feat(js/useImportExtensions): add extensionMappings option#7762
Conversation
🦋 Changeset detectedLatest commit: 44c1024 The changes in this PR will be included in the next version bump. This PR includes changesets to release 14 packages
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 |
CodSpeed Performance ReportMerging #7762 will not alter performanceComparing Summary
Footnotes
|
4ff68cd to
47d3b66
Compare
WalkthroughAdds an Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (5)
📒 Files selected for processing (7)
🚧 Files skipped from review as they are similar to previous changes (5)
⏰ 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). (10)
🔇 Additional comments (3)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
.changeset/six-plants-lie.md (1)
1-17: LGTM!The changelog clearly documents the new feature with a helpful example. The trailing comma on line 13 is valid JSON but you might consider removing it to avoid confusion.
crates/biome_js_analyze/src/lint/correctness/use_import_extensions.rs (1)
285-289: Consider documenting option precedence.The implementation correctly applies extension mappings. However, when both
forceJsExtensionsandextensionMappingsare configured,forceJsExtensionstakes precedence (line 283). Consider documenting this interaction in the rule documentation to avoid confusion.For example, you could add a note in the
extensionMappingssection:/// map TypeScript imports to JavaScript extensions. /// +/// Note: If `forceJsExtensions` is set to `true`, it takes precedence over +/// `extensionMappings`. +/// /// This is useful if you are bundling your code to JavaScript into a package
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (5)
crates/biome_js_analyze/tests/specs/correctness/useImportExtensions/bar.ts.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/correctness/useImportExtensions/foo.ts.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/correctness/useImportExtensions/invalidWithExtensionMappings.ts.snapis excluded by!**/*.snapand included by**packages/@biomejs/backend-jsonrpc/src/workspace.tsis excluded by!**/backend-jsonrpc/src/workspace.tsand included by**packages/@biomejs/biome/configuration_schema.jsonis excluded by!**/configuration_schema.jsonand included by**
📒 Files selected for processing (7)
.changeset/six-plants-lie.md(1 hunks)crates/biome_js_analyze/src/lint/correctness/use_import_extensions.rs(2 hunks)crates/biome_js_analyze/tests/specs/correctness/useImportExtensions/bar.ts(1 hunks)crates/biome_js_analyze/tests/specs/correctness/useImportExtensions/foo.ts(1 hunks)crates/biome_js_analyze/tests/specs/correctness/useImportExtensions/invalidWithExtensionMappings.options.json(1 hunks)crates/biome_js_analyze/tests/specs/correctness/useImportExtensions/invalidWithExtensionMappings.ts(1 hunks)crates/biome_rule_options/src/use_import_extensions.rs(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-05T14:43:29.581Z
Learnt from: dyc3
Repo: biomejs/biome PR: 7081
File: packages/@biomejs/biome/configuration_schema.json:7765-7781
Timestamp: 2025-08-05T14:43:29.581Z
Learning: The file `packages/biomejs/biome/configuration_schema.json` is auto-generated and should not be manually edited or reviewed for schema issues; any changes should be made at the code generation source.
Applied to files:
crates/biome_js_analyze/tests/specs/correctness/useImportExtensions/invalidWithExtensionMappings.options.json
🔇 Additional comments (7)
crates/biome_rule_options/src/use_import_extensions.rs (2)
2-2: LGTM!The FxHashMap import and serde attribute cleanup are appropriate.
Also applies to: 10-10
13-16: LGTM!The new field is well-documented and properly configured.
crates/biome_js_analyze/tests/specs/correctness/useImportExtensions/invalidWithExtensionMappings.ts (1)
1-2: LGTM!The test cases appropriately exercise both scenarios: missing extension and incorrect extension with the mapping active.
crates/biome_js_analyze/tests/specs/correctness/useImportExtensions/foo.ts (1)
1-1: LGTM!Simple test fixture, looks good.
crates/biome_js_analyze/tests/specs/correctness/useImportExtensions/bar.ts (1)
1-1: LGTM!Simple test fixture, looks good.
crates/biome_js_analyze/tests/specs/correctness/useImportExtensions/invalidWithExtensionMappings.options.json (1)
1-18: LGTM!The test configuration correctly sets up the extension mapping for testing.
crates/biome_js_analyze/src/lint/correctness/use_import_extensions.rs (1)
80-101: LGTM!The documentation for the new option is clear and helpful.
a2fae21 to
44c1024
Compare
Summary
Adds a new option to
useImportExtensionsto be a more precisely configurable version offorcejsextensions.Open to suggestions for a better name for the option, I don't really like it but couldn't come up with anything else.
fixes #7734
Test Plan
added tests
Docs
updated the rule docs