feat(linter/plugins): correctly transfer script type for tokens#17237
feat(linter/plugins): correctly transfer script type for tokens#17237
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. |
2727034 to
988ad0a
Compare
There was a problem hiding this comment.
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
SourceTypefields in the serialized buffer - Implemented helper functions to detect JSX and TypeScript source types from the buffer
- Updated token parsing to use the correct
ScriptKindbased 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.

cloese ##17185