Skip to content

feat(lint): support class methods, object methods, and getters in noMisleadingReturnType#9873

Merged
dyc3 merged 7 commits intobiomejs:mainfrom
minseong0324:feat/no-misleading-return-type-class-methods
Apr 11, 2026
Merged

feat(lint): support class methods, object methods, and getters in noMisleadingReturnType#9873
dyc3 merged 7 commits intobiomejs:mainfrom
minseong0324:feat/no-misleading-return-type-class-methods

Conversation

@minseong0324
Copy link
Copy Markdown
Contributor

I used Claude Code to assist with this implementation.

Summary

Addresses items from #9810: extends noMisleadingReturnType to class methods, object methods, class getters, and object getters.

Adds type_of_member to TypedService and find_member_type to Type for member-level type lookup. Skips generators and class method overloads.

Test Plan

Snapshot tests.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 9, 2026

🦋 Changeset detected

Latest commit: e91972f

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 A-Type-Inference Area: type inference labels Apr 9, 2026
@minseong0324 minseong0324 marked this pull request as ready for review April 9, 2026 00:54
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 9, 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: 1644b8f4-55fb-4c50-a1eb-9c80a97b40a6

📥 Commits

Reviewing files that changed from the base of the PR and between f2a0778 and e91972f.

📒 Files selected for processing (1)
  • .changeset/loose-adults-show.md
✅ Files skipped from review due to trivial changes (1)
  • .changeset/loose-adults-show.md

Walkthrough

This PR extends the no_misleading_return_type lint to cover class and object methods and getters (in addition to free functions). It introduces a AnyFunctionLikeWithReturnType node-union, refactors the rule to dispatch per node kind and share return-type vs return-expression checks via new helpers, skips generator methods and overload implementations, adds member-name resolution, implements TypedService::type_of_member and Type::find_member_type, and updates tests and a changeset.

Possibly related PRs

Suggested labels

A-Diagnostic

Suggested reviewers

  • ematipico
  • dyc3
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main change: extending noMisleadingReturnType to support class methods, object methods, and getters.
Description check ✅ Passed The description is clearly related to the changeset, referencing issue #9810 and explaining the additions to TypedService and Type, plus the test strategy.

✏️ 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.

Copy link
Copy Markdown
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.

🧹 Nitpick comments (1)
crates/biome_js_analyze/src/lint/nursery/no_misleading_return_type.rs (1)

101-101: Computed property names are silently skipped.

Using as_js_literal_member_name() means methods with computed names (e.g., [Symbol.iterator]() or ["getStatus"]()) won't be analysed. This is probably fine as a deliberate scope limitation, but worth documenting if not already covered.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/biome_js_analyze/src/lint/nursery/no_misleading_return_type.rs` at
line 101, The code silently skips methods with computed names because it calls
method.name().ok()?.as_js_literal_member_name() when computing let name = ...,
so either document this deliberate limitation or extend the logic to handle
computed property names: update the lookup around
method.name()/as_js_literal_member_name() to detect computed names (check
method.name() variants), resolve their string/symbol form (or fallback to a
synthetic representation) and use that for analysis, or add a clear
comment/docstring near this code (referencing method.name(),
as_js_literal_member_name(), and the let name assignment) stating that computed
property names are intentionally excluded.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@crates/biome_js_analyze/src/lint/nursery/no_misleading_return_type.rs`:
- Line 101: The code silently skips methods with computed names because it calls
method.name().ok()?.as_js_literal_member_name() when computing let name = ...,
so either document this deliberate limitation or extend the logic to handle
computed property names: update the lookup around
method.name()/as_js_literal_member_name() to detect computed names (check
method.name() variants), resolve their string/symbol form (or fallback to a
synthetic representation) and use that for analysis, or add a clear
comment/docstring near this code (referencing method.name(),
as_js_literal_member_name(), and the let name assignment) stating that computed
property names are intentionally excluded.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8632f519-16c6-4997-966d-5e494b2dd3cd

📥 Commits

Reviewing files that changed from the base of the PR and between ccf9770 and c7b182b.

⛔ Files ignored due to path filters (2)
  • crates/biome_js_analyze/tests/specs/nursery/noMisleadingReturnType/invalid.ts.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noMisleadingReturnType/valid.ts.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (5)
  • crates/biome_js_analyze/src/lint/nursery/no_misleading_return_type.rs
  • crates/biome_js_analyze/src/services/typed.rs
  • crates/biome_js_analyze/tests/specs/nursery/noMisleadingReturnType/invalid.ts
  • crates/biome_js_analyze/tests/specs/nursery/noMisleadingReturnType/valid.ts
  • crates/biome_js_type_info/src/type.rs

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 9, 2026

Merging this PR will not alter performance

✅ 58 untouched benchmarks
⏩ 196 skipped benchmarks1


Comparing minseong0324:feat/no-misleading-return-type-class-methods (e91972f) with main (e7775a5)2

Open in CodSpeed

Footnotes

  1. 196 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 (ccf9770) during the generation of this report, so e7775a5 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Copy link
Copy Markdown
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.

Needs a changeset, since the rule was released in the last patch

@minseong0324 minseong0324 force-pushed the feat/no-misleading-return-type-class-methods branch from f2a0778 to e91972f Compare April 10, 2026 23:32
@minseong0324
Copy link
Copy Markdown
Contributor Author

Needs a changeset, since the rule was released in the last patch

Added in e91972f.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Linter Area: linter A-Type-Inference Area: type inference L-JavaScript Language: JavaScript and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants