Skip to content

fix(linter): handle variable references in replaceOverride#34026

Merged
jaysoo merged 1 commit intomasterfrom
issue-34010
Jan 7, 2026
Merged

fix(linter): handle variable references in replaceOverride#34026
jaysoo merged 1 commit intomasterfrom
issue-34010

Conversation

@jaysoo
Copy link
Member

@jaysoo jaysoo commented Jan 5, 2026

The migration generator (@nx/plugin:migration) fails when due to ESLint flat config not being parsed correctly, leading to an error.

This happens because replaceOverride uses parseTextToJson to parse the config, which fails for non-JSON-serializable JavaScript expressions.

This PR fixes the issue by using AST parsing, like we did for hasOverrides here #33548.

Fixes #34010

@jaysoo jaysoo requested a review from a team as a code owner January 5, 2026 21:34
@jaysoo jaysoo requested a review from meeroslav January 5, 2026 21:34
@vercel
Copy link

vercel bot commented Jan 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
nx-dev Ready Ready Preview Jan 7, 2026 3:10pm

@netlify
Copy link

netlify bot commented Jan 5, 2026

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit 08dcdc1
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/695e75b9ec9c9200081f46f7
😎 Deploy Preview https://deploy-preview-34026--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
Contributor

nx-cloud bot commented Jan 5, 2026

View your CI Pipeline Execution ↗ for commit 08dcdc1

Command Status Duration Result
nx affected --targets=lint,test,test-kt,build,e... ✅ Succeeded 38m 22s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 2m 50s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 12s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 3s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-01-07 15:46:49 UTC

Copy link
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

A new CI pipeline execution was requested that may update the conclusion below...

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

We classified these failures as environment_state because none of them relate to the PR's changes to ESLint flat config parsing. The failures involve unrelated areas: plugin linting validation logic, React module federation runtime timeouts, and JSON parsing errors during project generation. The e2e-eslint test also shows a 0.44% flakiness rate, indicating intermittent environmental issues rather than problems introduced by the AST-based variable reference handling added in this PR.

No code changes were suggested for this issue.

If the issue was transient, you can trigger a rerun:

Rerun CI

Nx Cloud View detailed reasoning on Nx Cloud ↗


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

The migration generator (@nx/plugin:migration) fails when the project's
ESLint flat config contains variable references in property values, such as:
`plugins: { 'package-json': pluginPackageJson }`

This happens because `replaceOverride` uses `parseTextToJson` to parse
the config, which fails for non-JSON-serializable JavaScript expressions.

The migration generator should work correctly even when the ESLint config
contains variable references. The fix applies the same approach used in
PR #33548 for `hasOverride`: using AST-based property extraction instead
of JSON parsing.

Fixes #34010

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@jaysoo jaysoo merged commit 9fb5a6c into master Jan 7, 2026
21 checks passed
@jaysoo jaysoo deleted the issue-34010 branch January 7, 2026 17:56
jaysoo added a commit that referenced this pull request Jan 9, 2026
The migration generator (`@nx/plugin:migration`) fails when due to
ESLint flat config not being parsed correctly, leading to an error.

This happens because `replaceOverride` uses `parseTextToJson` to parse
the config, which fails for non-JSON-serializable JavaScript
expressions.

This PR fixes the issue by using AST parsing, like we did for
`hasOverrides` here #33548.

Fixes #34010

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
@github-actions
Copy link
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 Jan 13, 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.

Reopen https://github.com/nrwl/nx/issues/31796

3 participants