Skip to content

fix(span)!: SourceType::from_path(".js") return js instead of jsx#11038

Merged
Boshen merged 1 commit intomainfrom
05-14-fix_span_sourcetype_from_path_.js_return_js_instead_of_jsx
May 15, 2025
Merged

fix(span)!: SourceType::from_path(".js") return js instead of jsx#11038
Boshen merged 1 commit intomainfrom
05-14-fix_span_sourcetype_from_path_.js_return_js_instead_of_jsx

Conversation

@Boshen
Copy link
Member

@Boshen Boshen commented May 14, 2025

closes #11020

Previously SourceType::from_path(".js") treats a .js file as .jsx
to maximize parse rate for the linter.

Force the .jsx change in the linter instead of a generic solution for SourceType::from_path.

Copilot AI review requested due to automatic review settings May 14, 2025 15:06
@Boshen Boshen requested a review from camc314 as a code owner May 14, 2025 15:06
Copy link
Member Author

Boshen commented May 14, 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.

@github-actions github-actions bot added A-linter Area - Linter A-cli Area - CLI C-bug Category - Bug labels May 14, 2025
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 updates how SourceType::from_path classifies .js files as standard JavaScript rather than JSX, and moves the forced JSX promotion into the linter’s runtime. It also refreshes related tests and snapshots and adds a new fixture/test for JS treated as JSX.

  • Refactor SourceType mapping to treat only .jsx/.tsx as JSX and all others (including .js) as standard.
  • In the linter runtime, force .js files to parse as JSX via with_jsx(true).
  • Update tests, snapshots, and add a new js_and_jsx test and fixture.

Reviewed Changes

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

Show a summary per file
File Description
crates/oxc_span/src/source_type.rs Adjusted extension-to-variant mapping in From<FileExtension>
crates/oxc_span/src/source_type.rs (tests) Updated assertions for js, mjs, cjs to is_javascript
crates/oxc_linter/src/service/runtime.rs Added logic to force .js parsing as JSX; contains a typo in comment
apps/oxlint/src/snapshots/_fixtures__linter@*.snap Updated snapshot counts and added new JS/JSX fixture output
apps/oxlint/src/snapshots/[email protected] New snapshot for the js_and_jsx test
apps/oxlint/src/lint.rs Added js_and_jsx test, but path mismatches the fixture name
apps/oxlint/fixtures/linter/js_as_jsx.js New fixture (name mismatch with test)

@codspeed-hq
Copy link

codspeed-hq bot commented May 14, 2025

CodSpeed Instrumentation Performance Report

Merging #11038 will not alter performance

Comparing 05-14-fix_span_sourcetype_from_path_.js_return_js_instead_of_jsx (00dcece) with main (7ad6cf8)

Summary

✅ 36 untouched benchmarks

@Boshen Boshen force-pushed the 05-14-fix_span_sourcetype_from_path_.js_return_js_instead_of_jsx branch from cb81e31 to 8c47057 Compare May 14, 2025 15:24
@github-actions github-actions bot added the A-transformer Area - Transformer / Transpiler label May 14, 2025
@graphite-app
Copy link
Contributor

graphite-app bot commented May 14, 2025

Merge activity

  • May 14, 11:26 AM EDT: Graphite disabled "merge when ready" on this PR due to: a merge conflict with the target branch; resolve the conflict and try again..
  • May 14, 11:27 AM EDT: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • May 14, 11:27 AM EDT: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • May 14, 11:29 AM EDT: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.

@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label May 14, 2025
@Dunqing
Copy link
Member

Dunqing commented May 14, 2025

image

Nice! Just curious why it affects *.tsx benchmark

@Boshen Boshen force-pushed the 05-14-fix_span_sourcetype_from_path_.js_return_js_instead_of_jsx branch from 8c47057 to 6018f5c Compare May 15, 2025 08:28
Previously `SourceType::from_path(".js")` treats a `.js` file as `.jsx`
to maximize parse rate for the linter.

Force the `.jsx` change in the linter instead of a generic solution for `SourceType::from_path`.
@Boshen Boshen force-pushed the 05-14-fix_span_sourcetype_from_path_.js_return_js_instead_of_jsx branch from 6018f5c to 00dcece Compare May 15, 2025 08:41
@github-actions github-actions bot added the A-formatter Area - Formatter label May 15, 2025
@Boshen Boshen merged commit 4e5c73b into main May 15, 2025
26 checks passed
@Boshen Boshen deleted the 05-14-fix_span_sourcetype_from_path_.js_return_js_instead_of_jsx branch May 15, 2025 08:58
This was referenced May 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

0-merge Merge with Graphite Merge Queue A-cli Area - CLI A-formatter Area - Formatter A-linter Area - Linter A-transformer Area - Transformer / Transpiler C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

transformer: non-JSX file doesn't need to update options from comments

4 participants