Skip to content

fix(no-base-to-string): handle overloaded toString declarations#779

Merged
graphite-app[bot] merged 1 commit intomainfrom
c/03-09-fix_no-base-to-string_handle_overloaded_tostring_declarations
Mar 10, 2026
Merged

fix(no-base-to-string): handle overloaded toString declarations#779
graphite-app[bot] merged 1 commit intomainfrom
c/03-09-fix_no-base-to-string_handle_overloaded_tostring_declarations

Conversation

@camc314
Copy link
Copy Markdown
Contributor

@camc314 camc314 commented Mar 9, 2026

Copilot AI review requested due to automatic review settings March 9, 2026 22:34
Copy link
Copy Markdown
Contributor Author

camc314 commented Mar 9, 2026


How to use the Graphite Merge Queue

Add the label 0-merge to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes the no-base-to-string lint rule to correctly handle types with overloaded toString (or toLocaleString/valueOf) declarations, preventing both false positives (flagging types that have a user-defined overloaded toString) and false negatives (not flagging synthesized mapped-type properties with zero declarations).

Changes:

  • Replaced the single-pass toString/toLocaleString check (which incorrectly returned usefulnessAlways for any symbol with a declaration count ≠ 1) with a loop over ["toString", "toLocaleString", "valueOf"] that correctly distinguishes user-defined declarations from Object-only declarations.
  • Added two new valid test cases (overloaded class toString and overloaded ambient module function toString) and one new invalid test case (synthesized mapped-type toString with no declarations).
  • Updated the test snapshot to include the new diagnostic for the mapped-type test case.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
internal/rules/no_base_to_string/no_base_to_string.go Core logic rewrite: iterates over toString, toLocaleString, and valueOf; skips synthesized (zero-declaration) properties; uses utils.Some to detect any non-Object declaration
internal/rules/no_base_to_string/no_base_to_string_test.go New valid cases for overloaded toString; new invalid case for mapped type with zero declarations
internal/rule_tester/__snapshots__/no-base-to-string.snap Snapshot updated to include the new invalid-87 diagnostic

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@camc314 camc314 self-assigned this Mar 10, 2026
Copy link
Copy Markdown
Contributor Author

camc314 commented Mar 10, 2026

Merge activity

@graphite-app graphite-app bot force-pushed the c/03-09-fix_no-base-to-string_handle_overloaded_tostring_declarations branch from 71f2de7 to b4f666b Compare March 10, 2026 11:52
@graphite-app graphite-app bot merged commit b4f666b into main Mar 10, 2026
8 checks passed
@graphite-app graphite-app bot deleted the c/03-09-fix_no-base-to-string_handle_overloaded_tostring_declarations branch March 10, 2026 12:00
@graphite-app graphite-app bot removed the 0-merge label Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants