+
Skip to content

Conversation

arendjr
Copy link
Contributor

@arendjr arendjr commented Oct 2, 2025

Summary

Fixed #7638: useImportExtensions no longer emits diagnostics on valid import paths that end with a query or hash.

Example

// This no longer warns if `index.css` exists:
import style from '../theme/index.css?inline';

Test Plan

Test case added. Existing test cases still pass.

Docs

N/A

Copy link

changeset-bot bot commented Oct 2, 2025

🦋 Changeset detected

Latest commit: 6888c50

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@biomejs/biome Patch
@biomejs/cli-win32-x64 Patch
@biomejs/cli-win32-arm64 Patch
@biomejs/cli-darwin-x64 Patch
@biomejs/cli-darwin-arm64 Patch
@biomejs/cli-linux-x64 Patch
@biomejs/cli-linux-arm64 Patch
@biomejs/cli-linux-x64-musl Patch
@biomejs/cli-linux-arm64-musl Patch
@biomejs/wasm-web Patch
@biomejs/wasm-bundler Patch
@biomejs/wasm-nodejs Patch
@biomejs/backend-jsonrpc Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@arendjr arendjr changed the title fix(linter): useImportExtensions handles queries and hashes fix(linter): useImportExtensions handles queries and hashes Oct 2, 2025
@github-actions github-actions bot added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Oct 2, 2025
Copy link
Contributor

coderabbitai bot commented Oct 2, 2025

Walkthrough

Adds a patch changeset documenting a fix to the useImportExtensions rule: imports ending with a query or hash are no longer flagged. The lint implementation now extracts and strips query/hash suffixes from the last path segment, mutates the detected extension accordingly, and withholds extension suggestions when such a suffix is present. Construction of the result sets module_name_token directly. Test fixtures add a CSS file and a valid import case using ./sub/theme.css?inline to ensure no diagnostics are emitted.

Possibly related PRs

Suggested labels

A-Linter, L-JavaScript

Suggested reviewers

  • siketyan
  • ematipico

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Title Check ✅ Passed The title accurately and concisely summarises the main change by indicating a linter fix for the useImportExtensions rule to correctly handle queries and hashes in import paths.
Linked Issues Check ✅ Passed The changes implement the objectives from issue #7638 by stripping query and hash segments in import paths, preserving existing extension checks and adding tests for imports like "../theme/index.css?inline", satisfying the linked issue requirements.
Out of Scope Changes Check ✅ Passed All modifications are directly related to the useImportExtensions rule, its tests and the corresponding version bump, and there are no unrelated code or documentation changes beyond the scope of issue #7638.
Description Check ✅ Passed The pull request description clearly relates to the changeset by summarising the bug fix for the useImportExtensions lint rule, providing an example and a test plan that match the implemented updates.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d025e53 and 6888c50.

⛔ Files ignored due to path filters (1)
  • crates/biome_js_analyze/tests/specs/correctness/useImportExtensions/valid.js.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (4)
  • .changeset/extended-extensions-excel.md (1 hunks)
  • crates/biome_js_analyze/src/lint/correctness/use_import_extensions.rs (3 hunks)
  • crates/biome_js_analyze/tests/specs/correctness/useImportExtensions/sub/theme.css (1 hunks)
  • crates/biome_js_analyze/tests/specs/correctness/useImportExtensions/valid.js (1 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
crates/biome_*_{syntax,parser,formatter,analyze,factory,semantic}/**

📄 CodeRabbit inference engine (CLAUDE.md)

Maintain the per-language crate structure: biome_{lang}_{syntax,parser,formatter,analyze,factory,semantic}

Files:

  • crates/biome_js_analyze/tests/specs/correctness/useImportExtensions/sub/theme.css
  • crates/biome_js_analyze/tests/specs/correctness/useImportExtensions/valid.js
  • crates/biome_js_analyze/src/lint/correctness/use_import_extensions.rs
crates/biome_*/**

📄 CodeRabbit inference engine (CLAUDE.md)

Place core crates under /crates/biome_*/

Files:

  • crates/biome_js_analyze/tests/specs/correctness/useImportExtensions/sub/theme.css
  • crates/biome_js_analyze/tests/specs/correctness/useImportExtensions/valid.js
  • crates/biome_js_analyze/src/lint/correctness/use_import_extensions.rs
**/tests/**

📄 CodeRabbit inference engine (CLAUDE.md)

Place test files under a tests/ directory in each crate

Files:

  • crates/biome_js_analyze/tests/specs/correctness/useImportExtensions/sub/theme.css
  • crates/biome_js_analyze/tests/specs/correctness/useImportExtensions/valid.js
.changeset/**/*.md

📄 CodeRabbit inference engine (CONTRIBUTING.md)

.changeset/**/*.md: Create changesets using the just new-changeset command; do not author them manually
In changeset markdown, only use headers #### or #####
Changeset descriptions must end every sentence with a full stop (.)
For bug fixes, start the changeset description with a linked issue reference like “Fixed #1234
Prefer past tense for what was done and present tense for current behavior in changesets

Files:

  • .changeset/extended-extensions-excel.md
**/*.{rs,toml}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Before committing, format Rust and TOML files (e.g., via just f/just format)

Files:

  • crates/biome_js_analyze/src/lint/correctness/use_import_extensions.rs
**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Document rules, assists, and options via inline rustdoc in Rust source

Files:

  • crates/biome_js_analyze/src/lint/correctness/use_import_extensions.rs
🧬 Code graph analysis (1)
crates/biome_js_analyze/src/lint/correctness/use_import_extensions.rs (1)
crates/biome_js_syntax/src/import_ext.rs (1)
  • module_name_token (401-435)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (24)
  • GitHub Check: Test Node.js API
  • GitHub Check: Bench (biome_html_parser)
  • GitHub Check: Bench (biome_package)
  • GitHub Check: Bench (biome_graphql_formatter)
  • GitHub Check: Bench (biome_html_formatter)
  • GitHub Check: Bench (biome_configuration)
  • GitHub Check: Bench (biome_module_graph)
  • GitHub Check: Bench (biome_graphql_parser)
  • GitHub Check: Bench (biome_json_analyze)
  • GitHub Check: Bench (biome_css_formatter)
  • GitHub Check: Bench (biome_json_parser)
  • GitHub Check: Bench (biome_js_analyze)
  • GitHub Check: Bench (biome_css_analyze)
  • GitHub Check: Bench (biome_json_formatter)
  • GitHub Check: Bench (biome_js_parser)
  • GitHub Check: Bench (biome_css_parser)
  • GitHub Check: Bench (biome_js_formatter)
  • GitHub Check: Documentation
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Check Dependencies
  • GitHub Check: autofix
🔇 Additional comments (7)
.changeset/extended-extensions-excel.md (1)

1-13: LGTM!

The changeset follows all the guidelines: proper scope, linked issue reference, past tense, full stops, and a clear example demonstrating the fix.

crates/biome_js_analyze/tests/specs/correctness/useImportExtensions/valid.js (1)

22-22: LGTM!

The test case directly validates the fix for issue #7638, ensuring imports with query parameters no longer emit diagnostics when the underlying file extension is present.

crates/biome_js_analyze/tests/specs/correctness/useImportExtensions/sub/theme.css (1)

1-2: LGTM!

The test fixture provides the necessary file for the query parameter test case to resolve against, following the established pattern for test resources.

crates/biome_js_analyze/src/lint/correctness/use_import_extensions.rs (4)

234-234: LGTM!

Making existing_extension mutable enables the in-place stripping of query/hash suffixes, which is necessary for the fix.


247-250: LGTM!

The extraction logic correctly identifies query or hash suffixes using find(['?', '#']) on the last path component.


252-258: LGTM!

The stripping logic correctly removes query/hash suffixes from the extension in place, with an appropriate fallback if strip_suffix fails.


317-320: LGTM!

The result construction correctly suppresses the fix suggestion when a query/hash is present. Combined with the earlier stripping logic, this ensures no diagnostics are emitted for valid extensions with query/hash suffixes, as the comparison at line 267 will now match after stripping.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

codspeed-hq bot commented Oct 2, 2025

CodSpeed Performance Report

Merging #7640 will not alter performance

Comparing arendjr:extended-extensions-excel (6888c50) with main (41df59b)1

Summary

✅ 133 untouched

Footnotes

  1. No successful run was found on main (d025e53) during the generation of this report, so 41df59b was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

🙌

@ematipico ematipico merged commit 899f7b2 into biomejs:main Oct 2, 2025
31 checks passed
@github-actions github-actions bot mentioned this pull request Oct 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Linter Area: linter L-JavaScript Language: JavaScript and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

💅 useImportExtensions doesn't handle ?inline query

2 participants

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载