fix(parser): fix false positive parsing optional member expr#9534
Merged
graphite-app[bot] merged 1 commit intomainfrom Mar 4, 2025
Merged
Conversation
Contributor
Author
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
CodSpeed Performance ReportMerging #9534 will not alter performanceComparing Summary
|
Member
Merge activity
|
b38b20b to
2c6e3f1
Compare
camc314
added a commit
that referenced
this pull request
Dec 19, 2025
## Summary Implements the `unicorn/no-immediate-mutation` rule that disallows mutating a variable immediately after initialization. Closes #9534 ### What it detects - Array mutations: `array.push()`, `array.unshift()` - Object property assignments: `obj.foo = bar` - `Object.assign()` calls - Set mutations: `set.add()` - Map mutations: `map.set()` ### Features - Handles both variable declarations and assignment expressions - Correctly skips self-referencing mutations (e.g., `array.push(array[0])`) - Supports all statement containers including SwitchCase - Validates global references for Object/Set/Map to avoid false positives when these identifiers are shadowed ### Examples ```js // Bad const array = [1, 2]; array.push(3); const obj = { foo: 1 }; obj.bar = 2; const set = new Set([1]); set.add(2); // Good const array = [1, 2, 3]; const obj = { foo: 1, bar: 2 }; const set = new Set([1, 2]); ``` ## Test plan - All 94 pass cases and 118 fail cases from eslint-plugin-unicorn pass - Clippy passes with no warnings ## AI Assistance Disclosure I used Codex to review the changes, sanity-check the implementation against existing patterns, and help spot potential edge cases. --------- Co-authored-by: Cameron Clark <cameron.clark@hey.com>
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.

closes #9525