Skip to content

Conversation

@tt-a1i
Copy link
Contributor

@tt-a1i tt-a1i commented Jan 4, 2026

Summary

Fixed #8345: useAdjacentOverloadSignatures no longer reports false positives for static and instance methods with the same name.

The rule was incorrectly treating static methods and instance methods with the same name as belonging to the same overload group:

class Foo {
  static kek(): number { return 0 }  // reported as needing to be adjacent to instance kek()
  another(): string { return '' }
  kek(): number { return 1 }         // false positive
}

Static and instance methods are now tracked separately, so they're treated as independent overload groups.

Test plan

  • Added test cases for static/instance method combinations in valid.ts
  • Verified existing tests still pass
  • cargo test -p biome_js_analyze use_adjacent_overload_signatures

AI Assistance Disclosure

I used Codex to review the changes, sanity-check the implementation against existing patterns, and help spot potential edge cases.

…OverloadSignatures

Fixed biomejs#8345: useAdjacentOverloadSignatures no longer reports false positives
for static and instance methods with the same name. Static methods and
instance methods are now treated as separate overload groups.
@changeset-bot
Copy link

changeset-bot bot commented Jan 4, 2026

🦋 Changeset detected

Latest commit: 014b48e

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 Jan 4, 2026
@codspeed-hq
Copy link

codspeed-hq bot commented Jan 4, 2026

CodSpeed Performance Report

Merging #8670 will not alter performance

Comparing tt-a1i:fix/adjacent-overload-static (014b48e) with main (1550e73)

Summary

✅ 58 untouched
⏩ 95 skipped1

Footnotes

  1. 95 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.

- Keep static/instance in key without ignoring interleaving members

- Preserve private names (#f) vs public names

- Add invalid coverage + update snapshots
@tt-a1i tt-a1i marked this pull request as ready for review January 4, 2026 09:51
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 4, 2026

Walkthrough

This PR fixes a false-positive in the useAdjacentOverloadSignatures lint rule. The fix introduces per-member static-awareness by creating a ClassMethodKey that combines method name and static flag. This ensures static and instance methods with identical names are treated as separate overload groups, preventing false positives when methods are non-consecutive. Test cases are added to verify both valid scenarios (static and instance methods separated) and invalid scenarios (true adjacent overload violations).

Suggested reviewers

  • ematipico
  • dyc3
  • siketyan

Pre-merge checks and finishing touches

✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: fixing the rule to differentiate static and instance methods in overload signature checking.
Description check ✅ Passed The description is well-related to the changeset, explaining the bug fix with a concrete example and describing the test plan and verification steps.
Linked Issues check ✅ Passed The PR successfully addresses issue #8345 by implementing separate tracking for static vs instance methods, treating them as distinct overload groups and preventing false positives.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the issue: implementation fix in the rule logic, test cases covering the static/instance distinction, and release notes documenting the fix.
✨ Finishing touches
  • 📝 Generate docstrings

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

193-203: Consider adding rustdoc for ClassMethodKey.

The struct is well-designed, but a brief rustdoc comment would clarify its purpose: "Represents a class method identity including both its name and whether it's static. Used to distinguish static and instance methods with the same name as separate overload groups."

🔎 Suggested rustdoc
+/// Key for tracking class method overloads.
+///
+/// Combines the method name with a static flag to ensure static and instance
+/// methods with the same name are treated as separate overload groups.
 #[derive(Clone, Eq, PartialEq, Hash)]
 struct ClassMethodKey {
     name: ClassMemberName,
     is_static: bool,
 }
📜 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 1550e73 and 014b48e.

⛔ Files ignored due to path filters (2)
  • crates/biome_js_analyze/tests/specs/suspicious/useAdjacentOverloadSignatures/invalid.ts.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/suspicious/useAdjacentOverloadSignatures/valid.ts.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (4)
  • .changeset/fix-adjacent-overload-static.md
  • crates/biome_js_analyze/src/lint/suspicious/use_adjacent_overload_signatures.rs
  • crates/biome_js_analyze/tests/specs/suspicious/useAdjacentOverloadSignatures/invalid.ts
  • crates/biome_js_analyze/tests/specs/suspicious/useAdjacentOverloadSignatures/valid.ts
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

**/*.rs: Use inline rustdoc documentation for rules, assists, and their options
Use the dbg!() macro for debugging output in Rust tests and code
Use doc tests (doctest) format with code blocks in rustdoc comments; ensure assertions pass in tests

Files:

  • crates/biome_js_analyze/src/lint/suspicious/use_adjacent_overload_signatures.rs
🧠 Learnings (17)
📚 Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/*.rs : Distinguish between `TypeData::Unknown` and `TypeData::UnknownKeyword` to measure inference effectiveness versus explicit user-provided unknown types

Applied to files:

  • crates/biome_js_analyze/src/lint/suspicious/use_adjacent_overload_signatures.rs
📚 Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/*.rs : Use `TypeReference` instead of `Arc` for types that reference other types to avoid stale cache issues when modules are replaced

Applied to files:

  • crates/biome_js_analyze/src/lint/suspicious/use_adjacent_overload_signatures.rs
📚 Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/js_module_info/collector.rs : Implement module-level (thin) inference to resolve `TypeReference::Qualifier` variants by looking up declarations in module scopes and handling import statements

Applied to files:

  • crates/biome_js_analyze/src/lint/suspicious/use_adjacent_overload_signatures.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Use `declare_node_union!` macro to query multiple node types together to avoid redundant traversal passes

Applied to files:

  • crates/biome_js_analyze/src/lint/suspicious/use_adjacent_overload_signatures.rs
📚 Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/*.rs : Use `TypeReference` variants (`Qualifier`, `Resolved`, `Import`, `Unknown`) to represent different phases of type resolution

Applied to files:

  • crates/biome_js_analyze/src/lint/suspicious/use_adjacent_overload_signatures.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Avoid string allocations by using `&str` or `TokenText` instead of `to_string()`

Applied to files:

  • crates/biome_js_analyze/src/lint/suspicious/use_adjacent_overload_signatures.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Use the `Semantic<T>` query type to access semantic information about bindings, references, and scope within a rule

Applied to files:

  • crates/biome_js_analyze/src/lint/suspicious/use_adjacent_overload_signatures.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Use `Markup!` macro for diagnostic messages and code action descriptions to ensure proper formatting

Applied to files:

  • crates/biome_js_analyze/src/lint/suspicious/use_adjacent_overload_signatures.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Use `declare_lint_rule!` macro with a `version` field set to `next` for new rules

Applied to files:

  • crates/biome_js_analyze/src/lint/suspicious/use_adjacent_overload_signatures.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Check if a variable is global using the semantic model before reporting diagnostics for rules that ban global functions or variables

Applied to files:

  • crates/biome_js_analyze/src/lint/suspicious/use_adjacent_overload_signatures.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Deprecated rules must include a `deprecated` field in the `declare_lint_rule!` macro with an explanation of what rule to use instead

Applied to files:

  • crates/biome_js_analyze/src/lint/suspicious/use_adjacent_overload_signatures.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Invalid code snippets in rule documentation must emit exactly one diagnostic

Applied to files:

  • crates/biome_js_analyze/src/lint/suspicious/use_adjacent_overload_signatures.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Rule names should use the `use` prefix when the rule's sole intention is to mandate a single concept

Applied to files:

  • crates/biome_js_analyze/src/lint/suspicious/use_adjacent_overload_signatures.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Code blocks in rule documentation must specify a language identifier and be tagged with `expect_diagnostic` for invalid examples or remain untagged for valid examples

Applied to files:

  • crates/biome_js_analyze/src/lint/suspicious/use_adjacent_overload_signatures.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Use `rule_category!()` macro to refer to the diagnostic category instead of dynamically parsing its string name

Applied to files:

  • crates/biome_js_analyze/src/lint/suspicious/use_adjacent_overload_signatures.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Mark rules with `issue_number` in the `declare_lint_rule!` macro if they are work-in-progress to indicate missing features

Applied to files:

  • crates/biome_js_analyze/src/lint/suspicious/use_adjacent_overload_signatures.rs
📚 Learning: 2025-12-22T09:26:56.943Z
Learnt from: ematipico
Repo: biomejs/biome PR: 8537
File: crates/biome_js_analyze/src/lint/nursery/no_leaked_render.rs:167-210
Timestamp: 2025-12-22T09:26:56.943Z
Learning: When defining lint rules (declare_lint_rule!), only specify fix_kind if the rule implements an action(...) function. Rules that only emit diagnostics without a code fix should omit fix_kind. This applies to all Rust lint rule definitions under crates/.../src/lint (e.g., crates/biome_js_analyze/src/lint/...).

Applied to files:

  • crates/biome_js_analyze/src/lint/suspicious/use_adjacent_overload_signatures.rs
🧬 Code graph analysis (1)
crates/biome_js_analyze/tests/specs/suspicious/useAdjacentOverloadSignatures/invalid.ts (1)
crates/biome_js_analyze/tests/specs/suspicious/noRedeclare/valid-declaration-merging.ts (1)
  • F (143-143)
⏰ 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). (3)
  • GitHub Check: Bench (biome_js_formatter)
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Test Node.js API
🔇 Additional comments (5)
crates/biome_js_analyze/tests/specs/suspicious/useAdjacentOverloadSignatures/invalid.ts (1)

55-67: Excellent test coverage for the fix.

Classes E and F verify that the rule still correctly flags non-adjacent overloads within the same group (instance or static) whilst treating static and instance as separate groups. Class E validates instance overload violations, Class F validates static overload violations.

crates/biome_js_analyze/src/lint/suspicious/use_adjacent_overload_signatures.rs (2)

213-251: Well-implemented static/instance distinction.

Both JsMethodClassMember and TsMethodSignatureClassMember code paths correctly extract the static modifier using BitFlags<Modifier> and construct ClassMethodKey with the appropriate flag. The consistent handling across both member types ensures comprehensive coverage.


317-334: Elegant generic solution.

Making check_method generic over T: Clone + Eq + Hash + Into<TokenText> is clever—it allows the function to work seamlessly with both plain TokenText (for interfaces, types) and ClassMethodKey (for classes) without code duplication. The Into<TokenText> bound ensures diagnostics can still display just the method name.

crates/biome_js_analyze/tests/specs/suspicious/useAdjacentOverloadSignatures/valid.ts (1)

74-102: Comprehensive test coverage with clear documentation.

The four new classes thoroughly validate the fix:

  • D & E: Basic static/instance separation in different orders
  • F: Static overloads remain valid when adjacent
  • G: Instance overloads valid with static method following

The comments clearly link to issue #8345 and explain the expected behaviour.

.changeset/fix-adjacent-overload-static.md (1)

1-13: Clear and well-documented changelog entry.

The changeset succinctly explains the fix with a practical example. The reference to issue #8345 and the rule documentation link provide useful context for users.

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.

💅 False-positiveuseAdjacentOverloadSignatures for static and none-static methods

1 participant