Skip to content

fix(linter): prepend framework configs before baseConfig in flat config generation#34898

Merged
FrozenPandaz merged 1 commit intomasterfrom
gh-32923
Mar 20, 2026
Merged

fix(linter): prepend framework configs before baseConfig in flat config generation#34898
FrozenPandaz merged 1 commit intomasterfrom
gh-32923

Conversation

@leosvelperez
Copy link
Copy Markdown
Member

@leosvelperez leosvelperez commented Mar 18, 2026

Current Behavior

Framework generators append predefined configs (flat/react, flat/angular, etc.) after baseConfig in the flat config array. In flat config, later entries override earlier ones, so framework rules override user root rules.

Additionally, the parser/plugins config entries in flat/typescript, flat/javascript, and flat/angular have no files restriction, applying the TypeScript parser to all files globally — including .html, .json, and other non-TS/JS files. This was partially fixed in PR #28381 (which scoped rules/extends) but the parser entries were missed.

Expected Behavior

Framework configs are inserted before baseConfig, giving user root config higher priority. Root standalone projects (no baseConfig) are unaffected.

Parser/plugins entries are scoped to their respective file types, so .html files get the correct parser (Angular template parser, or ESLint default) instead of the TypeScript parser.

Changes

  • Implement checkBaseConfig option in addBlockToFlatConfigExport to insert before ...baseConfig when present
  • Framework generators (@nx/react, @nx/angular, @nx/next, etc.) pass checkBaseConfig: true
  • Scope parser entries in flat/typescript to **/*.ts, **/*.tsx, **/*.cts, **/*.mts
  • Scope parser entries in flat/javascript to **/*.js, **/*.jsx, **/*.cjs, **/*.mjs
  • Scope processor/plugins entry in flat/angular to **/*.ts
  • Refactor addPredefinedConfigToFlatLintConfig to use an options object for optional params
  • Fix regex patterns in react-native and expo jest config templates to use [.] instead of \. — avoids no-useless-escape lint errors and fixes a latent bug where \. in a string literal matched any character instead of a literal dot

Related Issue(s)

Fixes #32923

@leosvelperez leosvelperez requested a review from a team as a code owner March 18, 2026 09:50
@leosvelperez leosvelperez requested a review from MaxKless March 18, 2026 09:50
@leosvelperez leosvelperez self-assigned this Mar 18, 2026
@netlify
Copy link
Copy Markdown

netlify bot commented Mar 18, 2026

Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit ce7c868
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/69bbf95be1d0df0008cadbda
😎 Deploy Preview https://deploy-preview-34898--nx-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 18, 2026

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit ce7c868
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/69bbf95ba8734100083d4053
😎 Deploy Preview https://deploy-preview-34898--nx-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@nx-cloud
Copy link
Copy Markdown
Contributor

nx-cloud bot commented Mar 18, 2026

View your CI Pipeline Execution ↗ for commit ce7c868

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 55m 16s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 6s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 9s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 3s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded <1s View ↗
nx affected -t e2e-macos-local --parallel=1 --b... ✅ Succeeded 1m 30s View ↗

☁️ Nx Cloud last updated this comment at 2026-03-19 15:37:47 UTC

@leosvelperez leosvelperez force-pushed the gh-32923 branch 2 times, most recently from 7cc74c4 to 5402a74 Compare March 18, 2026 11:35
nx-cloud[bot]

This comment was marked as outdated.

@leosvelperez leosvelperez marked this pull request as draft March 18, 2026 11:49
@leosvelperez leosvelperez marked this pull request as ready for review March 18, 2026 15:16
Comment thread packages/eslint/src/generators/utils/flat-config/ast-utils.ts
nx-cloud[bot]

This comment was marked as outdated.

nx-cloud[bot]

This comment was marked as outdated.

nx-cloud[bot]

This comment was marked as outdated.

@leosvelperez leosvelperez marked this pull request as draft March 19, 2026 09:07
In flat config, later array entries override earlier ones. Framework
generators appended predefined configs (flat/react, flat/angular, etc.)
after baseConfig, causing framework rules to override user root rules.

Implement the checkBaseConfig option in addBlockToFlatConfigExport to
find the ...baseConfig spread element and insert before it. Framework
generators pass checkBaseConfig: true so their configs are placed before
baseConfig, giving user root config higher priority. When baseConfig
is not found (root standalone projects), falls back to appending.

Also scope the parser/plugins config entries in flat/typescript,
flat/javascript, and flat/angular to their respective file types.
Previously these entries had no files restriction, applying the
TypeScript parser to all files globally (including .html, .json, etc.).
This completes the scoping fix started in PR #28381 which only scoped
the rules/extends but missed the parser entries.

Refactor addPredefinedConfigToFlatLintConfig to use an options object
instead of positional params for optional arguments.
Copy link
Copy Markdown
Contributor

@nx-cloud nx-cloud bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

At least one additional CI pipeline execution has run since the conclusion below was written and it may no longer be applicable.

Nx Cloud has identified a possible root cause for your failed CI:

We classified vue:build-base as an environment issue rather than a code change because the failure is caused by a missing devkit build artifact (dist/packages/devkit/index.d.ts), which is a CI pipeline dependency ordering problem unrelated to this PR's ESLint flat config changes. Our analysis confirms devkit is not in the set of touched projects, and the same error does not appear on master. Rerunning the pipeline after devkit:build completes should resolve this.

No code changes were suggested for this issue.

Trigger a rerun:

Rerun CI

Nx Cloud View detailed reasoning on Nx Cloud ↗

🔔 Heads up, your workspace has pending recommendations ↗ to auto-apply fixes for similar failures.


🎓 Learn more about Self-Healing CI on nx.dev

@leosvelperez leosvelperez marked this pull request as ready for review March 19, 2026 15:57
@FrozenPandaz FrozenPandaz merged commit d5f51d6 into master Mar 20, 2026
26 of 29 checks passed
@FrozenPandaz FrozenPandaz deleted the gh-32923 branch March 20, 2026 21:53
@github-actions
Copy link
Copy Markdown
Contributor

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ESLint root rules are ignored

2 participants