Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@haydenbleasel
Copy link

@haydenbleasel haydenbleasel commented Nov 6, 2025

Introduces an 'allowlist' option to the noNamespaceImport lint rule, allowing specific modules to use namespace imports without triggering diagnostics. Updates rule logic, options struct, and adds tests for valid and invalid cases with allowlist configuration.

I am not a Rust developer so this is purely Claude. Reviewed it, hope it's okay.

Summary

As requested by some Ultracite users (example), some libraries heavily encourage the use of the namespace import.

Zod for example is 73% smaller when imported this way.

I'd like to enforce this rule but for a small selection, hence the allowlist.

Test Plan

Claude created test files to verify the new functionality:

  • validWithAllowlist.js + validWithAllowlist.options.json - Tests that modules in the allowlist don't trigger
    diagnostics
  • invalidWithAllowlist.js + invalidWithAllowlist.options.json - Tests that modules NOT in the allowlist still trigger
    diagnostics

Docs

N/A

Introduces an 'allowlist' option to the noNamespaceImport lint rule, allowing specific modules to use namespace imports without triggering diagnostics. Updates rule logic, options struct, and adds tests for valid and invalid cases with allowlist configuration.
@changeset-bot
Copy link

changeset-bot bot commented Nov 6, 2025

🦋 Changeset detected

Latest commit: b4b97f8

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

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

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

@github-actions github-actions bot added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Nov 6, 2025
@haydenbleasel haydenbleasel changed the title Add allowlist option to noNamespaceImport rule feat(no_namespace_import): add allowlist option Nov 6, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 6, 2025

Walkthrough

Adds an allowedModules option to the performance/noNamespaceImport lint and exposes module source kinds via AnyJsModuleSource. The lint now skips diagnostics for imports whose specifier matches an entry in allowedModules. NoNamespaceImportOptions was extended with a public allowed_modules: Vec<String> field (skipped when empty). New tests and per-test option files cover allowed and disallowed external and local modules. A changeset documents the new option. No public function signatures were otherwise changed.

Suggested labels

A-Project, A-Diagnostic

