Skip to content

refactor(linter/plugins, parser/napi): generate type IDs maps as variants#17174

Merged
graphite-app[bot] merged 1 commit intomainfrom
om/12-19-refactor_linter_plugins_parser_napi_generate_type_ids_maps_as_variants
Dec 20, 2025
Merged

refactor(linter/plugins, parser/napi): generate type IDs maps as variants#17174
graphite-app[bot] merged 1 commit intomainfrom
om/12-19-refactor_linter_plugins_parser_napi_generate_type_ids_maps_as_variants

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Dec 20, 2025

Pure refactor. Generate the JS files containing NODE_TYPE_IDS_MAP as variants of a single source code file, instead of constructing to two different versions for parser and linter manually.

This makes changes in further PRs to come easier to implement.

@github-actions github-actions bot added A-linter Area - Linter A-parser Area - Parser A-cli Area - CLI A-ast-tools Area - AST tools A-linter-plugins Area - Linter JS plugins C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior labels Dec 20, 2025
Copy link
Member Author

overlookmotel commented Dec 20, 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.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the code generation for NODE_TYPE_IDS_MAP to use a single source template with variants, rather than manually constructing separate versions for parser and linter. The refactoring uses the existing generate_variants! macro with conditional compilation comments to create two output variants that differ only in whether they include the FUNCTION_NODE_TYPE_IDS export.

  • Unified the source template for type ID maps with conditional /* IF LINTER */ blocks
  • Applied the variant generator pattern (already used for walker code) to type ID map generation
  • Moved function_node_ids.sort_unstable() earlier to ensure sorting before template interpolation

Reviewed changes

Copilot reviewed 1 out of 3 changed files in this pull request and generated no comments.

File Description
tasks/ast_tools/src/generators/estree_visit.rs Modified generator to use variant system with conditional LINTER flag instead of manually creating two versions; moved sorting of function_node_ids earlier
napi/parser/src-js/generated/visit/type_ids.js Generated parser variant without FUNCTION_NODE_TYPE_IDS export; minor formatting changes (removed inline comments)
apps/oxlint/src-js/generated/type_ids.ts Generated oxlint variant with FUNCTION_NODE_TYPE_IDS export; minor formatting changes (removed inline comments)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@overlookmotel overlookmotel force-pushed the om/12-19-refactor_linter_plugins_parser_napi_generate_type_ids_maps_as_variants branch from 382828e to 9839836 Compare December 20, 2025 13:16
@overlookmotel overlookmotel force-pushed the om/12-20-fix_ast_tools_fix_formatting_of_variants branch from daabe4a to 101b8a6 Compare December 20, 2025 13:16
@graphite-app graphite-app bot added the 0-merge Merge with Graphite Merge Queue label Dec 20, 2025
@graphite-app
Copy link
Contributor

graphite-app bot commented Dec 20, 2025

Merge activity

…ants (#17174)

Pure refactor. Generate the JS files containing `NODE_TYPE_IDS_MAP` as variants of a single source code file, instead of constructing to two different versions for parser and linter manually.

This makes changes in further PRs to come easier to implement.
@graphite-app graphite-app bot force-pushed the om/12-20-fix_ast_tools_fix_formatting_of_variants branch from 101b8a6 to bc8ab2e Compare December 20, 2025 14:00
@graphite-app graphite-app bot force-pushed the om/12-19-refactor_linter_plugins_parser_napi_generate_type_ids_maps_as_variants branch from 9839836 to 24a8d9e Compare December 20, 2025 14:01
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Dec 20, 2025
Base automatically changed from om/12-20-fix_ast_tools_fix_formatting_of_variants to main December 20, 2025 14:08
@graphite-app graphite-app bot merged commit 24a8d9e into main Dec 20, 2025
19 checks passed
@graphite-app graphite-app bot deleted the om/12-19-refactor_linter_plugins_parser_napi_generate_type_ids_maps_as_variants branch December 20, 2025 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ast-tools Area - AST tools A-cli Area - CLI A-linter Area - Linter A-linter-plugins Area - Linter JS plugins A-parser Area - Parser 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