Skip to content

feat: apply fix to use consistent method signatures#9544

Merged
dyc3 merged 6 commits intobiomejs:mainfrom
ViniciusDev26:feat/apply-fix-to-useConsistentMethodSignatures
Mar 22, 2026
Merged

feat: apply fix to use consistent method signatures#9544
dyc3 merged 6 commits intobiomejs:mainfrom
ViniciusDev26:feat/apply-fix-to-useConsistentMethodSignatures

Conversation

@ViniciusDev26
Copy link
Contributor

This PR was written with the assistance of Claude Code (AI). The implementation,
decisions, and review were done collaboratively with the AI.

Summary

Adds an unsafe auto-fix to the useConsistentMethodSignatures rule, which was
left open in #8786.

Closes #8780.

The fix converts between method-style and property-style signatures depending
on the configured style option:

  • method → property (default): method(arg: string): voidmethod: (arg: string) => void
  • property → method (style: "method"): method: (arg: string) => voidmethod(arg: string): void

The fix is intentionally skipped in cases where conversion would be unsafe:

  • Overloaded methods: converting multiple signatures with the same name would
    require generating intersection types (e.g. ((x: string) => void) & ((x: number) => void)).
  • readonly properties: methods cannot have a readonly modifier.

Test Plan

Existing snapshot tests were updated to include the fix output. All spec tests pass:

cargo test -p biome_js_analyze use_consistent_method_signatures

Docs

No new options were added. Documentation is already present in the rule's inline rustdoc from #8786.

ViniciusDev26 and others added 2 commits March 18, 2026 12:55
Implements the `action()` method for the `useConsistentMethodSignatures`
rule, enabling automatic conversion between method-style and
property-style signatures.

- method → property: `method(arg: T): U` → `method: (arg: T) => U`
- property → method: `prop: (arg: T) => U` → `prop(arg: T): U`

Fixes are skipped when conversion is not safe: overloaded methods
(would require intersection types) and readonly properties (methods
cannot be readonly).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@changeset-bot
Copy link

changeset-bot bot commented Mar 18, 2026

🦋 Changeset detected

Latest commit: 7e7f67c

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 Mar 18, 2026
@ViniciusDev26 ViniciusDev26 changed the title Feat/apply fix to use consistent method signatures feat: apply fix to use consistent method signatures Mar 18, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 18, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ce7903bc-6375-4cce-b3e9-244d35d74034

📥 Commits

Reviewing files that changed from the base of the PR and between 1c27cf3 and feb8cfd.

⛔ 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 (1)
  • crates/biome_js_analyze/src/lint/nursery/use_consistent_method_signatures.rs

Walkthrough

This PR adds an unsafe autofix for the useConsistentMethodSignatures lint: marks the rule FixKind::Unsafe, implements action for UseConsistentMethodSignatures, and introduces bidirectional conversion helpers (method_to_property, property_to_method) plus overload detection to avoid converting overloaded methods. The fixer replaces the AST node in a single mutation and reports the target style in its message. A changeset entry declaring the fix as unsafe was added.

Possibly related PRs

Suggested labels

A-Diagnostic

Suggested reviewers

  • ematipico
  • dyc3
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: apply fix to use consistent method signatures' directly describes the main change—adding an auto-fix to the rule implementation.
Description check ✅ Passed The description clearly explains the changeset: adding an unsafe auto-fix to useConsistentMethodSignatures, method↔property conversion logic, and edge cases handled.
Linked Issues check ✅ Passed The PR fully implements the objectives from #8780: adds an auto-fix for the rule with bidirectional conversion logic, handles unsafe cases (overloads and readonly), and integrates with the existing rule.
Out of Scope Changes check ✅ Passed All changes are directly scoped to implementing the auto-fix for useConsistentMethodSignatures; the changeset file and lint rule modifications align with the stated objective.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

Tip

You can make CodeRabbit's review stricter and more nitpicky using the `assertive` profile, if that's what you prefer.

Change the reviews.profile setting to assertive to make CodeRabbit's nitpick more issues in your PRs.

@codspeed-hq
Copy link

codspeed-hq bot commented Mar 18, 2026

Merging this PR will not alter performance

✅ 58 untouched benchmarks
⏩ 159 skipped benchmarks1


Comparing ViniciusDev26:feat/apply-fix-to-useConsistentMethodSignatures (7e7f67c) with main (956e367)2

Open in CodSpeed

Footnotes

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

  2. No successful run was found on main (8a3647b) during the generation of this report, so 956e367 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

ViniciusDev26 and others added 2 commits March 20, 2026 13:07
- Remove `issue_number` field (resolved by the PR itself)
- Rename `inner` helper to `check_method_overloads` for clarity

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ViniciusDev26 ViniciusDev26 requested a review from dyc3 March 20, 2026 16:08
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.

looks good, ci has failures

Remove outdated "actively worked on" notice from test snapshots.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@dyc3 dyc3 merged commit 723798b into biomejs:main Mar 22, 2026
19 checks passed
@github-actions github-actions bot mentioned this pull request Mar 22, 2026
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.

📎 Add code fix for useConsistentMethodSignatures

2 participants