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

Skip to content

Conversation

@Bertie690
Copy link
Contributor

Summary

Fixes #7855

Test Plan

While it is literally just docs, I added more rustdoc examples to show off the new diagnostics, given the existing ones solely handled boxed type rule violations.

Docs

the entire pr is docs lol

@changeset-bot
Copy link

changeset-bot bot commented Nov 5, 2025

🦋 Changeset detected

Latest commit: 046ff0c

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

@github-actions github-actions bot added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Nov 5, 2025
@Bertie690 Bertie690 changed the title docs: Update documentation for noBannedTypes description docs: update documentation for noBannedTypes description Nov 5, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 5, 2025

Walkthrough

Updates the no_banned_types lint: BannedType::message() now returns impl biome_console::fmt::Display instead of &str. Diagnostics are constructed using that Display with emphasized markup for the banned type and an inline-disable note. Message text expanded and reformatted to provide richer, markup-aware guidance and examples for boxed primitives (BigInt/Boolean/Number/String/Symbol), Function, Object and empty-object forms ({} / EmptyObject). Minor punctuation and stylistic tweaks. A changeset entry was added for a patch release. Public API change is limited to the BannedType::message return type.

Suggested reviewers

  • dyc3
  • siketyan
  • ematipico

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.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 reflects the main change: updating documentation and diagnostics for the noBannedTypes rule.
Description check ✅ Passed The description explains the fix addresses issue #7855 and consists of documentation updates with additional rustdoc examples.
Linked Issues check ✅ Passed The PR addresses all coding-related objectives from issue #7855: improved documentation clarity, factually correct type distinctions, and updated guidance for empty-object types.
Out of Scope Changes check ✅ Passed The code changes in no_banned_types.rs enhance the BannedType::message method with richer formatted diagnostics, directly aligned with improving documentation and error message clarity as per issue #7855.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • 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 feedcd3 and 046ff0c.

📒 Files selected for processing (1)
  • crates/biome_js_analyze/src/lint/complexity/no_banned_types.rs (6 hunks)
🧰 Additional context used
🧠 Learnings (13)
📓 Common learnings
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.rs : Add new TypeScript type support by extending the TypeData enum rather than introducing parallel structures.
📚 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/complexity/no_banned_types.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.rs : Add new TypeScript type support by extending the TypeData enum rather than introducing parallel structures.

Applied to files:

  • crates/biome_js_analyze/src/lint/complexity/no_banned_types.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/complexity/no_banned_types.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/complexity/no_banned_types.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/complexity/no_banned_types.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/complexity/no_banned_types.rs
📚 Learning: 2025-09-23T21:33:00.843Z
Learnt from: arendjr
Repo: biomejs/biome PR: 7571
File: crates/biome_service/src/file_handlers/html.rs:360-368
Timestamp: 2025-09-23T21:33:00.843Z
Learning: Don't flag potential move/borrow issues in Rust code reviews since the Rust compiler catches these at compile time. Focus on logic, design, and issues that the toolchain doesn't automatically detect.

Applied to files:

  • crates/biome_js_analyze/src/lint/complexity/no_banned_types.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/complexity/no_banned_types.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 : For non-mandatory tokens, use the provided helper constructors (e.g., `token`, `space_token`, `dynamic_token`)

Applied to files:

  • crates/biome_js_analyze/src/lint/complexity/no_banned_types.rs
📚 Learning: 2025-10-15T09:21:24.116Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_diagnostics/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:21:24.116Z
Learning: Specify static properties (category, severity, description, message, location, tags) with `#[diagnostic(...)]`

Applied to files:

  • crates/biome_js_analyze/src/lint/complexity/no_banned_types.rs
📚 Learning: 2025-10-15T09:21:24.116Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_diagnostics/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:21:24.116Z
Learning: Prefer implementing the Diagnostic trait via `#[derive(Diagnostic)]`

Applied to files:

  • crates/biome_js_analyze/src/lint/complexity/no_banned_types.rs
📚 Learning: 2025-10-15T09:21:24.116Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_diagnostics/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:21:24.116Z
Learning: `#[derive(Diagnostic)]` is supported on enums; each variant must contain a type that is itself a diagnostic

