Skip to content

refactor(ast): remove AstKind for PropertyKey#12108

Merged
graphite-app[bot] merged 1 commit intomainfrom
07-02-refactor_ast_remove_astkind_for_propertykey_
Jul 8, 2025
Merged

refactor(ast): remove AstKind for PropertyKey#12108
graphite-app[bot] merged 1 commit intomainfrom
07-02-refactor_ast_remove_astkind_for_propertykey_

Conversation

@camchenry
Copy link
Member

@camchenry camchenry commented Jul 7, 2025

This removes the PropertyKey AstKind, in support of making the AST kinds more consistent (i.e., only structs should be visited in the AST).

Similar to past PRs, I've added a new PropertyKeyKind to narrow the AstKind enum (related: oxc-project/backlog#166).

Comments on various changes:

  • id_length rule: I had to add new handling for nodes which were previously covered by visting PropertyKey.
  • no_magic_numbers rule: Similar to id_length, we need to be more careful when checking if a value is part of a class property initializer, since we can't fully rely on the parent kind anymore.
  • prefer_dom_node_text_content rule: the ancestry here has changed, fortunately for the better in this case. some of the previous juggling of parent/grandparent has been replaced with a simpler check.
  • prefer_string_raw: the logic for PropertyKey was already fully covered by ObjectProperty, so I've removed it.
  • Semantic binder changes: I added an additional check for binding the SetAccessor scope flags which ensures that we only set it when a function is part of a property definition's value, not its key. This evidenced as a test failure in the no_setter_return lint rule.

@github-actions github-actions bot added A-linter Area - Linter A-semantic Area - Semantic A-ast Area - AST A-ast-tools Area - AST tools A-formatter Area - Formatter C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior labels Jul 7, 2025
Copy link
Member Author

camchenry commented Jul 7, 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.

@camchenry camchenry force-pushed the 07-06-refactor_ast_remove_astkind_for_assignmenttargetpattern_ branch from 994b27c to 4cb2cf1 Compare July 7, 2025 03:46
@camchenry camchenry force-pushed the 07-02-refactor_ast_remove_astkind_for_propertykey_ branch from 5373dd9 to 862878e Compare July 7, 2025 03:47
@codspeed-hq
Copy link

codspeed-hq bot commented Jul 7, 2025

CodSpeed Instrumentation Performance Report

Merging #12108 will improve performances by 5.04%

Comparing 07-02-refactor_ast_remove_astkind_for_propertykey_ (8814c53) with main (228cff5)

Summary

⚡ 2 improvements
✅ 32 untouched benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
linter[RadixUIAdoptionSection.jsx] 2.6 ms 2.5 ms +5.04%
linter[cal.com.tsx] 1.2 s 1.2 s +3.18%

@graphite-app graphite-app bot changed the base branch from 07-06-refactor_ast_remove_astkind_for_assignmenttargetpattern_ to graphite-base/12108 July 7, 2025 19:43
@graphite-app graphite-app bot force-pushed the graphite-base/12108 branch from 4cb2cf1 to e8e2a25 Compare July 7, 2025 19:51
@graphite-app graphite-app bot force-pushed the 07-02-refactor_ast_remove_astkind_for_propertykey_ branch from 862878e to 49327db Compare July 7, 2025 19:51
@graphite-app graphite-app bot changed the base branch from graphite-base/12108 to main July 7, 2025 19:52
@graphite-app graphite-app bot force-pushed the 07-02-refactor_ast_remove_astkind_for_propertykey_ branch from 49327db to d425145 Compare July 7, 2025 19:52
@camchenry camchenry force-pushed the 07-02-refactor_ast_remove_astkind_for_propertykey_ branch from d425145 to 61d04aa Compare July 8, 2025 03:42
@camchenry
Copy link
Member Author

Looks like this makes the linter up to 5% faster for some files, and more like ~1% in other files. Semantic analysis is also ~1% faster as well it seems.

Screenshot 2025-07-07 at 11 53 55 PM

@camchenry camchenry force-pushed the 07-02-refactor_ast_remove_astkind_for_propertykey_ branch from d1bb27f to a6abb49 Compare July 8, 2025 03:56
@camchenry camchenry marked this pull request as ready for review July 8, 2025 03:58
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Jul 8, 2025
Copy link
Contributor

camc314 commented Jul 8, 2025

Merge activity

graphite-app bot pushed a commit that referenced this pull request Jul 8, 2025
- part of #11490

This removes the `PropertyKey` AstKind, in support of making the AST kinds more consistent (i.e., only `struct`s should be visited in the AST).

Similar to past PRs, I've added a new `PropertyKeyKind` to narrow the `AstKind` enum (related: oxc-project/backlog#166).

Comments on various changes:
- `id_length` rule: I had to add new handling for nodes which were previously covered by visting `PropertyKey`.
- `no_magic_numbers` rule: Similar to `id_length`, we need to be more careful when checking if a value is part of a class property initializer, since we can't fully rely on the parent kind anymore.
- `prefer_dom_node_text_content` rule: the ancestry here has changed, fortunately for the better in this case. some of the previous juggling of parent/grandparent has been replaced with a simpler check.
- `prefer_string_raw`: the logic for `PropertyKey` was already fully covered by `ObjectProperty`, so I've removed it.
- Semantic binder changes: I added an additional check for binding the `SetAccessor` scope flags which ensures that we only set it when a function is part of a property definition's value, not its key. This evidenced as a test failure in the `no_setter_return` lint rule.
@graphite-app graphite-app bot force-pushed the 07-02-refactor_ast_remove_astkind_for_propertykey_ branch from a6abb49 to 4a7450a Compare July 8, 2025 10:32
- part of #11490

This removes the `PropertyKey` AstKind, in support of making the AST kinds more consistent (i.e., only `struct`s should be visited in the AST).

Similar to past PRs, I've added a new `PropertyKeyKind` to narrow the `AstKind` enum (related: oxc-project/backlog#166).

Comments on various changes:
- `id_length` rule: I had to add new handling for nodes which were previously covered by visting `PropertyKey`.
- `no_magic_numbers` rule: Similar to `id_length`, we need to be more careful when checking if a value is part of a class property initializer, since we can't fully rely on the parent kind anymore.
- `prefer_dom_node_text_content` rule: the ancestry here has changed, fortunately for the better in this case. some of the previous juggling of parent/grandparent has been replaced with a simpler check.
- `prefer_string_raw`: the logic for `PropertyKey` was already fully covered by `ObjectProperty`, so I've removed it.
- Semantic binder changes: I added an additional check for binding the `SetAccessor` scope flags which ensures that we only set it when a function is part of a property definition's value, not its key. This evidenced as a test failure in the `no_setter_return` lint rule.
@graphite-app graphite-app bot force-pushed the 07-02-refactor_ast_remove_astkind_for_propertykey_ branch from 4a7450a to 8814c53 Compare July 8, 2025 10:36
@graphite-app graphite-app bot merged commit 8814c53 into main Jul 8, 2025
24 checks passed
@graphite-app graphite-app bot deleted the 07-02-refactor_ast_remove_astkind_for_propertykey_ branch July 8, 2025 10:44
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Jul 8, 2025
This was referenced Jul 12, 2025
camc314 added a commit that referenced this pull request Jul 16, 2025
## [1.7.0] - 2025-07-16

### 🚀 Features

- 5e428a4 linter/eslint-plugin-next: No-html-link-for-pages rule
addition (#12194) (Gabriel Díaz Aguilera)
- 9b14fbc ast: Add `ThisExpression` to `TSTypeName` (#12156) (Boshen)
- c551b8f linter: Report diagnostics from custom plugins (#12219)
(camc314)
- d387729 linter: JS custom rules config (#12160) (camc314)
- 152e59d napi/oxlint: Read source text into start of allocator (#12122)
(overlookmotel)
- bde1ef1 linter: Load custom JS plugins (#11980) (camc314)
- d4ebd14 linter: Add `oxlint2`/`disable_oxlint2` feature flags (#12130)
(camc314)
- a4dae73 linter: Introduce `LintPlugins` to store builtin + custom
plugins (#12117) (camc314)

### 🐛 Bug Fixes

- 3f9a1f0 linter/no-unused-private-class-members: Fix false positive
with nullish coalescing assignments (#12317) (camc314)
- 47fad0e linter/no-empty-file: False positive with empty file with
triple slash directive (#12293) (camc314)
- 633ba30 linter: False positive with unknown plugins when unmatched
eslint rule (#12285) (camc314)
- 9720774 linter: Report implicit config parse errors (#12260) (Simon
Buchan)
- 1920c6b language_server: Respect the root `.oxlintrc.json` file for
`ignorePatterns` (#12171) (Sysix)
- 98708eb linter: Fix inconsistent behavior in `no-duplicate-imports`
rule (#12192) (yefan)
- 853d2bc linter, language_server: Correctly identify usage of `import`
plugin (#12157) (overlookmotel)

### 🚜 Refactor

- ee761de ast: Remove `AstKind` for `AssignmentTarget` (#12252) (Tyler
Earls)
- c68b607 ast: Rename `TemplateLiteral::quasi` to
`TemplateLiteral::single_quasi` (#12266) (Dunqing)
- 32c32af ast: Check whether there is a single `quasi` in
`TemplateLiteral::quasi` (#12265) (Dunqing)
- 8f6a1da linter/js-plugins: Use `u32` for IDs (#12243) (overlookmotel)
- 36cd364 linter/js-plugins: Clean up code (#12242) (overlookmotel)
- 8c02ebd linter/js-plugins: Rename `specifiers` to `paths` (#12241)
(overlookmotel)
- 3adaf98 linter: Simplify getting nodes count (#12239) (overlookmotel)
- 6e54645 language_server: Store `LintService` instead of `Linter`
(#12016) (Sysix)
- 113cf8c linter: Move `LintServiceOptions.paths` to
`LintService.with_paths` (#12015) (Sysix)
- acfac68 oxlint: Adjust ignore patterns by counting bytes instead of
chars (#12209) (Sysix)
- 729b82b linter: Rename `plugin_name` to `plugin_specifier` (#12148)
(overlookmotel)
- 532b816 linter: Use `to_string` instead of `into` (#12147)
(overlookmotel)
- 89f2a69 linter: TODO comment (#12146) (overlookmotel)
- f90d3e1 linter: Feature gate `load_external_plugin` by both `oxlint2`
and `disable_oxlint2` features (#12141) (overlookmotel)
- 12e4ec7 linter: Make `tokio` dependency optional (#12140)
(overlookmotel)
- 1d2eaca oxlint2: Introduce `force_test_reporter` feature for
consistent graphical outputs (#12133) (camc314)
- 8814c53 ast: Remove `AstKind` for `PropertyKey` (#12108) (camchenry)
- 228cff5 semantic,linter: Assert that Program is always the first node
(#12123) (Ulrich Stark)
- e8e2a25 ast: Remove `AstKind` for `AssignmentTargetPattern` (#12105)
(camchenry)
- f7c675d linter: Rename `LintPlugins` to `BuiltinLintPlugins` (#12116)
(camc314)
- a9e5ec0 linter: Access plugins through config instead of storing
directly (#12115) (camc314)
- 9736a7f linter: Simplify `unicorn/require-post-message-target-origin`
(#12110) (shulaoda)

### 📚 Documentation

- 2e3db46 linter: Add missing backtick preventing website from building
(#12113) (camc314)

### ⚡ Performance

- d0f8b88 linter/js-plugins: Do not copy `Vec` (#12248) (overlookmotel)
- 4284d19 linter/js-plugins: Use hashmap `Entry` API + remove temp `Vec`
(#12247) (overlookmotel)
- c7889c3 semantic,linter: Simplify implementation and uses of ancestors
iterators (#12164) (Ulrich Stark)
- f99959c linter: Move work out of loop (#12145) (overlookmotel)
- 514d40c linter: Do not create `Resolver` unless required (#12142)
(overlookmotel)
- 7103527 linter/no-constructor-return: Optimize loop (#12138)
(overlookmotel)

### 🧪 Testing

- d1194e8 oxlint: Ignore test on windows (#12262) (camc314)

Co-authored-by: camc314 <18101008+camc314@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ast Area - AST A-ast-tools Area - AST tools A-formatter Area - Formatter A-linter Area - Linter A-semantic Area - Semantic C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants