Skip to content

fix(formatter): normalize destructuring keys in DCR#22478

Merged
graphite-app[bot] merged 1 commit into
mainfrom
codex/fix-dcr-destructuring-keys
May 16, 2026
Merged

fix(formatter): normalize destructuring keys in DCR#22478
graphite-app[bot] merged 1 commit into
mainfrom
codex/fix-dcr-destructuring-keys

Conversation

@camc314

@camc314 camc314 commented May 16, 2026

Copy link
Copy Markdown
Contributor

Fixes a false positive in formatter detect-code-removal checks when formatting object destructuring keys.

The detector already normalizes object-like property keys because formatter output can change quoted keys into equivalent unquoted or numeric keys. This extends that normalization to destructuring binding and assignment pattern properties, covering cases like:

const { index, "0": code } = match;

which formats to:

const { index, 0: code } = match;

without removing code.

failing monitor oxc: https://github.com/oxc-project/monitor-oxc/actions/runs/25915602942/job/76171605899

@github-actions github-actions Bot added the A-formatter Area - Formatter label May 16, 2026
@codspeed-hq

codspeed-hq Bot commented May 16, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 44 untouched benchmarks
⏩ 7 skipped benchmarks1


Comparing codex/fix-dcr-destructuring-keys (9ae4246) with main (118194a)2

Open in CodSpeed

Footnotes

  1. 7 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (723beea) during the generation of this report, so 118194a was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@camc314 camc314 marked this pull request as ready for review May 16, 2026 11:08
@camc314 camc314 requested review from Dunqing and leaysgur as code owners May 16, 2026 11:08
Copilot AI review requested due to automatic review settings May 16, 2026 11:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Extends the formatter's detect-code-removal (DCR) key normalization to cover destructuring binding and assignment target property patterns, preventing false positives where quoted keys are reformatted to unquoted/numeric equivalents.

Changes:

  • Adds BindingProperty and AssignmentTargetPropertyProperty to the parent-kind match that triggers key normalization in StatsCollector.
  • Adds two regression test cases covering object destructuring and assignment destructuring with quoted numeric keys.

@leaysgur leaysgur left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you!

@leaysgur leaysgur added the 0-merge Merge with Graphite Merge Queue label May 16, 2026

leaysgur commented May 16, 2026

Copy link
Copy Markdown
Member

Merge activity

Fixes a false positive in formatter detect-code-removal checks when formatting object destructuring keys.

The detector already normalizes object-like property keys because formatter output can change quoted keys into equivalent unquoted or numeric keys. This extends that normalization to destructuring binding and assignment pattern properties, covering cases like:

```js
const { index, "0": code } = match;
```

which formats to:

```js
const { index, 0: code } = match;
```

without removing code.

failing monitor oxc: https://github.com/oxc-project/monitor-oxc/actions/runs/25915602942/job/76171605899
@graphite-app graphite-app Bot force-pushed the codex/fix-dcr-destructuring-keys branch from 9ae4246 to 8c1da44 Compare May 16, 2026 11:18
@graphite-app graphite-app Bot merged commit 8c1da44 into main May 16, 2026
28 checks passed
@graphite-app graphite-app Bot deleted the codex/fix-dcr-destructuring-keys branch May 16, 2026 11:22
@graphite-app graphite-app Bot removed the 0-merge Merge with Graphite Merge Queue label May 16, 2026
camc314 pushed a commit that referenced this pull request May 18, 2026
# Oxlint
### 🚀 Features

- 1ae291e linter/no-underscore-dangle: Add `allowInUsingDeclarations`
option (#22483) (吴杨帆)
- 0440b0f linter/eslint: Implement `id-match` rule (#22379) (Vladislav
Sayapin)
- 65bf119 linter: Implement react no-object-type-as-default-prop
(#22481) (uhyo)
- 2a6ddce linter/eslint: Implement `no-implied-eval` rule (#22391)
(Vladislav Sayapin)
- d3a3c1d linter: Auto detect agents from CLI and transition to the
agent output format (#22068) (Jovi De Croock)
- 625758a linter/vitest: Implement padding-around-after-all-blocks rule
(#21788) (kapobajza)
- 37680b0 linter: Implement react no-unstable-nested-components (#22248)
(Jovi De Croock)
- d8d9c74 linter: Implement import/newline-after-import rule (#19142)
(Ryuya Yanagi)

### 🐛 Bug Fixes

- 3f59e03 linter: Only call rayon/miette/tracing inits once (#21899)
(Matiss Janis Aboltins)
- 602dfd6 linter/promise/no-return-wrap: Detect Promise calls in all
branches (#22474) (zennnnnnn11)
- e182aee linter: Allow dialogs and popovers for no_autofocus (#22289)
(mehm8128)
- 7ffb710 linter/jest/vitest: Jest/no-standalone-expect ignores
additionalTestBlockFunctions option for jest/vitest hooks (#22477)
(kapobajza)
- c6f2d3f linter: Add more expression support for iframe-has-title
(#22460) (mehm8128)
- 5747ff1 linter: Avoid enabling jest with vitest plugin (#22499)
(camc314)
- 863984f linter/no-find-dom-node: Run on all files (#22479) (bab)

### ⚡ Performance

- 2afef79 linter: Optimize `no-loop-func` (#22491) (camchenry)
- 4c9ca72 oxlint: Align walker thread count with rayon pool (#22494)
(Boshen)

### 📚 Documentation

- f7967c7 linter/id-match: Clarify `onlyDeclarations` config docs
(#22523) (camc314)
- 1e0c97f linter: Fix closing code block in documentation for
`padding-around-after-all-blocks` rule. (#22513) (connorshea)
- a9049fd linter: Exclude directly provide autoFocus to dialog pattern
(#22510) (mehm8128)
# Oxfmt
### 🐛 Bug Fixes

- 8ee946f formatter/sort_imports: Use label to classify lines (#22512)
(leaysgur)
- 8c1da44 formatter: Normalize destructuring keys in DCR (#22478)
(camc314)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-formatter Area - Formatter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants