fix(ast): include rest properties when using get_binding_identifiers#15710
Conversation
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. |
72e8817 to
4f50b0f
Compare
CodSpeed Performance ReportMerging #15710 will not alter performanceComparing Summary
Footnotes |
4f50b0f to
a30af92
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR fixes the get_binding_identifiers method to correctly include rest properties (...rest) when extracting binding identifiers from array and object destructuring patterns. Previously, rest properties were not being included, which could cause issues in various code analysis scenarios.
- Adds support for rest properties in both
ArrayPatternandObjectPatterndestructuring - Removes redundant
BindingRestElementhandling from theno_const_assignlinter rule (now handled automatically) - Adds test cases to ensure const-to-let conversion doesn't incorrectly transform const declarations with rest properties that are reassigned
Reviewed Changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| crates/oxc_ast/src/ast_impl/js.rs | Modified append_binding_identifiers to include rest properties for both array and object patterns |
| crates/oxc_linter/src/rules/eslint/no_const_assign.rs | Removed explicit BindingRestElement handling, now covered by the fixed get_binding_identifiers |
| crates/oxc_minifier/src/peephole/normalize.rs | Added test cases for const declarations with rest properties being reassigned |
Comments suppressed due to low confidence (1)
crates/oxc_ast/src/ast_impl/js.rs:1351
- The documentation for
get_binding_identifiersshould be updated to include examples with rest properties, since the method now returns rest bindings. Consider adding examples likelet {a, ...rest} = objwould return[a, rest]andlet [a, ...rest] = arrwould return[a, rest].
/// Returns the bound identifiers in this binding pattern.
///
/// ## Example
///
/// - `let {} = obj` would return `[]`
/// - `let {a, b} = obj` would return `[a, b]`
/// - `let {a = 1, b: c} = obj` would return `[a, c]`
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
get_binding_identifiersget_binding_identifiers
|
@camc314 I've only not hit "merge" because it's not assigned to me. |
Merge activity
|
#15710) previously, the rest param of an `ArrayPattern` inside a `BindingPattern` would never be visited, this meant it had to be manually visited inside the linter. It also meant that the minifier incorrectly transformed `{ const { a, ...b } = {}; b = {} }` to `{ let const { a, ...b } = {} }` which is a difference in runtime behvaiour (before is a `TypeError`, after is not.
a30af92 to
440a977
Compare
### 💥 BREAKING CHANGES - ea51b0b napi: [**BREAKING**] Standardize function naming with sync suffixes (#15661) (Boshen) ### 🚀 Features - 77efb76 parser: Improve error message for invalid switch clauses (#15728) (sapphi-red) - 5691727 parser: Improve `import source` `from` error message (#15727) (sapphi-red) - b7404bc parser: Improve error message for missing function body (#15726) (sapphi-red) - 71c2fb0 parser: Improve error message when JSX is found while not enabled (#15725) (sapphi-red) - 56e7e44 minifier: Disable removal of unnecessary `use strict` directives for DCE (#15691) (sapphi-red) - 8a61cfd allocator, ast: Introduce `UnstableAddress` trait (#15700) (overlookmotel) - f5ce55a napi: Export all options using wildcard exports (Boshen) - 68703b9 minifier: Rotate binary expressions to remove parentheses (#15473) (sapphi-red) ### 🐛 Bug Fixes - c023ba6 semantic: Do not duplicate statements in temp `Vec` when binding `TSModuleDeclaration`s (#15724) (overlookmotel) - d60ca81 parser: Reject `import something 'source'` (#15746) (sapphi-red) - e0728fa ast: Exclude comment end position from `is_inside_comment` check (#15753) (camc314) - 9f54a36 semantic: Error on `\00` in strict mode (#15743) (sapphi-red) - 440a977 ast: Include rest properties when using `get_binding_identifiers` (#15710) (camc314) ### ⚡ Performance - 1f09d3c parser: Faster checking for invalid modifiers (#15717) (overlookmotel) - d8d4e31 ast: Use loop instead of recursion in `TSModuleDeclarationBody::as_module_block_mut` (#15713) (overlookmotel) ### 📚 Documentation - e033d50 ast: Clarify behavior of `TSModuleDeclaration::has_use_strict_directive` (#15730) (overlookmotel) - 9eda70f allocator: Improve docs for `Address` methods (#15697) (overlookmotel)
### 💥 BREAKING CHANGES - ea51b0b napi: [**BREAKING**] Standardize function naming with sync suffixes (#15661) (Boshen) ### 🚀 Features - 77efb76 parser: Improve error message for invalid switch clauses (#15728) (sapphi-red) - 5691727 parser: Improve `import source` `from` error message (#15727) (sapphi-red) - b7404bc parser: Improve error message for missing function body (#15726) (sapphi-red) - 71c2fb0 parser: Improve error message when JSX is found while not enabled (#15725) (sapphi-red) - 56e7e44 minifier: Disable removal of unnecessary `use strict` directives for DCE (#15691) (sapphi-red) - 8a61cfd allocator, ast: Introduce `UnstableAddress` trait (#15700) (overlookmotel) - f5ce55a napi: Export all options using wildcard exports (Boshen) - 68703b9 minifier: Rotate binary expressions to remove parentheses (#15473) (sapphi-red) ### 🐛 Bug Fixes - c023ba6 semantic: Do not duplicate statements in temp `Vec` when binding `TSModuleDeclaration`s (#15724) (overlookmotel) - d60ca81 parser: Reject `import something 'source'` (#15746) (sapphi-red) - e0728fa ast: Exclude comment end position from `is_inside_comment` check (#15753) (camc314) - 9f54a36 semantic: Error on `\00` in strict mode (#15743) (sapphi-red) - 440a977 ast: Include rest properties when using `get_binding_identifiers` (#15710) (camc314) ### ⚡ Performance - 1f09d3c parser: Faster checking for invalid modifiers (#15717) (overlookmotel) - d8d4e31 ast: Use loop instead of recursion in `TSModuleDeclarationBody::as_module_block_mut` (#15713) (overlookmotel) ### 📚 Documentation - e033d50 ast: Clarify behavior of `TSModuleDeclaration::has_use_strict_directive` (#15730) (overlookmotel) - 9eda70f allocator: Improve docs for `Address` methods (#15697) (overlookmotel)
# Oxlint ### 🚀 Features - c199e38 linter: Implement config for all tsgolint rules supporting options (#15659) (camchenry) - 7598b3e linter: Allow configuring tsgolint rules (#15286) (camchenry) - e77f2ce vscode: Support `oxlint --lsp` (#15680) (Sysix) - e01c551 oxlint: Add `--lsp` flag to run the language server (#15611) (Sysix) - ac5c2ab lsp/fmt: Support ignore files & patterns (#15647) (Sysix) - e50a9bf linter: Add unicorn/prefer-response-static-json rule (#15692) (Mikhail Baev) - f5d9abb oxlint: Add enabled? column to --rules cli output (#15213) (Wren) - 6b5205c linter/plugins: Implement deprecated `SourceCode#getJSDocComment` method (#15653) (overlookmotel) - 5eccff1 linter/plugins: Implement deprecated `SourceCode` tokens methods (#15645) (overlookmotel) - 4c62ffa language_server: Add `run_server` helper for CLI tools (#15609) (Sysix) - 0d52a5e linter/plugins: Implement `Context#parserOptions` getter (#15632) (overlookmotel) - 287a538 linter/plugins: Implement `Context#get*` deprecated methods (#15606) (overlookmotel) - 84de1ca oxlint,oxfmt: Allow comments and also commas for vscode-json-ls (#15612) (leaysgur) - e763919 linter: Add test to enforce schema documentation for rules with configuration options (#15234) (Connor Shea) - 6cd0b5f linter/no-callback-in-promise: Add support for `timeoutsErr` option (#15507) (Li Wei) ### 🐛 Bug Fixes - 1decd57 linter/no-empty-named-blocks: Only search within node for comma token (#15751) (camc314) - 17c3d6d linter: Improve docs, diagnostic message, and implementation of typescript/consistent-indexed-object-style rule. (#15750) (connorshea) - 78a6df2 linter/no-empty-named-blocks: Skip comments when searching for token (#15735) (camc314) - 042befd linter/require-await: Skip comments when searching for token (#15734) (camc314) - 7a78220 linter/no-async-await: Skip comments when searching for token (#15733) (camc314) - 23b9ad1 linter/consistent-type-specifier-style: Skip comments when searching for token (#15732) (camc314) - 440a977 ast: Include rest properties when using `get_binding_identifiers` (#15710) (camc314) - 516d14e linter/no-namespace: Skip comments when searching for token (#15716) (camc314) - b5aaace linter/prefer-namespace-keyword: Skip comments when searching for token (#15715) (camc314) - 4eb9fa6 editor: Execute `oxc.path.server` in win32 with shell (#14203) (Sysix) - 9f991a4 linter: Reverse extends overrides priority (#14939) (Peter Wagenet) - 7c4a916 linter: Restores `oxlint --rules -f=json` functionality. (#15689) (Wren) - 24d00f4 linter/plugins: Add types for suggested fixes (#15636) (overlookmotel) - 257360f linter/plugins: Fill in TS type def for `RuleMeta` (#15629) (overlookmotel) - 81e179c linter: Allow file extensions without a dot in react/jsx-filename-extension rule (#15574) (Connor Shea) - 7a0e931 linter: Update the unicorn/prefer-add-event-listener rule with new JavaScript APIs (#15581) (connorshea) - bb5f8ca oxlint: Fix type annotation for big-endian (#15561) (Sysix) ### ⚡ Performance - e2a0997 linter/plugins: Recycle empty visitor object in ESLint compat mode (#15693) (overlookmotel) - 7528db4 language_server: Pass file content as a referenced `String` (#15568) (Sysix) - 54061e9 linter/plugins: Avoid implicit boolean coercion in `initLines` (#15641) (overlookmotel) - ccfd935 language_server: Avoid `Mutex` in `ServerLinter` (#15516) (Sysix) ### 📚 Documentation - 3ab750a linter: Clarify react-in-jsx-scope rule docs. (#15749) (connorshea) - a5feebc linter: `oxlint-disable` not `eslint-disable` (#15672) (overlookmotel) - 3d15805 linter: Reformat doc comments (#15670) (overlookmotel) - 16fcba6 linter: Remove "experimental" from description of stable features (#15669) (overlookmotel) - e62fd98 linter: Correct comment on what `EnablePlugins` does (#15668) (overlookmotel) - a25d31e linter: Fix grammar (#15666) (overlookmotel) - f5f452f linter: Add missing `perf` category (#15667) (overlookmotel) - 2c58952 linter: Add config docs for no-restricted-globals rule. (#15662) (connorshea) - a210b12 linter/plugins: Improve JSDoc comment for `RuleOptionsSchema` (#15642) (overlookmotel) - 3aabfac linter/plugins: Alter comments on `FILE_CONTEXT` used in ESLint-compat `Context` shim (#15605) (overlookmotel) - fd58aea linter: Fix a typo in the docs for react/no-is-mounted. (#15575) (Connor Shea) # Oxfmt ### 🚀 Features - 84de1ca oxlint,oxfmt: Allow comments and also commas for vscode-json-ls (#15612) (leaysgur) - 99823ad oxfmt: Print nothing for default(write) mode (#15583) (leaysgur) - 25a0163 formatter/sort_imports: Sort imports by `Array<Array<string>>` groups (#15578) (leaysgur) ### 🐛 Bug Fixes - bf20cf5 formatter: `CRLF` issue in the member chain (#15764) (Dunqing) - 5d688a0 formatter: Measuring multiline text in `fits_text` is incorrect (#15762) (Dunqing) - e306958 formatter: Regression case for test call (#15760) (Dunqing) - c42d983 formatter: Re-fix all cases that fail after `AstNode::Argument` was removed (#15676) (Dunqing) ### ⚡ Performance - d99a83f oxfmt: Use simdutf8 based read_to_string (#15614) (leaysgur) - 128e186 formatter/sort_imports: Precompute import metadata (#15580) (leaysgur) - cd31cc1 formatter/sort_imports: Use `Vec::with_capacity` for `next_elements` (#15579) (leaysgur) ### 📚 Documentation - 3d15805 linter: Reformat doc comments (#15670) (overlookmotel) Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
oxc-project#15710) previously, the rest param of an `ArrayPattern` inside a `BindingPattern` would never be visited, this meant it had to be manually visited inside the linter. It also meant that the minifier incorrectly transformed `{ const { a, ...b } = {}; b = {} }` to `{ let const { a, ...b } = {} }` which is a difference in runtime behvaiour (before is a `TypeError`, after is not.
### 💥 BREAKING CHANGES - ea51b0b napi: [**BREAKING**] Standardize function naming with sync suffixes (oxc-project#15661) (Boshen) ### 🚀 Features - 77efb76 parser: Improve error message for invalid switch clauses (oxc-project#15728) (sapphi-red) - 5691727 parser: Improve `import source` `from` error message (oxc-project#15727) (sapphi-red) - b7404bc parser: Improve error message for missing function body (oxc-project#15726) (sapphi-red) - 71c2fb0 parser: Improve error message when JSX is found while not enabled (oxc-project#15725) (sapphi-red) - 56e7e44 minifier: Disable removal of unnecessary `use strict` directives for DCE (oxc-project#15691) (sapphi-red) - 8a61cfd allocator, ast: Introduce `UnstableAddress` trait (oxc-project#15700) (overlookmotel) - f5ce55a napi: Export all options using wildcard exports (Boshen) - 68703b9 minifier: Rotate binary expressions to remove parentheses (oxc-project#15473) (sapphi-red) ### 🐛 Bug Fixes - c023ba6 semantic: Do not duplicate statements in temp `Vec` when binding `TSModuleDeclaration`s (oxc-project#15724) (overlookmotel) - d60ca81 parser: Reject `import something 'source'` (oxc-project#15746) (sapphi-red) - e0728fa ast: Exclude comment end position from `is_inside_comment` check (oxc-project#15753) (camc314) - 9f54a36 semantic: Error on `\00` in strict mode (oxc-project#15743) (sapphi-red) - 440a977 ast: Include rest properties when using `get_binding_identifiers` (oxc-project#15710) (camc314) ### ⚡ Performance - 1f09d3c parser: Faster checking for invalid modifiers (oxc-project#15717) (overlookmotel) - d8d4e31 ast: Use loop instead of recursion in `TSModuleDeclarationBody::as_module_block_mut` (oxc-project#15713) (overlookmotel) ### 📚 Documentation - e033d50 ast: Clarify behavior of `TSModuleDeclaration::has_use_strict_directive` (oxc-project#15730) (overlookmotel) - 9eda70f allocator: Improve docs for `Address` methods (oxc-project#15697) (overlookmotel)
# Oxlint ### 🚀 Features - c199e38 linter: Implement config for all tsgolint rules supporting options (oxc-project#15659) (camchenry) - 7598b3e linter: Allow configuring tsgolint rules (oxc-project#15286) (camchenry) - e77f2ce vscode: Support `oxlint --lsp` (oxc-project#15680) (Sysix) - e01c551 oxlint: Add `--lsp` flag to run the language server (oxc-project#15611) (Sysix) - ac5c2ab lsp/fmt: Support ignore files & patterns (oxc-project#15647) (Sysix) - e50a9bf linter: Add unicorn/prefer-response-static-json rule (oxc-project#15692) (Mikhail Baev) - f5d9abb oxlint: Add enabled? column to --rules cli output (oxc-project#15213) (Wren) - 6b5205c linter/plugins: Implement deprecated `SourceCode#getJSDocComment` method (oxc-project#15653) (overlookmotel) - 5eccff1 linter/plugins: Implement deprecated `SourceCode` tokens methods (oxc-project#15645) (overlookmotel) - 4c62ffa language_server: Add `run_server` helper for CLI tools (oxc-project#15609) (Sysix) - 0d52a5e linter/plugins: Implement `Context#parserOptions` getter (oxc-project#15632) (overlookmotel) - 287a538 linter/plugins: Implement `Context#get*` deprecated methods (oxc-project#15606) (overlookmotel) - 84de1ca oxlint,oxfmt: Allow comments and also commas for vscode-json-ls (oxc-project#15612) (leaysgur) - e763919 linter: Add test to enforce schema documentation for rules with configuration options (oxc-project#15234) (Connor Shea) - 6cd0b5f linter/no-callback-in-promise: Add support for `timeoutsErr` option (oxc-project#15507) (Li Wei) ### 🐛 Bug Fixes - 1decd57 linter/no-empty-named-blocks: Only search within node for comma token (oxc-project#15751) (camc314) - 17c3d6d linter: Improve docs, diagnostic message, and implementation of typescript/consistent-indexed-object-style rule. (oxc-project#15750) (connorshea) - 78a6df2 linter/no-empty-named-blocks: Skip comments when searching for token (oxc-project#15735) (camc314) - 042befd linter/require-await: Skip comments when searching for token (oxc-project#15734) (camc314) - 7a78220 linter/no-async-await: Skip comments when searching for token (oxc-project#15733) (camc314) - 23b9ad1 linter/consistent-type-specifier-style: Skip comments when searching for token (oxc-project#15732) (camc314) - 440a977 ast: Include rest properties when using `get_binding_identifiers` (oxc-project#15710) (camc314) - 516d14e linter/no-namespace: Skip comments when searching for token (oxc-project#15716) (camc314) - b5aaace linter/prefer-namespace-keyword: Skip comments when searching for token (oxc-project#15715) (camc314) - 4eb9fa6 editor: Execute `oxc.path.server` in win32 with shell (oxc-project#14203) (Sysix) - 9f991a4 linter: Reverse extends overrides priority (oxc-project#14939) (Peter Wagenet) - 7c4a916 linter: Restores `oxlint --rules -f=json` functionality. (oxc-project#15689) (Wren) - 24d00f4 linter/plugins: Add types for suggested fixes (oxc-project#15636) (overlookmotel) - 257360f linter/plugins: Fill in TS type def for `RuleMeta` (oxc-project#15629) (overlookmotel) - 81e179c linter: Allow file extensions without a dot in react/jsx-filename-extension rule (oxc-project#15574) (Connor Shea) - 7a0e931 linter: Update the unicorn/prefer-add-event-listener rule with new JavaScript APIs (oxc-project#15581) (connorshea) - bb5f8ca oxlint: Fix type annotation for big-endian (oxc-project#15561) (Sysix) ### ⚡ Performance - e2a0997 linter/plugins: Recycle empty visitor object in ESLint compat mode (oxc-project#15693) (overlookmotel) - 7528db4 language_server: Pass file content as a referenced `String` (oxc-project#15568) (Sysix) - 54061e9 linter/plugins: Avoid implicit boolean coercion in `initLines` (oxc-project#15641) (overlookmotel) - ccfd935 language_server: Avoid `Mutex` in `ServerLinter` (oxc-project#15516) (Sysix) ### 📚 Documentation - 3ab750a linter: Clarify react-in-jsx-scope rule docs. (oxc-project#15749) (connorshea) - a5feebc linter: `oxlint-disable` not `eslint-disable` (oxc-project#15672) (overlookmotel) - 3d15805 linter: Reformat doc comments (oxc-project#15670) (overlookmotel) - 16fcba6 linter: Remove "experimental" from description of stable features (oxc-project#15669) (overlookmotel) - e62fd98 linter: Correct comment on what `EnablePlugins` does (oxc-project#15668) (overlookmotel) - a25d31e linter: Fix grammar (oxc-project#15666) (overlookmotel) - f5f452f linter: Add missing `perf` category (oxc-project#15667) (overlookmotel) - 2c58952 linter: Add config docs for no-restricted-globals rule. (oxc-project#15662) (connorshea) - a210b12 linter/plugins: Improve JSDoc comment for `RuleOptionsSchema` (oxc-project#15642) (overlookmotel) - 3aabfac linter/plugins: Alter comments on `FILE_CONTEXT` used in ESLint-compat `Context` shim (oxc-project#15605) (overlookmotel) - fd58aea linter: Fix a typo in the docs for react/no-is-mounted. (oxc-project#15575) (Connor Shea) # Oxfmt ### 🚀 Features - 84de1ca oxlint,oxfmt: Allow comments and also commas for vscode-json-ls (oxc-project#15612) (leaysgur) - 99823ad oxfmt: Print nothing for default(write) mode (oxc-project#15583) (leaysgur) - 25a0163 formatter/sort_imports: Sort imports by `Array<Array<string>>` groups (oxc-project#15578) (leaysgur) ### 🐛 Bug Fixes - bf20cf5 formatter: `CRLF` issue in the member chain (oxc-project#15764) (Dunqing) - 5d688a0 formatter: Measuring multiline text in `fits_text` is incorrect (oxc-project#15762) (Dunqing) - e306958 formatter: Regression case for test call (oxc-project#15760) (Dunqing) - c42d983 formatter: Re-fix all cases that fail after `AstNode::Argument` was removed (oxc-project#15676) (Dunqing) ### ⚡ Performance - d99a83f oxfmt: Use simdutf8 based read_to_string (oxc-project#15614) (leaysgur) - 128e186 formatter/sort_imports: Precompute import metadata (oxc-project#15580) (leaysgur) - cd31cc1 formatter/sort_imports: Use `Vec::with_capacity` for `next_elements` (oxc-project#15579) (leaysgur) ### 📚 Documentation - 3d15805 linter: Reformat doc comments (oxc-project#15670) (overlookmotel) Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>

previously, the rest param of an
ArrayPattern inside aBindingPatternwould never be visited, this meant it had to be manually visited inside the linter. It also meant that the minifier incorrectly transformed{ const { a, ...b } = {}; b = {} } to{ let const { a, ...b } = {} }which is a difference in runtime behvaiour (before is aTypeError, after is not.