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
Let me set up a proper fixture in the actual tests/fixtures directory and write a temp test to run against it.
Assistant
Now let's write a temporary test file to run this fixture through the analyzer.
Assistant
ObjectPatternandoxc_ast::ast::*wildcard import means it's already accessible. Let's add the code.Assistant
Now let's add the new method right after
record_typed_binding:Assistant
Now let's hook it into
visit_variable_declaration:Assistant
Now let's check
PropertyKey::static_name()return type to fix the.as_ref()call correctly.Assistant
Good, returns
Cow<str>, so.as_ref()works for&strconversion viaCow<str>: AsRef<str>. Let's build now.Assistant
Builds fine. Now let's run the reproduction test again.
Assistant
Fixed the destructured props case. Now let's also check the
$props<{...}>()generic type argument form, and verify renamed destructuring works too.Assistant
Let's add a new field for named object type declarations (interfaces/type-aliases).
Assistant
Now update the import list and the
record_destructured_typed_bindingsfunction to consultnamed_object_type_bindingsfor plain type references.Assistant
Now update
record_destructured_typed_bindingsto also try resolving via a named interface/type-alias when the annotation is a plain type reference:Assistant
Builds. Now let's re-run the interface test scenario.
Assistant
The
interface Propspattern now works too. Let's test thetype Props = {...}alias variant as well, and confirm the original repro variants still work.Assistant
All variants work now. Let's also verify the original simple
export letcases still work and check thatunusedstill correctly detects genuinely-unused methods (regression safety).Assistant
Now let's run the broader test suites for extract and core crates to check for regressions.
Assistant
All extract tests pass. Now let's run the full core test suite.
Assistant
All 524 core tests pass, including the new test. Now let's also run the full workspace test suite to be thorough, then clean up temporary files.
Assistant
Confirmed this failure pre-exists (unrelated to our change, likely due to running as root bypassing read-only permission checks). Let's continue running the rest of the workspace tests, skipping this pre-existing failure.
Assistant
All tests pass except the pre-existing unrelated failure (confirmed above to fail on the unmodified base too, likely due to running as root). Now let's clean up my temporary test scaffolding since we shouldn't add new tests to the repo per instructions, but keep the actual source fix.
Assistant
Now let's re-run the extract and core test suites to make sure everything's still fine after removing the temp test.
Assistant
All good. Let's also run clippy to be safe given the strict lint setup used in this repo.
Assistant
Clean, no clippy warnings with
-D warnings. Now let's view the final diff to review everything.Assistant
Formatting fixed. Let's rebuild and re-run tests to make sure formatting changes didn't break anything.
Assistant
All good. Let's do a final review of the diff and status.
Assistant
The workspace is clean, only the intended source-level fix remains (no leftover test/fixture files). Let's go through the checklist.
Checklist Review
- If an error was reported in the issue description, I have successfully reproduced it.
Yes. I built a minimal Svelte fixture where a parent component instantiates
new ResultState()and passes it as an untyped prop to a child (ResultActionsMenu.svelte), matching the hister repo's pattern. I confirmed that withexport let resultState: ResultState;(typed prop identifier), things already worked — but with Svelte 5 runes-style destructured props (let { resultState } = $props();, with type given either inline, via atype Props = {...}alias, or via aninterface Props {...}), the class member (ResultState.pin) was incorrectly flagged as unused. This is the realistic shape of the false positive since Svelte 5 runes props destructuring is the modern idiom.
- If an error was reported in the issue description, I have successfully reproduced it.
Yes. I built a minimal Svelte fixture where a parent component instantiates
Assistant
-
If an error was reported in the issue description, I have confirmed that my fix resolves the error. Yes. After adding:
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.