feat: apply fix to use consistent method signatures#9544
Conversation
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 detectedLatest commit: 7e7f67c The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
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 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (1)
WalkthroughThis PR adds an unsafe autofix for the Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment Tip You can make CodeRabbit's review stricter and more nitpicky using the `assertive` profile, if that's what you prefer.Change the |
Merging this PR will not alter performance
Comparing Footnotes
|
crates/biome_js_analyze/src/lint/nursery/use_consistent_method_signatures.rs
Outdated
Show resolved
Hide resolved
crates/biome_js_analyze/src/lint/nursery/use_consistent_method_signatures.rs
Outdated
Show resolved
Hide resolved
- 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>
dyc3
left a comment
There was a problem hiding this comment.
looks good, ci has failures
Remove outdated "actively worked on" notice from test snapshots. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary
Adds an unsafe auto-fix to the
useConsistentMethodSignaturesrule, which wasleft open in #8786.
Closes #8780.
The fix converts between method-style and property-style signatures depending
on the configured
styleoption:method(arg: string): void→method: (arg: string) => voidstyle: "method"):method: (arg: string) => void→method(arg: string): voidThe fix is intentionally skipped in cases where conversion would be unsafe:
require generating intersection types (e.g.
((x: string) => void) & ((x: number) => void)).readonlyproperties: methods cannot have areadonlymodifier.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_signaturesDocs
No new options were added. Documentation is already present in the rule's inline rustdoc from #8786.