Skip to content

fix(linter): delete override block when update returns undefined in replaceOverride#34070

Merged
jaysoo merged 1 commit intomasterfrom
fix_eslint_replace_ast
Jan 9, 2026
Merged

fix(linter): delete override block when update returns undefined in replaceOverride#34070
jaysoo merged 1 commit intomasterfrom
fix_eslint_replace_ast

Conversation

@jaysoo
Copy link
Member

@jaysoo jaysoo commented Jan 9, 2026

I found regression in replaceOverride behavior that isn't guarded against. There is migration from v17 (https://github.com/nrwl/nx/blob/20.8.x/packages/next/src/migrations/update-17-2-7/remove-eslint-rules-patch.ts#L17) that shows that when update function returns undefined, then that override entry should be removed.

We had no other unit tests to cover this case previously, so it was missed until I tried cherry-picking the fix to 20.8.x branch.

There was also a bug with flat config in v20 and v21 where not passing update function for flat config leads to an error due to update(data) being called without checking if update exists (since it's optional). We never actually skip on passing update (which makes replaceOverride useless since it's noop), so I marked it as required arg now.

Current Behavior

When replaceOverride is called with an update function that returns undefined, the override block is not removed. This is inconsistent with the JSON code path which uses splice to remove the override.

Expected Behavior

When the update function returns undefined, the entire override block should be deleted from the flat config, matching the JSON path behavior.

…eplaceOverride

## Current Behavior
When `replaceOverride` is called with an update function that returns
`undefined`, the override block is not removed. This is inconsistent
with the JSON code path which uses `splice` to remove the override.

## Expected Behavior
When the update function returns `undefined`, the entire override block
should be deleted from the flat config, matching the JSON path behavior.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@jaysoo jaysoo requested a review from a team as a code owner January 9, 2026 17:55
@jaysoo jaysoo requested a review from leosvelperez January 9, 2026 17:55
@vercel
Copy link

vercel bot commented Jan 9, 2026

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

Project Deployment Review Updated (UTC)
nx-dev Ready Ready Preview Jan 9, 2026 6:00pm

@netlify
Copy link

netlify bot commented Jan 9, 2026

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit af483ec
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/6961411fdbff69000855d05f
😎 Deploy Preview https://deploy-preview-34070--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 9, 2026

View your CI Pipeline Execution ↗ for commit af483ec

Command Status Duration Result
nx affected --targets=lint,test,test-kt,build,e... ✅ Succeeded 9m 31s 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 2s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-01-09 20:13:46 UTC

@jaysoo jaysoo merged commit 0fe39b2 into master Jan 9, 2026
21 of 22 checks passed
@jaysoo jaysoo deleted the fix_eslint_replace_ast branch January 9, 2026 20:16
FrozenPandaz pushed a commit that referenced this pull request Jan 14, 2026
…eplaceOverride (#34070)

I found regression in `replaceOverride` behavior that isn't guarded
against. There is migration from v17
(https://github.com/nrwl/nx/blob/20.8.x/packages/next/src/migrations/update-17-2-7/remove-eslint-rules-patch.ts#L17)
that shows that when `update` function returns `undefined`, then that
override entry should be removed.

We had no other unit tests to cover this case previously, so it was
missed until I tried cherry-picking the fix to `20.8.x` branch.

There was also a bug with flat config in v20 and v21 where not passing
`update` function for flat config leads to an error due to
`update(data)` being called without checking if `update` exists (since
it's optional). We never actually skip on passing `update` (which makes
`replaceOverride` useless since it's noop), so I marked it as required
arg now.

## Current Behavior

When `replaceOverride` is called with an update function that returns
`undefined`, the override block is not removed. This is inconsistent
with the JSON code path which uses `splice` to remove the override.

## Expected Behavior

When the update function returns `undefined`, the entire override block
should be deleted from the flat config, matching the JSON path behavior.

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
(cherry picked from commit 0fe39b2)
@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 15, 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.

2 participants