Applied to files:

  • crates/biome_js_analyze/src/lint/complexity/no_banned_types.rs
🔇 Additional comments (3)
crates/biome_js_analyze/src/lint/complexity/no_banned_types.rs (3)

18-84: Excellent documentation improvements!

The expanded documentation clearly explains why each type is problematic and provides helpful context about exceptions. The distinction between primitive types and boxed object types is particularly well-articulated, and the explanation of {} accepting non-nullable values (not empty objects) addresses a common misconception.


85-151: Comprehensive and accurate examples.

The invalid and valid examples cover all the rule's scenarios effectively. The callback example (line 127) correctly uses cb(12), and the exception cases for {} are clearly demonstrated.


299-329: Well-structured message implementation.

The return type change to impl biome_console::fmt::Display correctly accommodates the markup-based messages. The use of and_then for extracting primitive_str (lines 302-303) is appropriate, and the expect is safe since all variants in that match arm map to syntax kinds. The <Emphasis> tags are used consistently throughout to highlight type names and alternatives.


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: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
crates/biome_js_analyze/src/lint/complexity/no_banned_types.rs (1)

220-228: Fix the diagnostic chain syntax error.

Line 225 terminates the statement with a semicolon, but line 227 attempts to continue the method chain with .note(...). This causes the compilation error on line 227.

Apply this diff to fix the chaining:

         let diagnostic = RuleDiagnostic::new(
             rule_category!(),
             banned_type_range,
             markup! {"Don't use '"{banned_type.to_string()}"' as a type."}.to_owned(),
         )
-        .note(markup! { {banned_type.message()} }.to_owned());
+        .note(markup! { {banned_type.message()} }.to_owned())
         // TODO: Update this if/when the rule gets split up or has individual disabling options added
-        .note("If that's really what you want, use an inline disable comment.")
+        .note("If that's really what you want, use an inline disable comment.");
         Some(diagnostic)
📜 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 6e8a50e and 4215331.

📒 Files selected for processing (1)
  • crates/biome_js_analyze/src/lint/complexity/no_banned_types.rs (7 hunks)
🧰 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/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/complexity/no_banned_types.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.rs : Add new TypeScript type support by extending the TypeData enum rather than introducing parallel structures.

Applied to files:

  • crates/biome_js_analyze/src/lint/complexity/no_banned_types.rs
📚 Learning: 2025-10-15T09:21:24.116Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_diagnostics/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:21:24.116Z
Learning: Prefer implementing the Diagnostic trait via `#[derive(Diagnostic)]`

Applied to files:

  • crates/biome_js_analyze/src/lint/complexity/no_banned_types.rs
📚 Learning: 2025-10-15T09:21:24.116Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_diagnostics/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:21:24.116Z
Learning: `#[derive(Diagnostic)]` is supported on enums; each variant must contain a type that is itself a diagnostic

Applied to files:

  • crates/biome_js_analyze/src/lint/complexity/no_banned_types.rs
📚 Learning: 2025-10-15T09:21:24.116Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_diagnostics/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:21:24.116Z
Learning: Specify static properties (category, severity, description, message, location, tags) with `#[diagnostic(...)]`

Applied to files:

  • crates/biome_js_analyze/src/lint/complexity/no_banned_types.rs
🪛 GitHub Actions: Pull request Node.js
crates/biome_js_analyze/src/lint/complexity/no_banned_types.rs

[error] 227-227: expected expression, found .


[error] 309-309: expected ;, found "\nExplicitly defining the function shape helps prevent mismatching argument types and return values."


[error] 310-310: expected ;, found "\nIf a generic "catch-all" callback type is required, consider using a "top type" like (...args: never) => unknown instead."


[error] 302-302: mismatched types: expected &str because of return type, found Markup<'_>


[error] 314-314: mismatched types: expected &str because of return type, found Markup<'_>


[error] 302-306: the trait bound std::option::Option<&str>: biome_console::fmt::Display is not satisfied


[error] could not compile biome_js_analyze (lib) due to 6 previous errors

⏰ 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). (6)
  • GitHub Check: End-to-end tests
  • GitHub Check: Check Dependencies
  • GitHub Check: autofix
  • GitHub Check: Bench (biome_js_analyze)
  • GitHub Check: Bench (biome_js_parser)
  • GitHub Check: Bench (biome_js_formatter)

Copy link
Contributor

@dyc3 dyc3 left a comment

Choose a reason for hiding this comment

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

Nice! The CI will need to be fixed though

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.

Since we updated the code of the rule (the diagnostic), we should have a changeset. We can just say "Improved the diagnostic of ..."

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: 2

📜 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 eaeba31 and 2b6d20b.

📒 Files selected for processing (1)
  • crates/biome_js_analyze/src/lint/complexity/no_banned_types.rs (7 hunks)
🧰 Additional context used
🧠 Learnings (8)
📓 Common learnings
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.rs : Add new TypeScript type support by extending the TypeData enum rather than introducing parallel structures.
📚 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.rs : Add new TypeScript type support by extending the TypeData enum rather than introducing parallel structures.

Applied to files:

  • crates/biome_js_analyze/src/lint/complexity/no_banned_types.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/complexity/no_banned_types.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/complexity/no_banned_types.rs
📚 Learning: 2025-09-23T21:33:00.843Z
Learnt from: arendjr
Repo: biomejs/biome PR: 7571
File: crates/biome_service/src/file_handlers/html.rs:360-368
Timestamp: 2025-09-23T21:33:00.843Z
Learning: Don't flag potential move/borrow issues in Rust code reviews since the Rust compiler catches these at compile time. Focus on logic, design, and issues that the toolchain doesn't automatically detect.

Applied to files:

  • crates/biome_js_analyze/src/lint/complexity/no_banned_types.rs
📚 Learning: 2025-10-15T09:21:24.116Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_diagnostics/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:21:24.116Z
Learning: Prefer implementing the Diagnostic trait via `#[derive(Diagnostic)]`

Applied to files:

  • crates/biome_js_analyze/src/lint/complexity/no_banned_types.rs
📚 Learning: 2025-10-15T09:21:24.116Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_diagnostics/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:21:24.116Z
Learning: `#[derive(Diagnostic)]` is supported on enums; each variant must contain a type that is itself a diagnostic

Applied to files:

  • crates/biome_js_analyze/src/lint/complexity/no_banned_types.rs
📚 Learning: 2025-10-15T09:21:24.116Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_diagnostics/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:21:24.116Z
Learning: Specify static properties (category, severity, description, message, location, tags) with `#[diagnostic(...)]`

Applied to files:

  • crates/biome_js_analyze/src/lint/complexity/no_banned_types.rs
🪛 GitHub Actions: Lint rule docs
crates/biome_js_analyze/src/lint/complexity/no_banned_types.rs

[error] 303-307: the trait biome_console::fmt::Display is not implemented for std::option::Option<&str>; adjust the code to handle Option (e.g., unwrap or map to a string) before formatting. This causes a compilation error in the lint rule.

🪛 GitHub Actions: Pull request Node.js
crates/biome_js_analyze/src/lint/complexity/no_banned_types.rs

[error] 303-307: Compiler error: the trait bound std::option::Option<&str>: biome_console::fmt::Display is not satisfied in markup! macro usage. This causes the build to fail while compiling biome_js_analyze.

⏰ 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). (5)
  • GitHub Check: Check Dependencies
  • GitHub Check: Bench (biome_js_formatter)
  • GitHub Check: Bench (biome_js_parser)
  • GitHub Check: Bench (biome_js_analyze)
  • GitHub Check: autofix

@Bertie690 Bertie690 requested review from dyc3 and ematipico November 5, 2025 20:58
@Bertie690 Bertie690 changed the title docs: update documentation for noBannedTypes description docs: update documentation + diagnostic for noBannedTypes description Nov 5, 2025
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 2b6d20b and f08c47a.

📒 Files selected for processing (2)
  • .changeset/curvy-nails-bake.md (1 hunks)
  • crates/biome_js_analyze/src/lint/complexity/no_banned_types.rs (6 hunks)
