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.
Assistant
Now let's write a temporary test to run the analysis pipeline on this fixture.
Assistant
Now let's look at the
extract_type_annotation_nameandTSTypehandling helpers to plan the TSTypeReference detection.Assistant
Now let's refactor
collect_nested_type_bindingsto share the signature loop, and addextract_interface_type_bindings.Assistant
Now let's add the data structures and logic in
mod.rsandvisit_impl.rs.Assistant
Now add fields to the struct:
Assistant
Now let's add the resolver method near
resolve_factory_call_candidates, and wire it up intointo_module_info,merge_into.Assistant
Now add the helper methods and hook up variable-declaration handling. Let's find
record_typed_bindinglocation to add nearby methods:Assistant
Good,
oxc_ast::ast::*wildcard import means all AST types (TSInterfaceBody, TSInterfaceDeclaration, TSTypeAliasDeclaration, ObjectPattern) are already in scope. Let's add the needed helper imports and new methods.Assistant
Now add the two
record_named_type_literal_properties_from_*methods andrecord_destructured_typed_bindingmethod afterrecord_typed_binding:Assistant
Now let's hook this into
visit_variable_declaration:Assistant
Now wire into
into_module_infoandmerge_into:Assistant
Now update
sfc.rsto call this resolver before readingbinding_target_names():Assistant
Now let's try to build.
Assistant
It builds. Now let's clean up the exploration test code and re-run our reproduction tests.
Assistant
Good, cleaned up. Now let's run the runes-based reproduction test:
Assistant
The Svelte 5 runes
$props()destructuring case now works correctly. Let's also test the inline type-literal variant for destructuring:Assistant
Excellent, the named interface variant also works now. Let's test the Vue equivalent (
defineProps<Props>()destructuring) to ensure Vue also benefits since the fix is at the generic visitor level, and also test edge cases like rename destructuring and type alias:Assistant
All edge cases work correctly. Now let's remove the exploration test and run the full test suite for extract and core crates.
Assistant
Good, svelte.rs no longer shows as modified. Now let's check
git statusagain and run the full build + test suite.Assistant
unused_class_members: 1— matches expectation (onlyunusedMethod). Let's confirm which member:Assistant
End-to-end confirmed via the CLI itself. Now let's clean up the scratch fixture and run the full existing test suites.
Assistant
Now let's run the full test suites for the affected crates.
Assistant
All 1638 tests pass. Now let's run the core crate tests as well (integration tests + unit tests).
Assistant
All 523 core tests pass. Let's also run the whole workspace test suite to be thorough (or at least the affected crates) and check clippy for lint cleanliness.
Assistant
Confirmed: this failure pre-exists on HEAD without my changes (likely environment-specific, e.g., running as root so read-only permissions don't block writes). Not related to our fix. Let's continue running the rest of the workspace tests to confirm no other regressions.
Assistant
Only the single pre-existing environment-specific failure (already confirmed present on HEAD without my changes). Everything else across the whole workspace passes. Let's run clippy to make sure the new code is lint-clean.
Assistant
No clippy warnings. Let's also check clippy on
fallow-corefor completeness (since sfc.rs is in extract, no changes there):Assistant
Clean. Now let's review the final diff for correctness and add a CHANGELOG entry consistent with repo conventions.
Assistant
Now clean, no stray trailing newline diff. Let's run
cargo fmt --checkto ensure formatting compliance.Assistant
Formatting is clean. Let's rebuild and run tests one final time to be safe.
Assistant
Clean diff. Let's also verify one more time the end-to-end scratch fixture reproduction with the freshly rebuilt CLI binary, confirming the fix.
Assistant
Only the genuinely unused method is reported, and all methods called from the Svelte template are correctly credited.
Let's finalize by going through the checklist.
Assistant
Summary
Assistant
Checklist review:
- Reproduced the reported error: Yes — built a Svelte-5-runes fixture (
$props()destructuring passing a class instance into a child component, called viaresultState.pin(...)in markup) and confirmed via both the integration-test harness and the actualfallowCLI that the methods were falsely flagged asunused-class-memberbefore the fix. - Confirmed the fix resolves it: Yes — after the change, the same fixture (in three variants: inline type literal, named
interface Props, and renamed destructuring) shows only the genuinely-unused method, verified via the CLI's JSON output. - Edge cases considered: order-independence of interface/type-alias declaration vs. destructuring use (deferred resolution), inline vs. named type annotations, property renaming (
{ resultState: rs }), and the SFC-specific ordering quirk where is read before (fixed by resolving destructured candidates earlier in ). Also confirmed the negative case (no template calls → all methods reported unused) still works, so the fix doesn't blanket-credit.
- Reproduced the reported error: Yes — built a Svelte-5-runes fixture (
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.