Lint config files with ESLint and Prettier - #1655
Draft
VPS-thodax wants to merge 1 commit into
Draft
Conversation
Config files were largely excluded from linting: ESLint only ran on `src/`
and JSON files, so no `.mjs`/`.mts`/`.ts` config file was ever checked, and the
Prettier globs missed `.mjs`/`.mts` entirely as well as every file in the
repository root. As a result `site/eslint.config.mjs` and
`site-configs/site-configs.ts` were unformatted, and the `next.config.*`
override in `site/eslint.config.mjs` was dead configuration.
- Each package's `lint:eslint` now also covers the package-root
`*.{ts,mts,js,mjs,cjs}` files, and `lint:prettier` adds `mts`/`mjs`/`cjs`
- Each `eslint.config.mjs` disables the TypeScript project service for those
config files (they are not part of any tsconfig) and allows them to import
devDependencies
- Root `lint:root`/`lint:fix:root` now cover repository-root files and
`site-configs/`, which the previous glob excluded, plus `ts`/`mts`/`mjs`/`cjs`
- `lint-staged` mirrors the new patterns and runs ESLint on config files
- Fixed the findings this surfaced, and the `lint:create-app` script, which ran
the API lint instead of create-app's
COM-239
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
ESLint runs on
src/and**/*.jsononly, and the Prettier globs miss.mjs/.mtsas well as every file in the repository root — so config files are effectively unlinted. As a result threeeslint.config.mjsfiles andsite-configs/site-configs.tsare unformatted onmain, and thenext.config.*override insite/eslint.config.mjsthat bansprocess.envis dead configuration: the file it targets never reaches ESLint.Solution
lint:eslintandlint:prettiernow cover the package-root config files, andlint:rootcovers repository-root files plussite-configs/, which the old glob excluded by prefix.lint-stagedmirrors the new patterns.lint:create-app, which ran the API lint instead of create-app's.Decisions
eslint.config.mjsdisables it for them and allows devDependency imports. Adding them to everytsconfig.jsonincludewould have pulled tooling configs intotscand the build output. No rule loses type information — the shared preset usestseslint.configs.recommended, not the type-checked variant.Further information