🧰 Additional context used
🧠 Learnings (10)
📚 Learning: 2025-10-25T07:02:26.457Z
Learnt from: ematipico
Repo: biomejs/biome PR: 7856
File: .changeset/yellow-crews-guess.md:1-5
Timestamp: 2025-10-25T07:02:26.457Z
Learning: The Biome documentation website uses kebab-case URL slugs for rule pages (e.g., `/linter/rules/no-continue/`), not camelCase.

Applied to files:

  • .changeset/curvy-nails-bake.md
📚 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/complexity/no_banned_types.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.rs : Add new TypeScript type support by extending the TypeData enum rather than introducing parallel structures.

Applied to files:

  • crates/biome_js_analyze/src/lint/complexity/no_banned_types.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/complexity/no_banned_types.rs
📚 Learning: 2025-09-23T21:33:00.843Z
Learnt from: arendjr
Repo: biomejs/biome PR: 7571
File: crates/biome_service/src/file_handlers/html.rs:360-368
Timestamp: 2025-09-23T21:33:00.843Z
Learning: Don't flag potential move/borrow issues in Rust code reviews since the Rust compiler catches these at compile time. Focus on logic, design, and issues that the toolchain doesn't automatically detect.

Applied to files:

  • crates/biome_js_analyze/src/lint/complexity/no_banned_types.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/complexity/no_banned_types.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 : For non-mandatory tokens, use the provided helper constructors (e.g., `token`, `space_token`, `dynamic_token`)

Applied to files:

  • crates/biome_js_analyze/src/lint/complexity/no_banned_types.rs
📚 Learning: 2025-10-15T09:21:24.116Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_diagnostics/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:21:24.116Z
Learning: Prefer implementing the Diagnostic trait via `#[derive(Diagnostic)]`

Applied to files:

  • crates/biome_js_analyze/src/lint/complexity/no_banned_types.rs
📚 Learning: 2025-10-15T09:21:24.116Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_diagnostics/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:21:24.116Z
Learning: `#[derive(Diagnostic)]` is supported on enums; each variant must contain a type that is itself a diagnostic

Applied to files:

  • crates/biome_js_analyze/src/lint/complexity/no_banned_types.rs
📚 Learning: 2025-10-15T09:21:24.116Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_diagnostics/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:21:24.116Z
Learning: Specify static properties (category, severity, description, message, location, tags) with `#[diagnostic(...)]`

Applied to files:

  • crates/biome_js_analyze/src/lint/complexity/no_banned_types.rs
⏰ 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). (5)
  • GitHub Check: Test Node.js API
  • GitHub Check: Bench (biome_js_analyze)
  • GitHub Check: autofix
  • GitHub Check: Bench (biome_js_formatter)
  • GitHub Check: Bench (biome_js_parser)

@codspeed-hq
Copy link

codspeed-hq bot commented Nov 5, 2025

CodSpeed Performance Report

Merging #8006 will not alter performance

Comparing Bertie690:banned-types-doc-fix (046ff0c) with main (e8b6753)

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.

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/src/lint/complexity/no_banned_types.rs (1)

318-323: Consider aligning the leading newline for consistency.

The Object/EmptyObject message starts with "\n" whilst the primitive and Function messages start with text directly. Whilst the extra spacing may be intentional, removing the leading newline would make the formatting consistent across all variants.

Apply this diff if you'd like to align the formatting:

             Self::Object | Self::EmptyObject => {
                 markup! {
-                    "\n`"{ self.to_string() }"` accepts _any non-nullable value_, including non-object primitives like `123` and `true`."
+                    "`"{ self.to_string() }"` accepts _any non-nullable value_, including non-object primitives like `123` and `true`."
                     "\n- If you want a type meaning \"any arbitrary object\", use `object` instead."
                     "\n- If you want a type meaning \"any value\", use `unknown` instead."
                     "\n- If you want a type meaning \"an object without any properties\", use `{ [k: string]: never }` or `Record<string, never>` instead."
                 }.to_owned()
             }
📜 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 18ed3fb and ea1a171.

📒 Files selected for processing (1)
  • crates/biome_js_analyze/src/lint/complexity/no_banned_types.rs (6 hunks)
🧰 Additional context used
🧠 Learnings (12)
📓 Common learnings
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.rs : Add new TypeScript type support by extending the TypeData enum rather than introducing parallel structures.
📚 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/complexity/no_banned_types.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.rs : Add new TypeScript type support by extending the TypeData enum rather than introducing parallel structures.

Applied to files:

  • crates/biome_js_analyze/src/lint/complexity/no_banned_types.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/complexity/no_banned_types.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/complexity/no_banned_types.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/complexity/no_banned_types.rs
📚 Learning: 2025-09-23T21:33:00.843Z
Learnt from: arendjr
Repo: biomejs/biome PR: 7571
File: crates/biome_service/src/file_handlers/html.rs:360-368
Timestamp: 2025-09-23T21:33:00.843Z
Learning: Don't flag potential move/borrow issues in Rust code reviews since the Rust compiler catches these at compile time. Focus on logic, design, and issues that the toolchain doesn't automatically detect.

Applied to files:

  • crates/biome_js_analyze/src/lint/complexity/no_banned_types.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/complexity/no_banned_types.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 : For non-mandatory tokens, use the provided helper constructors (e.g., `token`, `space_token`, `dynamic_token`)

Applied to files:

  • crates/biome_js_analyze/src/lint/complexity/no_banned_types.rs
📚 Learning: 2025-10-15T09:21:24.116Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_diagnostics/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:21:24.116Z
Learning: Prefer implementing the Diagnostic trait via `#[derive(Diagnostic)]`

Applied to files:

  • crates/biome_js_analyze/src/lint/complexity/no_banned_types.rs
📚 Learning: 2025-10-15T09:21:24.116Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_diagnostics/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:21:24.116Z
Learning: `#[derive(Diagnostic)]` is supported on enums; each variant must contain a type that is itself a diagnostic

Applied to files:

  • crates/biome_js_analyze/src/lint/complexity/no_banned_types.rs
📚 Learning: 2025-10-15T09:21:24.116Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_diagnostics/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:21:24.116Z
Learning: Specify static properties (category, severity, description, message, location, tags) with `#[diagnostic(...)]`

Applied to files:

  • crates/biome_js_analyze/src/lint/complexity/no_banned_types.rs
⏰ 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)
  • GitHub Check: Documentation
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Check Dependencies
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Test Node.js API
  • GitHub Check: autofix
  • GitHub Check: Bench (biome_js_parser)
  • GitHub Check: Bench (biome_js_formatter)
  • GitHub Check: Bench (biome_js_analyze)
🔇 Additional comments (3)
crates/biome_js_analyze/src/lint/complexity/no_banned_types.rs (3)

21-151: Excellent documentation improvements.

The expanded explanations and examples are thorough and accurate. The distinction between primitive and boxed types is now crystal clear, and the {} type guidance with its exceptions is particularly helpful.


226-229: Nice cleanup on the diagnostic construction.

Using banned_type.message() centralises the messaging logic, and the punctuation consistency fix is a good catch.

Also applies to: 247-247


298-316: The Display-based messaging looks solid.

The transition from &str to impl Display allows the rich markup formatting, and the primitive type extraction correctly handles the Option chain. The expanded explanations will help developers understand why these types are problematic.

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/src/lint/complexity/no_banned_types.rs (1)

297-326: Tidy the leading newline for consistency.

Line 319 begins with \n, which introduces a blank line before the message content for Object and EmptyObject types. The other match branches (lines 305 and 312) don't start with a newline, so this inconsistency is likely unintentional and affects diagnostic formatting.

Apply this diff to remove the leading newline:

             Self::Object | Self::EmptyObject => {
                 markup! {
-                    "\n`"{ self.to_string() }"` accepts _any non-nullable value_, including non-object primitives like `123` and `true`."
+                    "`"{ self.to_string() }"` accepts _any non-nullable value_, including non-object primitives like `123` and `true`."
                     "\n- If you want a type meaning \"any arbitrary object\", use `object` instead."
                     "\n- If you want a type meaning \"any value\", use `unknown` instead."
                     "\n- If you want a type meaning \"an object without any properties\", use `{ [k: string]: never }` or `Record<string, never>` instead."
                 }.to_owned()
             }
📜 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 ea1a171 and cd7bb18.

📒 Files selected for processing (1)
  • crates/biome_js_analyze/src/lint/complexity/no_banned_types.rs (6 hunks)
🧰 Additional context used
🧠 Learnings (12)
📓 Common learnings
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.rs : Add new TypeScript type support by extending the TypeData enum rather than introducing parallel structures.
📚 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/complexity/no_banned_types.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.rs : Add new TypeScript type support by extending the TypeData enum rather than introducing parallel structures.

Applied to files:

  • crates/biome_js_analyze/src/lint/complexity/no_banned_types.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/complexity/no_banned_types.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/complexity/no_banned_types.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/complexity/no_banned_types.rs
📚 Learning: 2025-09-23T21:33:00.843Z
Learnt from: arendjr
Repo: biomejs/biome PR: 7571
File: crates/biome_service/src/file_handlers/html.rs:360-368
Timestamp: 2025-09-23T21:33:00.843Z
Learning: Don't flag potential move/borrow issues in Rust code reviews since the Rust compiler catches these at compile time. Focus on logic, design, and issues that the toolchain doesn't automatically detect.

Applied to files:

  • crates/biome_js_analyze/src/lint/complexity/no_banned_types.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/complexity/no_banned_types.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 : For non-mandatory tokens, use the provided helper constructors (e.g., `token`, `space_token`, `dynamic_token`)

Applied to files:

  • crates/biome_js_analyze/src/lint/complexity/no_banned_types.rs
📚 Learning: 2025-10-15T09:21:24.116Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_diagnostics/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:21:24.116Z
Learning: Prefer implementing the Diagnostic trait via `#[derive(Diagnostic)]`

Applied to files:

  • crates/biome_js_analyze/src/lint/complexity/no_banned_types.rs
📚 Learning: 2025-10-15T09:21:24.116Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_diagnostics/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:21:24.116Z
Learning: `#[derive(Diagnostic)]` is supported on enums; each variant must contain a type that is itself a diagnostic

Applied to files:

  • crates/biome_js_analyze/src/lint/complexity/no_banned_types.rs
📚 Learning: 2025-10-15T09:21:24.116Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_diagnostics/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:21:24.116Z
Learning: Specify static properties (category, severity, description, message, location, tags) with `#[diagnostic(...)]`

Applied to files:

  • crates/biome_js_analyze/src/lint/complexity/no_banned_types.rs
🧬 Code graph analysis (1)
crates/biome_js_analyze/src/lint/complexity/no_banned_types.rs (1)
crates/biome_service/src/workspace.rs (1)
  • markup (1149-1151)
⏰ 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). (11)
  • GitHub Check: Documentation
  • GitHub Check: End-to-end tests
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Check Dependencies
  • GitHub Check: Test Node.js API
  • GitHub Check: Bench (biome_js_parser)
  • GitHub Check: Bench (biome_js_analyze)
  • GitHub Check: Bench (biome_js_formatter)
🔇 Additional comments (3)
crates/biome_js_analyze/src/lint/complexity/no_banned_types.rs (3)

18-161: Excellent documentation improvements.

The expanded explanations for boxed types, the Function type, and empty object type {} are clear and comprehensive. The additional examples effectively demonstrate both invalid and valid usage patterns.


213-231: LGTM on the diagnostic refactoring.

The use of .note(banned_type.message()) cleanly separates the diagnostic message from the detailed explanation, and the inline disable comment guidance is a helpful addition.


233-251: Nice punctuation polish.

The added full stop on line 247 improves consistency with standard diagnostic message formatting.

@ematipico ematipico merged commit f0612a5 into biomejs:main Nov 9, 2025
18 checks passed
@github-actions github-actions bot mentioned this pull request Nov 9, 2025
@Bertie690 Bertie690 deleted the banned-types-doc-fix branch November 9, 2025 14:38
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.

📚 noBannedTypes has factually incorrect information; lacks depth

3 participants