Suggested reviewers

  • dyc3
  • 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 (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarises the main change: adding an allowlist option to the noNamespaceImport rule.
Description check ✅ Passed The description is directly related to the changeset, explaining the allowlist feature, its rationale, and the test coverage added.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
crates/biome_js_analyze/tests/specs/performance/noNamespaceImport/invalidWithAllowlist.js (1)

1-3: Clarify the test comment.

The comment only mentions "other-lib" but doesn't explain that line 2 (zod) should NOT trigger a diagnostic because it's in the allowlist. Consider updating for clarity:

-/* should generate diagnostic because "other-lib" is not in the allowlist */
+/* should generate diagnostic for "other-lib" (not in allowlist) but not for "zod" (in allowlist) */
📜 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 5c55347 and 9c9a8ca.

⛔ Files ignored due to path filters (2)
  • crates/biome_js_analyze/tests/specs/performance/noNamespaceImport/invalidWithAllowlist.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/performance/noNamespaceImport/validWithAllowlist.js.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (6)
  • crates/biome_js_analyze/src/lint/performance/no_namespace_import.rs (3 hunks)
  • crates/biome_js_analyze/tests/specs/performance/noNamespaceImport/invalidWithAllowlist.js (1 hunks)
  • crates/biome_js_analyze/tests/specs/performance/noNamespaceImport/invalidWithAllowlist.options.json (1 hunks)
  • crates/biome_js_analyze/tests/specs/performance/noNamespaceImport/validWithAllowlist.js (1 hunks)
  • crates/biome_js_analyze/tests/specs/performance/noNamespaceImport/validWithAllowlist.options.json (1 hunks)
  • crates/biome_rule_options/src/no_namespace_import.rs (1 hunks)
🧰 Additional context used
🧠 Learnings (14)
📚 Learning: 2025-10-15T09:22:15.851Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:15.851Z
Learning: Applies to crates/biome_formatter/tests/specs/**/options.json : Use options.json files colocated with test inputs to override formatting options for all files in that folder

Applied to files:

  • crates/biome_js_analyze/tests/specs/performance/noNamespaceImport/invalidWithAllowlist.options.json
  • crates/biome_js_analyze/tests/specs/performance/noNamespaceImport/validWithAllowlist.options.json
📚 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/performance/noNamespaceImport/invalidWithAllowlist.options.json
  • crates/biome_js_analyze/tests/specs/performance/noNamespaceImport/validWithAllowlist.options.json
📚 Learning: 2025-09-25T12:32:59.003Z
Learnt from: arendjr
Repo: biomejs/biome PR: 7593
File: crates/biome_service/src/workspace/server.rs:1306-1306
Timestamp: 2025-09-25T12:32:59.003Z
Learning: In the biomejs/biome project, do not flag compilation errors during code review as they are handled by the existing test infrastructure and CI. Focus on other code quality aspects instead.

Applied to files:

  • crates/biome_js_analyze/tests/specs/performance/noNamespaceImport/invalidWithAllowlist.options.json
  • crates/biome_js_analyze/tests/specs/performance/noNamespaceImport/validWithAllowlist.options.json
📚 Learning: 2025-10-15T09:22:46.002Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:46.002Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : Import and use the `FormatNode` trait for AST nodes

Applied to files:

  • crates/biome_js_analyze/src/lint/performance/no_namespace_import.rs
📚 Learning: 2025-10-15T09:22:46.002Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:46.002Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : Do not attempt to fix code; if a mandatory token/node is missing, return `None` instead

Applied to files:

  • crates/biome_js_analyze/src/lint/performance/no_namespace_import.rs
📚 Learning: 2025-10-15T09:23:33.055Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:23:33.055Z
Learning: Applies to crates/biome_js_type_info/biome_module_graph/src/js_module_info/scoped_resolver.rs : Full inference must resolve TypeReference::Import across modules to TypeReference::Resolved when the target is available in the module graph.

Applied to files:

  • crates/biome_js_analyze/src/lint/performance/no_namespace_import.rs
📚 Learning: 2025-10-15T09:22:46.002Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:46.002Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : Implement the `Format` trait for your node type and use `JsFormatter` with `write!`/`format_args!` to define formatting

Applied to files:

  • crates/biome_js_analyze/src/lint/performance/no_namespace_import.rs
📚 Learning: 2025-10-15T09:23:33.055Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:23:33.055Z
Learning: Applies to crates/biome_js_type_info/biome_module_graph/src/js_module_info/collector.rs : Thin (module-level) inference should resolve local and global bindings to TypeReference::Resolved, mark imported bindings as TypeReference::Import, and fall back to TypeReference::Unknown if unresolved.

Applied to files:

  • crates/biome_js_analyze/src/lint/performance/no_namespace_import.rs
📚 Learning: 2025-10-15T09:23:33.055Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:23:33.055Z
Learning: Applies to crates/biome_js_type_info/biome_module_graph/src/**/*.rs : Do not copy or clone data between module graph entries (including behind Arc). Each module must avoid holding duplicated data from another module to enable simple invalidation.

Applied to files:

  • crates/biome_js_analyze/src/lint/performance/no_namespace_import.rs
📚 Learning: 2025-10-15T09:22:46.002Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:46.002Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : Use `dbg_write!` to debug and inspect the emitted IR during formatting

Applied to files:

  • crates/biome_js_analyze/src/lint/performance/no_namespace_import.rs
📚 Learning: 2025-10-15T09:22:46.002Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:46.002Z
Learning: Applies to crates/biome_js_formatter/**/Cargo.toml : Declare the dependency `biome_js_formatter = { version = "0.0.1", path = "../biome_js_formatter" }` for internal installation

Applied to files:

  • crates/biome_js_analyze/src/lint/performance/no_namespace_import.rs
📚 Learning: 2025-10-15T09:22:46.002Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:46.002Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : When a token is mandatory and present in the AST, use the AST-provided token (e.g., `node.l_paren_token().format()`) instead of emitting a static token

Applied to files:

  • crates/biome_js_analyze/src/lint/performance/no_namespace_import.rs
📚 Learning: 2025-10-15T09:22:15.851Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:15.851Z
Learning: Applies to crates/biome_formatter/src/**/*.rs : After generation, remove usages of `format_verbatim_node` and implement real formatting with biome_formatter utilities

Applied to files:

  • crates/biome_js_analyze/src/lint/performance/no_namespace_import.rs
📚 Learning: 2025-10-15T09:23:33.055Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:23:33.055Z
Learning: Applies to crates/biome_js_type_info/src/{type_info,local_inference,resolver,flattening}.rs : Avoid recursive type structures and cross-module Arcs; represent links between types using TypeReference and TypeData::Reference.

Applied to files:

  • crates/biome_rule_options/src/no_namespace_import.rs
🧬 Code graph analysis (2)
crates/biome_js_analyze/src/lint/performance/no_namespace_import.rs (1)
crates/biome_js_factory/src/generated/node_factory.rs (1)
  • js_module_source (2553-2558)
crates/biome_rule_options/src/no_namespace_import.rs (1)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
  • NoNamespaceImportOptions (8415-8415)
🔇 Additional comments (8)
crates/biome_rule_options/src/no_namespace_import.rs (2)

1-10: LGTM! Struct definition looks solid.

The allowlist field and serde configuration are appropriate for this use case.


12-18: Merge implementation is correct.

Standard last-write-wins semantics—when other.allowlist is Some, it overwrites self.allowlist. This is appropriate for configuration merging.

crates/biome_js_analyze/tests/specs/performance/noNamespaceImport/validWithAllowlist.options.json (1)

1-15: Test configuration looks correct.

crates/biome_js_analyze/src/lint/performance/no_namespace_import.rs (3)

33-50: Documentation is clear and helpful.

Good examples showing practical usage of the allowlist feature.


6-6: Import is correct.

AnyJsModuleSource is needed to extract the module name from the import source.


75-91: Allowlist checking logic is sound.

The iterator chain correctly unwraps Option<Box<[Box<str>]>> → slice → individual items. Error handling is conservative: if the module name can't be extracted, the diagnostic is still emitted, which is the safe default.

crates/biome_js_analyze/tests/specs/performance/noNamespaceImport/validWithAllowlist.js (1)

1-3: Test case is clear and correct.

The imports align with the allowlist configuration, properly testing that allowlisted modules don't trigger diagnostics.

crates/biome_js_analyze/tests/specs/performance/noNamespaceImport/invalidWithAllowlist.options.json (1)

1-15: Configuration looks good.

The test configuration correctly sets up the allowlist for the invalidWithAllowlist test case. Modules listed in the allowlist (in this case, "zod") will be exempt from the rule, allowing the test to verify that non-allowlisted modules still trigger diagnostics as expected.

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.

Thank you! I believe the addition of an option is sound. I left some comments that must be addressed

@codspeed-hq
Copy link

codspeed-hq bot commented Nov 6, 2025

CodSpeed Performance Report

Merging #8010 will not alter performance

Comparing haydenbleasel:configurable-no-namespace-import (b4b97f8) with next (e90b14f)

Summary

✅ 53 untouched
⏩ 85 skipped1

Footnotes

  1. 85 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@haydenbleasel
Copy link
Author

@ematipico i believe i've resolved everything, lmk if i missed something.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 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 7b55e82 and 74ef33a.

📒 Files selected for processing (5)
  • .changeset/thirty-goats-rescue.md (1 hunks)
  • crates/biome_js_analyze/src/lint/performance/no_namespace_import.rs (3 hunks)
  • crates/biome_js_analyze/tests/specs/performance/noNamespaceImport/invalidWithAllowlist.options.json (1 hunks)
  • crates/biome_js_analyze/tests/specs/performance/noNamespaceImport/validWithAllowlist.options.json (1 hunks)
  • crates/biome_rule_options/src/no_namespace_import.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • crates/biome_js_analyze/tests/specs/performance/noNamespaceImport/validWithAllowlist.options.json
  • crates/biome_js_analyze/src/lint/performance/no_namespace_import.rs
  • crates/biome_js_analyze/tests/specs/performance/noNamespaceImport/invalidWithAllowlist.options.json
  • .changeset/thirty-goats-rescue.md
🧰 Additional context used
🧠 Learnings (5)
📚 Learning: 2025-10-15T09:23:33.055Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:23:33.055Z
Learning: Applies to crates/biome_js_type_info/biome_module_graph/src/**/*.rs : Do not copy or clone data between module graph entries (including behind Arc). Each module must avoid holding duplicated data from another module to enable simple invalidation.

Applied to files:

  • crates/biome_rule_options/src/no_namespace_import.rs
📚 Learning: 2025-10-15T09:23:33.055Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:23:33.055Z
Learning: Applies to crates/biome_js_type_info/src/{type_info,local_inference,resolver,flattening}.rs : Avoid recursive type structures and cross-module Arcs; represent links between types using TypeReference and TypeData::Reference.

Applied to files:

  • crates/biome_rule_options/src/no_namespace_import.rs
📚 Learning: 2025-10-15T09:22:15.851Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:15.851Z
Learning: Applies to crates/biome_formatter/src/**/*.rs : After generation, remove usages of `format_verbatim_node` and implement real formatting with biome_formatter utilities

Applied to files:

  • crates/biome_rule_options/src/no_namespace_import.rs
📚 Learning: 2025-10-15T09:23:33.055Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:23:33.055Z
Learning: Applies to crates/biome_js_type_info/biome_module_graph/src/js_module_info/scoped_resolver.rs : Full inference must resolve TypeReference::Import across modules to TypeReference::Resolved when the target is available in the module graph.

Applied to files:

  • crates/biome_rule_options/src/no_namespace_import.rs
📚 Learning: 2025-10-15T09:24:31.042Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:24:31.042Z
Learning: Applies to crates/biome_parser/crates/biome_*_{syntax,factory}/** : Create per-language crates biome_<lang>_syntax and biome_<lang>_factory under crates/

Applied to files:

  • crates/biome_rule_options/src/no_namespace_import.rs
🧬 Code graph analysis (1)
crates/biome_rule_options/src/no_namespace_import.rs (1)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
  • NoNamespaceImportOptions (8415-8415)
🔇 Additional comments (2)
crates/biome_rule_options/src/no_namespace_import.rs (2)

1-3: Manual Merge implementation looks correct.

Removing Merge from the derive list and imports is the right approach when implementing the trait manually.


6-10: Field definition and naming convention are sound.

The allowed_modules name is semantically appropriate for an allow-list field. Other rules use ignore/ignores for deny-lists, which is a distinct semantic pattern—this differentiation is intentional and correct.

@ematipico
Copy link
Member

@ematipico i believe i've resolved everything, lmk if i missed something.

There's one thing missing. The PR must be merged in the next branch. It's written here: https://github.com/biomejs/biome?tab=contributing-ov-file#creating-pull-requests

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.

We're almost there. We need more tests, and make sure we correctly understand the purpose of this new option. Once we understand it, more tests should be added, and docs should be aligned.

Comment on lines +9 to +11
#[serde(skip_serializing_if = "Vec::is_empty")]
pub allowed_modules: Vec<String>,
}
Copy link
Member

@Conaclos Conaclos Nov 6, 2025

Choose a reason for hiding this comment

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

I recommend overriding options upon merging:

Suggested change
#[serde(skip_serializing_if = "Vec::is_empty")]
pub allowed_modules: Vec<String>,
}
#[serde(skip_serializing_if = "Option::<_>::is_none")]
pub allowed_modules: Option<Box<[Box<str>]>>,
}
impl biome_deserialize::Merge for NoBitwiseOperatorsOptions {
fn merge_with(&mut self, other: Self) {
if let Some(allowed_modules) = other.allowed_modules {
self.allowed_modules = Some(allowed_modules);
}
}
}

This aligns with other rules' options.

At call site you can use allowed_modules.iter().flatten() instead of allowed_modules.iter()

Copy link
Member

Choose a reason for hiding this comment

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

If possible, let's avoid Box. In other rules, it's been a perf bottleneck

Copy link
Member

Choose a reason for hiding this comment

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

it's been a perf bottleneck

We have no evidence about that. If I remember correctly, @arendjr tried to use Vec instead and don't find evidence of perf overhead.

However, we have no evidence for the reverse either.
Thus, I accept any choice.

Copy link
Contributor

Choose a reason for hiding this comment

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

I've seen cases where it caused overhead indeed, but then when I switched to Vec instead it turned out it wasn't the actual bottleneck. So while it does cause overhead, calling it a bottleneck is probably too strong. But yeah, by default I would suggest using Vec, except in situations where there is a very strong argument against the extra memory usage.

Copy link
Member

Choose a reason for hiding this comment

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

Turning a Vec into a box should not re-allocate if the Vec length is equal to its capacity. Our JSON deserializer should more or less guarantee this (to be checked).

Copy link
Contributor

Choose a reason for hiding this comment

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

Our JSON deserializer should more or less guarantee this (to be checked).

I am very sceptical of this claim :)

Copy link
Member

Choose a reason for hiding this comment

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

@haydenbleasel
Copy link
Author

Hey @ematipico made the requested changes. Might need a resolution on how to resolve that one conversation above though.

@dyc3 dyc3 requested a review from ematipico November 7, 2025 18:55
@dyc3
Copy link
Contributor

dyc3 commented Nov 7, 2025

@haydenbleasel please make sure to fix the CI before merging main again. since you're a first time contributor, we have to manually approve the CI runs.

@haydenbleasel
Copy link
Author

@dyc3 fixed the failing ci issues 👍

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
crates/biome_js_analyze/src/lint/performance/no_namespace_import.rs (1)

33-76: Verify documentation format matches contribution guide.

The documentation nicely covers both external dependencies and local modules (addressing the earlier concern). However, a previous review noted that the options format may not match the analyzer contribution guide. Please double-check the guide to ensure the format is correct.

🧹 Nitpick comments (1)
crates/biome_js_analyze/src/lint/performance/no_namespace_import.rs (1)

99-114: Consider documenting exact string matching behaviour.

The allowlist uses exact string comparison, so "./utils" won't match "./utils/" (trailing slash) and path normalisation isn't performed. This is likely fine, but users might find it helpful if the documentation explicitly mentions that module specifiers must match exactly as they appear in the import statement.

📜 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 bfd726b and 4d29c5f.

⛔ Files ignored due to path filters (2)
  • packages/@biomejs/backend-jsonrpc/src/workspace.ts is excluded by !**/backend-jsonrpc/src/workspace.ts and included by **
  • packages/@biomejs/biome/configuration_schema.json is excluded by !**/configuration_schema.json and included by **
📒 Files selected for processing (2)
  • .changeset/thirty-goats-rescue.md (1 hunks)
  • crates/biome_js_analyze/src/lint/performance/no_namespace_import.rs (3 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .changeset/thirty-goats-rescue.md
🧰 Additional context used
🧠 Learnings (12)
📚 Learning: 2025-10-15T09:23:33.055Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:23:33.055Z
Learning: Applies to crates/biome_js_type_info/biome_module_graph/src/js_module_info/scoped_resolver.rs : Full inference must resolve TypeReference::Import across modules to TypeReference::Resolved when the target is available in the module graph.

Applied to files:

  • crates/biome_js_analyze/src/lint/performance/no_namespace_import.rs
📚 Learning: 2025-10-15T09:23:33.055Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:23:33.055Z
Learning: Applies to crates/biome_js_type_info/biome_module_graph/src/**/*.rs : Do not copy or clone data between module graph entries (including behind Arc). Each module must avoid holding duplicated data from another module to enable simple invalidation.

Applied to files:

  • crates/biome_js_analyze/src/lint/performance/no_namespace_import.rs
📚 Learning: 2025-10-15T09:23:33.055Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:23:33.055Z
Learning: Applies to crates/biome_js_type_info/src/{type_info,local_inference,resolver,flattening}.rs : Avoid recursive type structures and cross-module Arcs; represent links between types using TypeReference and TypeData::Reference.

Applied to files:

  • crates/biome_js_analyze/src/lint/performance/no_namespace_import.rs
📚 Learning: 2025-10-15T09:23:33.055Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:23:33.055Z
Learning: Applies to crates/biome_js_type_info/biome_module_graph/src/js_module_info/collector.rs : Thin (module-level) inference should resolve local and global bindings to TypeReference::Resolved, mark imported bindings as TypeReference::Import, and fall back to TypeReference::Unknown if unresolved.

Applied to files:

  • crates/biome_js_analyze/src/lint/performance/no_namespace_import.rs
📚 Learning: 2025-10-15T09:22:46.002Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:46.002Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : Import and use the `FormatNode` trait for AST nodes

Applied to files:

  • crates/biome_js_analyze/src/lint/performance/no_namespace_import.rs
📚 Learning: 2025-10-15T09:23:33.055Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:23:33.055Z
Learning: Applies to crates/biome_js_type_info/biome_module_graph/src/js_module_info/scoped_resolver.rs : Do not cache results of full inference; module replacements would stale such caches.

Applied to files:

  • crates/biome_js_analyze/src/lint/performance/no_namespace_import.rs
📚 Learning: 2025-10-15T09:22:46.002Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:46.002Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : Do not attempt to fix code; if a mandatory token/node is missing, return `None` instead

Applied to files:

  • crates/biome_js_analyze/src/lint/performance/no_namespace_import.rs
📚 Learning: 2025-10-15T09:22:46.002Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:46.002Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : Implement the `Format` trait for your node type and use `JsFormatter` with `write!`/`format_args!` to define formatting

Applied to files:

  • crates/biome_js_analyze/src/lint/performance/no_namespace_import.rs
📚 Learning: 2025-10-15T09:22:46.002Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:46.002Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : Use `dbg_write!` to debug and inspect the emitted IR during formatting

Applied to files:

  • crates/biome_js_analyze/src/lint/performance/no_namespace_import.rs
📚 Learning: 2025-10-15T09:22:46.002Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:46.002Z
Learning: Applies to crates/biome_js_formatter/**/Cargo.toml : Declare the dependency `biome_js_formatter = { version = "0.0.1", path = "../biome_js_formatter" }` for internal installation

Applied to files:

  • crates/biome_js_analyze/src/lint/performance/no_namespace_import.rs
📚 Learning: 2025-10-15T09:22:46.002Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:46.002Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : When a token is mandatory and present in the AST, use the AST-provided token (e.g., `node.l_paren_token().format()`) instead of emitting a static token

Applied to files:

  • crates/biome_js_analyze/src/lint/performance/no_namespace_import.rs
📚 Learning: 2025-10-15T09:22:15.851Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:15.851Z
Learning: Applies to crates/biome_formatter/src/**/*.rs : After generation, remove usages of `format_verbatim_node` and implement real formatting with biome_formatter utilities

Applied to files:

  • crates/biome_js_analyze/src/lint/performance/no_namespace_import.rs
🧬 Code graph analysis (1)
crates/biome_js_analyze/src/lint/performance/no_namespace_import.rs (1)
crates/biome_js_factory/src/generated/node_factory.rs (1)
  • js_module_source (2553-2558)
🔇 Additional comments (2)
crates/biome_js_analyze/src/lint/performance/no_namespace_import.rs (2)

6-6: Import looks good.

The addition of AnyJsModuleSource is necessary for extracting the module specifier in the new allowlist logic.


99-114: Logic looks solid.

The chained if let guards are idiomatic and handle extraction failures gracefully. The exact string matching approach is simple and predictable—"zod" matches "zod", "./utils" matches "./utils".

@brandonmcconnell
Copy link
Contributor

I would pay for this feature 👀

I was just slapping biome-ignore on some valibot imports yesterday.

@ematipico
Copy link
Member

@haydenbleasel you probably missed this from the contribution guide, but this PR must be sent to next branch

@haydenbleasel haydenbleasel changed the base branch from main to next November 8, 2025 08:44
@github-actions github-actions bot added A-CLI Area: CLI A-Core Area: core A-Project Area: project A-Parser Area: parser A-Formatter Area: formatter A-Tooling Area: internal tools A-Diagnostic Area: diagnostocis L-HTML Language: HTML and super languages labels Nov 8, 2025
@dyc3
Copy link
Contributor

dyc3 commented Nov 8, 2025

@haydenbleasel It looks like the diff of this PR went crazy when you changed it to next. This probably happened because of merging main into this branch.

You can fix this like so:

  1. Create a new branch locally off of next.
  2. git cherry-pick your commits from this branch into the new one.
  3. assuming origin is your fork, git push --force origin configurable-no-namespace-import to update this pr OR you can create a new PR from the clean branch

Copy link
Member

@haydenbleasel are you still interested in this PR?

@haydenbleasel
Copy link
Author

@ematipico I am, I just don't have the time to re-branch it at the moment. Will get to it as soon as I can.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CLI Area: CLI A-Core Area: core A-Diagnostic Area: diagnostocis A-Formatter Area: formatter A-Linter Area: linter A-Parser Area: parser A-Project Area: project A-Tooling Area: internal tools L-HTML Language: HTML and super languages L-JavaScript Language: JavaScript and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants