Commit 4bbd4b1
authored
chore(repo): migrate nx repo to eslint v9 flat config (#35359)
## Current Behavior
The nx repo uses the legacy eslintrc format (`.eslintrc.json`,
`.eslintignore`) with ESLint v8 and outdated plugin versions. Several of
those plugins ship code that crashes under ESLint v9 (`context.getScope`
removed, etc.), and the `@nx/eslint` / `@nx/eslint-plugin` sources still
reference APIs removed in v9 (`Linter.defineParser`,
`Linter.defineRule`, classic `Linter.Config` shape).
## Expected Behavior
Every project in the repo uses an `eslint.config.mjs` flat config, the
ESLint ecosystem is on the latest v9-compatible versions, and
`@nx/eslint` / `@nx/eslint-plugin` sources compile and test cleanly
against the v9 type split.
### Main changes
- Replaced every `.eslintrc.json` / `.eslintignore` with an
`eslint.config.mjs`.
- Rewrote the root `eslint.config.mjs`:
- Exports a named `baseConfig` that leaf configs import, plus a default
export that opts out of linting (`**/*` ignored) so the root acts as a
shared base and isn't lint-checked directly.
- Drops `FlatCompat` in favor of native plugin imports.
- Exports shared `reactHooksV7Off`, `e2eTestOnlyIgnores`, and a
`storybookConfigs` wrapper that filters v10's preset down to
`storybook/*` rules (the preset references foreign rules like
`import-x/*` that we don't register).
- Cleaned up leaf configs emitted by the generator: deduplicated file
entries, merged split `package.json` blocks, fixed the jsonc parser
namespace import after v3 dropped its default export.
- Scoped the 15 e2e projects to `*.test.ts` files only via a shared
export.
- Bumped the ESLint ecosystem to the latest v9-compatible versions:
`eslint@^9.39.4`, `@eslint/js@^9.39.4`, `@typescript-eslint/*@^8.58.2`,
`eslint-plugin-storybook@^10.3.5`, `eslint-plugin-react-hooks@^7.1.0`,
`eslint-plugin-jsx-a11y@^6.10.2`, `eslint-plugin-import@^2.32.0`,
`eslint-plugin-playwright@^2.10.1`, `eslint-plugin-cypress@^6.3.1`,
`eslint-plugin-jest@^29.15.2`, `toml-eslint-parser@^1.0.3`,
`jsonc-eslint-parser@^3.1.0`, `angular-eslint@^21.3.1`. Dropped
`@eslint/eslintrc`, `@types/eslint`, `@types/eslint__js`.
- Aligned `@nx/eslint` source with the v9 type split: `Linter.Config` →
`Linter.LegacyConfig`, `ESLint.Options` → `ESLint.LegacyOptions`
wherever the underlying shape is eslintrc.
- Rewrote `@nx/eslint-plugin` rule specs (`dependency-checks`,
`enforce-module-boundaries`) as flat-config inline tests since
`Linter.defineParser`/`defineRule` were removed in v9.
- Aligned react/angular/expo/react-native add-linting helpers with the
v9 type split.
- Migrated `tools/eslint-rules` specs from `TSESLint.RuleTester` (legacy
config, rejected by v9's flat Linter) to
`@typescript-eslint/rule-tester`; added `isolatedModules: true` so
ts-jest resolves the new types under `module: node16`.
- Downgraded the new react-hooks v7 rules to `off` via a shared export
so the migration doesn't require rewriting legacy code.
- Auto-fixed unused eslint-disable directives
(`linterOptions.reportUnusedDisableDirectives` defaults to warn in v9).
- Ignored `packages/workspace/**/__fixtures__/**` in lint and updated
the affected snapshot so the fixture matches what the jest generator
templates actually emit.
### Note on ESLint v10
This PR stays on ESLint v9. A few plugins we rely on
(`eslint-plugin-import`, `eslint-plugin-jsx-a11y`,
`eslint-plugin-react`) still don't declare v10 peer support. The jump to
v10 will happen in a follow-up PR once those plugins publish
v10-compatible releases.1 parent 1507788 commit 4bbd4b1
319 files changed
Lines changed: 3813 additions & 4206 deletions
File tree
- astro-docs
- e2e
- angular
- cypress
- expo
- js
- next
- node
- nuxt
- nx-init
- nx
- react-native
- react
- release
- remix
- storybook
- workspace-create
- examples/angular-rspack
- appshell-css
- csr-css
- csr-i18n
- csr-scss
- csr-tailwind
- module-federation
- host
- remote
- ssg-css
- ssr-css
- zoneless-csr-css
- zoneless-csr-i18n
- zoneless-ssg-css
- zoneless-ssr-css
- graph
- client-e2e
- src/support
- client
- src
- app
- console-migrate
- console-project-details
- feature-projects
- feature-tasks
- ui-components
- migrate
- .storybook
- src/lib
- components
- state/automatic
- project-details
- src/lib
- ui-code-block
- .storybook
- ui-common
- ui-icons
- ui-project-details
- .storybook
- src/lib
- project-details
- show-all-options
- target-configuration-details-group-list
- target-configuration-details-header
- target-configuration-details-list-item
- target-source-info
- utils
- ui-render-config
- nx-dev
- data-access-documents
- feature-ai
- feature-analytics
- feature-feedback
- feature-search
- models-document
- models-package
- nx-dev-e2e
- src
- nx-dev
- ui-animations
- ui-blog
- ui-common
- ui-courses
- ui-fence
- ui-icons
- ui-markdoc
- ui-podcast
- ui-pricing
- ui-primitives
- src/lib
- ui-references
- ui-theme
- ui-video-courses
- util-ai
- packages
- angular-rspack-compiler
- angular-rspack
- src/lib
- plugins
- utils
- angular
- src/generators/add-linting/lib
- create-nx-plugin
- create-nx-workspace
- bin
- cypress
- detox
- devkit
- docker
- dotnet
- src/utils
- esbuild
- eslint-plugin
- src/rules
- eslint
- src
- executors/lint/utility
- generators
- init
- utils
- flat-config
- utils
- expo
- src/utils
- express
- gradle
- jest
- js
- src/executors/tsc/lib
- maven
- module-federation
- src
- plugins/utils
- utils
- with-module-federation/rspack
- nest
- next
- node
- nuxt
- nx
- src
- adapter
- command-line/init/implementation
- dot-nx
- migrations
- update-17-2-0
- update-20-0-0
- native
- plugins/js/lock-file/utils
- utils/yarn-syml
- playwright
- plugin
- react-native
- src/utils
- react
- src
- generators/stories
- utils
- remix
- src/generators
- action
- loader
- rollup
- rsbuild
- rspack
- src
- executors/module-federation-static-server
- generators
- convert-webpack
- init
- utils
- storybook
- vitest
- vite
- vue
- src/generators/library/__snapshots__
- webpack
- web
- workspace
- src/generators/remove/lib
- __fixtures__
- __snapshots__
- tools
- documentation/create-embeddings
- eslint-rules
- rules
- workspace-plugin
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
This file was deleted.
0 commit comments