Skip to content

feat(linter/plugins): correctly transfer script type for tokens#17237

Closed
camc314 wants to merge 1 commit intomainfrom
c/12-21-feat_oxlint_plugins_detect_source_type_for_correct_typescript_scriptkind
Closed

feat(linter/plugins): correctly transfer script type for tokens#17237
camc314 wants to merge 1 commit intomainfrom
c/12-21-feat_oxlint_plugins_detect_source_type_for_correct_typescript_scriptkind

Conversation

@camc314
Copy link
Contributor

@camc314 camc314 commented Dec 21, 2025

cloese ##17185

@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-enhancement Category - New feature or request labels Dec 21, 2025
Copy link
Contributor Author

camc314 commented Dec 21, 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.

@camc314 camc314 changed the title feat(oxlint/plugins): detect source type for correct TypeScript ScriptKind feat(linter/plugins): correctly transfer script type for tokens Dec 21, 2025
@camc314 camc314 force-pushed the c/12-21-feat_oxlint_plugins_detect_source_type_for_correct_typescript_scriptkind branch from 2727034 to 988ad0a Compare December 21, 2025 22:43
@camc314 camc314 assigned camc314 and overlookmotel and unassigned camc314 Dec 21, 2025
@camc314 camc314 marked this pull request as ready for review December 21, 2025 22:44
Copilot AI review requested due to automatic review settings December 21, 2025 22:44
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 implements correct script type transfer for tokens by reading SourceType information from the serialized buffer. Previously, the TypeScript parser was always initialized with ScriptKind.TSX, which caused incorrect parsing for non-JSX TypeScript files. The PR adds support for reading the language and variant fields from the SourceType struct in the buffer and uses them to determine the appropriate ScriptKind when parsing tokens.

Key changes:

  • Added offset constants for accessing SourceType fields in the serialized buffer
  • Implemented helper functions to detect JSX and TypeScript source types from the buffer
  • Updated token parsing to use the correct ScriptKind based on the actual source type

Reviewed changes

Copilot reviewed 5 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tasks/ast_tools/src/generators/raw_transfer.rs Added constants for SourceType field offsets and logic to calculate them from the schema
napi/parser/src-js/generated/constants.js Generated JavaScript constants file with SourceType offset values
apps/oxlint/src-js/generated/constants.ts Generated TypeScript constants file with SourceType offset values
apps/oxlint/src-js/plugins/source_code.ts Added isJsxSource() and isTypescriptSource() helper functions to read source type from buffer
apps/oxlint/src-js/plugins/tokens_parse.ts Updated token parsing to determine correct ScriptKind based on actual source type
apps/oxlint/test/fixtures/tokens/files/generic_arrow.ts Added new TypeScript test fixture with generic arrow function
apps/oxlint/test/fixtures/tokens/output.snap.md Updated snapshot with expected token output for the new TypeScript test file

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

@camc314 camc314 closed this Dec 22, 2025
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-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants