Skip to content

feat(lint): implement useConsistentMethodSignatures from typescript-eslint#8786

Merged
dyc3 merged 4 commits intobiomejs:mainfrom
Bertie690:method-signature-style
Jan 31, 2026
Merged

feat(lint): implement useConsistentMethodSignatures from typescript-eslint#8786
dyc3 merged 4 commits intobiomejs:mainfrom
Bertie690:method-signature-style

Conversation

@Bertie690
Copy link
Contributor

@Bertie690 Bertie690 commented Jan 17, 2026

Summary

Works towards implementing #8780

Implements a new nursery rule useConsistentMethodSignatures with the same semantics as its parent TSEslint counterpart.

No code fix is currently implemented, so the issue is left open for someone else to try their hand.

Test Plan

4 new spec test files, plus around 1-2 dozen doctests.

Docs

see above

@changeset-bot
Copy link

changeset-bot bot commented Jan 17, 2026

🦋 Changeset detected

Latest commit: 6fe58c5

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-Project Area: project A-Linter Area: linter L-JavaScript Language: JavaScript and super languages A-Diagnostic Area: diagnostocis labels Jan 17, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 17, 2026

Walkthrough

Adds a nursery linter rule useConsistentMethodSignatures that enforces a configured method-signature style (property or method) for TypeScript interfaces and type aliases. Implements the rule and its state (InconsistentMethodSignatureState), a public union AnyTsMethodSignatureLike with get_signature_style, and options types (UseConsistentMethodSignaturesOptions and MethodSignatureStyle). Adds tests and JSON configs for valid and invalid cases. The rule emits diagnostics when a node's signature style differs from the configured style and provides no automatic fixes.

Suggested reviewers

  • ematipico
  • dyc3
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: implementing a new lint rule useConsistentMethodSignatures from typescript-eslint.
Description check ✅ Passed The description clearly relates to the changeset, explaining the implementation of a nursery rule with test plan and deferred autofix work.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

🤖 Fix all issues with AI agents
In @.changeset/shiny-hands-care.md:
- Line 24: The file .changeset/shiny-hands-care.md is missing a trailing
newline; open that markdown file and add a single newline character at the end
so the file ends with exactly one trailing newline (ensure no extra blank lines
are appended).

In
`@crates/biome_js_analyze/src/lint/nursery/use_consistent_method_signatures.rs`:
- Around line 240-245: Fix the typo in the doc comment for the
declare_node_union! block that defines AnyTsMethodSignatureLike: change the
string "orinterface" to "or interface" in the comment above the macro invocation
so the sentence reads "within a type alias or interface." Leave the macro name
declare_node_union! and the union members (TsMethodSignatureTypeMember |
TsPropertySignatureTypeMember) unchanged.
- Line 56: The documentation comment in use_consistent_method_signatures.rs
contains an incomplete sentence: "any `Event`s passed to the  `SpecialEvent`s" —
update the doc string for the rule (near the comment mentioning `Event` and
`SpecialEvent`) to complete the thought and clarify the relationship (for
example: "any `Event`s passed to the `SpecialEvent` handlers" or "any `Event`s
passed to `SpecialEvent`-typed parameters"), ensuring the sentence reads
grammatically and consistently references `Event` and `SpecialEvent`.
- Around line 114-118: The doctest in use_consistent_method_signatures.rs
contains invalid TypeScript syntax for the property type `genericProp<T, U>:
(arg: T) => U`; update the example so the property is typed as a generic
function type instead of placing type parameters on the property name (i.e.,
make `genericProp` have a type that declares `<T, U>` on the function itself and
then `(arg: T) => U`). Modify the snippet in the doctest for the `genericProp`
property accordingly so it is valid TypeScript.

@github-actions github-actions bot added the A-CLI Area: CLI label Jan 17, 2026
@codspeed-hq
Copy link

codspeed-hq bot commented Jan 17, 2026

CodSpeed Performance Report

Merging this PR will not alter performance

Comparing Bertie690:method-signature-style (6fe58c5) with main (871b45e)

Summary

✅ 58 untouched benchmarks
⏩ 95 skipped benchmarks1

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.

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

🤖 Fix all issues with AI agents
In
`@crates/biome_js_analyze/src/lint/nursery/use_consistent_method_signatures.rs`:
- Around line 248-253: Doc comment contains a typo "annotatation" — update the
comment inside the declare_node_union for AnyTsMethodSignatureLike (the union of
TsMethodSignatureTypeMember and TsPropertySignatureTypeMember) to correct
"annotatation" to "annotation" so the documentation reads properly.
- Around line 149-155: The JSON example in the doc comment for the rule
use_consistent_method_signatures contains an invalid trailing comma after
"method"; remove that trailing comma so the snippet becomes valid JSON (update
the docblock showing the "options" example in
use_consistent_method_signatures.rs to have "style": "method" without a
following comma).
🧹 Nitpick comments (1)
crates/biome_js_analyze/src/lint/nursery/use_consistent_method_signatures.rs (1)

188-192: Convert comment to rustdoc.

Per coding guidelines, use inline rustdoc documentation. The current comment uses // instead of ///.

Proposed fix
-// Struct containing info about an inconsistent method signature diagnostic.
+/// Struct containing info about an inconsistent method signature diagnostic.
 pub struct InconsistentMethodSignatureState {
     target_style: MethodSignatureStyle,
     node_style: MethodSignatureStyle,
 }

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 the rule isn't finished (code fix missing), add issue_number to the rule metadata (check the contribution guide). You'll have to update the snapshots.

Then, update the PR description so that it doesn't close the relative issue

@Bertie690 Bertie690 requested a review from ematipico January 18, 2026 16:58
@Bertie690 Bertie690 changed the title feat(lint): implement useConsistentMethodSignatures from TSEslint feat(lint): implement useConsistentMethodSignatures from typescript-eslint Jan 23, 2026
@Bertie690
Copy link
Contributor Author

... how did merging into next break formatting

@Bertie690 Bertie690 force-pushed the method-signature-style branch from 96e95d3 to a7d21de Compare January 31, 2026 19:54
@Bertie690 Bertie690 changed the base branch from next to main January 31, 2026 19:54
@Bertie690 Bertie690 requested a review from dyc3 January 31, 2026 19:55
@Bertie690
Copy link
Contributor Author

@dyc3 Rebased onto main as requested.

@dyc3
Copy link
Contributor

dyc3 commented Jan 31, 2026

There's still some CI failures

@Bertie690
Copy link
Contributor Author

image

wow, these diagnostics are very helpful (not)

@Bertie690
Copy link
Contributor Author

@dyc3
On second glance, it appears the problems arise from the doctest parser not recognizing code highlight ranges from Starlight and promptly erroring out.

The goal was to highlight lines 2-3 and 4-6 of the codeblock on the website, but it appears this will have to be shelved until the doctest code learns to ignore such patterns.

@dyc3
Copy link
Contributor

dyc3 commented Jan 31, 2026

That's fine, we can remove the syntax causing the error

@dyc3 dyc3 merged commit d876a38 into biomejs:main Jan 31, 2026
20 checks passed
@github-actions github-actions bot mentioned this pull request Jan 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CLI Area: CLI A-Diagnostic Area: diagnostocis A-Linter Area: linter A-Project Area: project L-JavaScript Language: JavaScript and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants