ISSUE DESCRIPTION unused-class-members FP: methods called only from Svelte <template>…
- User
ISSUE DESCRIPTION
unused-class-members FP: methods called only from Svelte member expressions False positive on 2.84.0. Class methods called only from a Svelte
<template>via a member expression (for exampleresultState.pin(...)in markup) are reported asunused-class-member. Fallow tracks template-visible identifiers but not member-expression method calls on a bound instance inside Svelte markup.Repro (2.84.0): asciimoo/hister.
ResultState.onOpen,.pin,.updateLabel, and.addSkipRuleare each invoked from.sveltetemplates (resultState.pin(...)inResultActionsMenu.svelte) yet reported unused. The repo currently setsrules.unused-class-members: "off"to work around it.Expected: credit a method called as
<local>.<method>(...)inside a Svelte<template>when<local>resolves to an instance of the class, parallel to the existing Vue/Angular template member-access tracking.Interface
No new interfaces are introduced.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- Assistant
I’ll trace the existing template-member tracking for Vue/Angular and Svelte parser/visitor paths, reproduce or locate the relevant tests, then implement the smallest parallel change. I’ll run focused tests and inspect the final diff before submitting.
- Assistant
The extraction pipeline already has the intended bound-target mechanism and Svelte-specific tests for arrow-function member calls. I’m checking whether the reported direct-call shape is lost by Svelte attribute parsing or by downstream class-member resolution; the fix should preserve existing shadowing and only credit statically resolvable instance receivers.
- Assistant
The focused extraction test showed direct Svelte member calls are already correctly remapped when the instance target is known. The missing shape is a Svelte 5 rune initializer (
$state(new ResultState())): the visitor only recognized a barenewinitializer, so template calls had no bound target and were discarded. I added conservative wrapper recognition for directnewarguments (excluding built-ins), formatted the code, and ran all 256 SFC-template tests successfully. - Assistant
Checklist review:
- Reproduced the reported extraction shape with temporary focused tests; direct calls worked with known targets, and the missing Svelte rune-wrapped instance shape was identified.
- Confirmed the fix by running the complete SFC-template suite (256 tests) and the SFC integration tests (17 tests), all passing.
- Considered edge cases: only direct
new Class()arguments are recognized, built-in constructors are excluded, existing direct initializers and template-local shadowing remain unchanged. - Ran affected existing tests and
git diff --check; all passed. No repository tests were added or modified (temporary tests were restored).
The final change records class targets for wrapper initializers such as
$state(new ResultState()), allowing existing Svelte template member-expression remapping to creditResultStatemethods.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.