Skip to content

fix(parser): fix false positive parsing optional member expr#9534

Merged
graphite-app[bot] merged 1 commit intomainfrom
c/03-04-fix_parser_fix_false_positive_parsing_optional_member_expr
Mar 4, 2025
Merged

fix(parser): fix false positive parsing optional member expr#9534
graphite-app[bot] merged 1 commit intomainfrom
c/03-04-fix_parser_fix_false_positive_parsing_optional_member_expr

Conversation

@camc314
Copy link
Contributor

@camc314 camc314 commented Mar 4, 2025

closes #9525

@github-actions github-actions bot added A-parser Area - Parser C-bug Category - Bug labels Mar 4, 2025
Copy link
Contributor Author

camc314 commented Mar 4, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

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.

@camc314 camc314 marked this pull request as ready for review March 4, 2025 10:11
@codspeed-hq
Copy link

codspeed-hq bot commented Mar 4, 2025

CodSpeed Performance Report

Merging #9534 will not alter performance

Comparing c/03-04-fix_parser_fix_false_positive_parsing_optional_member_expr (2c6e3f1) with main (2326cef)

Summary

✅ 33 untouched benchmarks

@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Mar 4, 2025
Copy link
Member

Boshen commented Mar 4, 2025

Merge activity

  • Mar 4, 5:42 AM EST: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Mar 4, 5:42 AM EST: A user added this pull request to the Graphite merge queue.
  • Mar 4, 5:47 AM EST: A user merged this pull request with the Graphite merge queue.

@graphite-app graphite-app bot force-pushed the c/03-04-fix_parser_fix_false_positive_parsing_optional_member_expr branch from b38b20b to 2c6e3f1 Compare March 4, 2025 10:42
@graphite-app graphite-app bot merged commit 2c6e3f1 into main Mar 4, 2025
26 checks passed
@graphite-app graphite-app bot deleted the c/03-04-fix_parser_fix_false_positive_parsing_optional_member_expr branch March 4, 2025 10:47
@oxc-bot oxc-bot mentioned this pull request Mar 5, 2025
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

0-merge Merge with Graphite Merge Queue A-parser Area - Parser C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

more cases of unexpected optional chaining parsing without errors

2 participants