Skip to content

refactor(ast): get jsx types out of AstKind exceptions#11535

Merged
camc314 merged 4 commits intooxc-project:mainfrom
ulrichstark:refactor-out-ast-kind-exceptions-of-jsx-types
Jun 10, 2025
Merged

refactor(ast): get jsx types out of AstKind exceptions#11535
camc314 merged 4 commits intooxc-project:mainfrom
ulrichstark:refactor-out-ast-kind-exceptions-of-jsx-types

Conversation

@ulrichstark
Copy link
Copy Markdown
Contributor

This is my (not so confident) attempt to do #11490 for all jsx types.

  1. removed all jsx types from STRUCTS_BLACK_LIST and ENUMS_WHITE_LIST
  2. regenerated ast code
  3. added missing arms to AstKind::debug_name
  4. removed now broken is_jsx function, because it was unused
  5. fixed all compile errors
  6. fixed all test errors
  7. regenerated snapshots (different node ids and decreased prettier conformance)

All tests are green 🥳🎉

@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 labels Jun 6, 2025
@ulrichstark ulrichstark changed the title Refactor out ast kind exceptions of jsx types refactor(ast): get jsx types out of AstKind exceptions Jun 6, 2025
@github-actions github-actions bot added the C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior label Jun 6, 2025
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Jun 6, 2025

CodSpeed Instrumentation Performance Report

Merging #11535 will improve performances by 7.88%

Comparing ulrichstark:refactor-out-ast-kind-exceptions-of-jsx-types (91f0079) with main (896bdd9)

Summary

⚡ 1 improvements
✅ 37 untouched benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
linter[RadixUIAdoptionSection.jsx] 2.8 ms 2.6 ms +7.88%

@ulrichstark
Copy link
Copy Markdown
Contributor Author

Less code and even some nice performance improvements 😎
image

@overlookmotel
Copy link
Copy Markdown
Member

linter[RadixUIAdoptionSection.jsx] 2.8 ms 2.6 ms +7.92%
semantic[RadixUIAdoptionSection.jsx] 72.4 µs 69.8 µs +3.64%

Banger!

Thanks so much for getting on this. It's a large PR, so will take me a while to get through reviewing it. But, on the face of it, looks great.

@overlookmotel
Copy link
Copy Markdown
Member

overlookmotel commented Jun 6, 2025

Actually, it wasn't so long. I've reviewed. From what I can see, looks good. But I'm not the best person to review the linter changes as I'm not so familiar with the linter.

  1. @camc314 Could you possibly take a look at the linter changes (and not just the ones I've commented on)? As we're planning to drop Oxlint 1.0 next week, and make a big song and dance about it, it would be a really unfortunate moment to break things!

  2. The reduced conformance pass rate in formatter suggests something may be wrong there. I know literally nothing about the formatter. @Dunqing Can you advise what we should do about that?

Note: The perf boost in Semantic I'm guessing is due to producing less AstNodes (the snapshot changes with lower NodeIds suggests that). I guess the boost in linter is just due to simpler code (less branches and lookups), but I'm amazed it has such a large effect. Bravo!

@ulrichstark Just to flag please don't get your hopes up that every further step we take on adding/removing AstKinds will get a similar perf boost. In some cases it'll probably result in more AstNodes, in others less. So perf may go up or down. But this is certainly a very pleasant first step down the road!

@overlookmotel
Copy link
Copy Markdown
Member

overlookmotel commented Jun 6, 2025

Not sure what's going on with the "Check links" CI fail. I've re-run it twice and it keeps failing on https://babeljs.io/docs/babel-plugin-transform-typescript, which seems to be a valid link.

Copy link
Copy Markdown
Contributor

@camc314 camc314 left a comment

Choose a reason for hiding this comment

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

linter changes look good excluding those two @overlookmotel caught

@Dunqing
Copy link
Copy Markdown
Member

Dunqing commented Jun 7, 2025

There's no need to worry about the Formatter; I've created #11511 to revamp the Formatter core. I will revisit all AstKind use cases in Formatter after that work is done.

@Boshen
Copy link
Copy Markdown
Member

Boshen commented Jun 7, 2025

@camc314 merge after oxlint 1.0

@Boshen Boshen marked this pull request as draft June 7, 2025 03:58
@ulrichstark
Copy link
Copy Markdown
Contributor Author

Just did a commit to shorten the call to get the parent node kind. The other feedback around the two instances of is_within_jsx_attribute seems to be resolved? Is more work required from my side or are we good and wait for the oxlint 1.0 release?

@camc314
Copy link
Copy Markdown
Contributor

camc314 commented Jun 7, 2025

Is more work required from my side or are we good and wait for the oxlint 1.0 release?

nope, i don't think so. I've checked both changes and they look fine. thanks for your work on this!

@camc314 camc314 marked this pull request as ready for review June 10, 2025 13:27
@camc314 camc314 force-pushed the refactor-out-ast-kind-exceptions-of-jsx-types branch from 6c5c773 to 91f0079 Compare June 10, 2025 13:27
@camc314 camc314 merged commit d41fb13 into oxc-project:main Jun 10, 2025
24 checks passed
@ulrichstark ulrichstark deleted the refactor-out-ast-kind-exceptions-of-jsx-types branch June 10, 2025 14:37
@overlookmotel
Copy link
Copy Markdown
Member

Nice work @ulrichstark!

This was referenced Jun 12, 2025
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.

5 participants