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 start by exploring the repository structure and locating the unused-class-members / Svelte template handling code.
- Assistant
I'll inspect unused-class-members analysis and how Svelte templates credit member usage.
- Assistant
rg is not found, let me use grep instead.
- Assistant
Looking at unused members analysis and Vue/Angular/Svelte framework tests next.
- Assistant
Let me look at how Svelte and Vue templates handle member accesses.
- Assistant
Let me search for where Svelte templates are parsed and how member accesses are extracted.
- Assistant
There's an extract.rs - that's likely where the parsing happens. Also external_style_usage. Let me explore extract.
- Assistant
extract.rs is a file, not a directory. Let me look at its contents related to Svelte.
- Assistant
There's a larger extraction module elsewhere. Let me find where the actual AST extraction happens.
- Assistant
There's a crates/extract directory. Let me explore that.
- Assistant
Perfect - there's sfc_template/svelte.rs and Vue/angular templates. Let me compare how they handle member accesses.
- Assistant
I'll inspect bound_targets and Vue member expression handling next.
- Assistant
There's already a test for bound-target member access. I'll read that and the shared merge logic.
- Assistant
Template scanner may already handle this — checking SFC bound_targets wiring and unused-class-members integration.
- Assistant
Let me look at how template_visible_bound_targets is populated and how member access mapping works.
- Assistant
I'll check binding_target_names and member-access rewriting next.
- Assistant
I'll read how analyze_template_snippet_with_bound_targets handles member expressions, and check related tests.
- Assistant
There's already a Vue test for this — I'll check whether a Svelte equivalent exists and inspect the fixtures.
- Assistant
There's already a Svelte class-member test — checking the fixture and how hister's ResultState pattern differs.
- Assistant
I'll check binding_target_names and changelog entries for this false positive pattern.
- Assistant
Inspecting decisions and whether typed props / $state bindings are tracked.
- Assistant
There's an
exported-instance-class-membersfixture — that may match the hister pattern. - Assistant
Checking INSTANCE_EXPORT_SENTINEL and how exported instances map to class members.
- Assistant
I'll inspect how member accesses on imported identifiers are resolved in unused_members.
- Assistant
I'll build fallow and craft a minimal Svelte repro of the reported false positive.
- Assistant
I'll build and run the existing Svelte bound-member tests to see current behavior.
- Assistant
I'll check whether typed
export let/$props()bindings are recorded as bound targets. - Assistant
Let me look at where record_typed_binding is called for variable declarators.
- Assistant
I'll write a quick extraction probe covering prop-typed and imported-instance Svelte patterns.
- Assistant
I'll create a temporary fixture and run analysis against several candidate patterns.
- Assistant
Now let me run fallow on this repro.
- Assistant
Need to check the CLI usage.
- Assistant
Need a cwd option.
- Assistant
Let me run with --root
- Assistant
The typed
export letpattern works. Trying more variants without type annotations and with different binding shapes. - Assistant
Found it: Svelte 5
$props()destructuring loses typed bindings. Checking nested type support and props patterns. - Assistant
Let me read extract_nested_type_bindings and understand how $props handwriting should work. Also check if there's existing handling for object pattern typed bindings.
- Assistant
$state(new Class())is a common Svelte 5 pattern and fails — checking wrappers like$stateand factory helpers. - Assistant
Searching for state handling and related TODOs.
- Assistant
Looking at factory and wrapper extraction helpers for patterns we can extend.
- Assistant
Let me focus. The issue description says:I understand the issue you're describing—Svelte template member expressions like
resultState.pin(...)aren't currently credited as "used" for class methods when the receiver is a destructured prop or$staterune. That's a clear gap compared to Vue/Angular. - Assistant
Looking at Playwright type-alias shape capture for a similar approach.
- Assistant
Checking Svelte 5
$props<T>()type-argument form as well. - Assistant
I'll check bare method references and other event-handler shapes.
- Assistant
Checking whether type-only imports resolve in local_to_export_keys (needed for typed props).
- Assistant
Inspecting resolve_bound_member_accesses and where to add destructure handling.
- Assistant
I'll implement typed
$propsdestructuring and$state(new Class())binding resolution. - Assistant
Checking merge_into for finalize hooks used by SFC scripts.
- Assistant
Implementing the fix: reading key visitor sections, then applying code changes.
- Assistant
Implementing typed object-destructure bindings and Svelte rune unwrapping.
- Assistant
I'll add the PendingDestructureBinding struct and object_type_shapes field, then implement resolution.
- Assistant
Adding the new fields next to playwright fixture state.
- Assistant
Let me open around line 185-210.
- Assistant
I'll add object_type_shapes and pending_destructure_type_bindings after playwright_fixture_types.
- Assistant
I'll add the resolve function and wire it into finalize next.
- Assistant
Let me open around 648-720 and the finalize calls.
- Assistant
I'll insert resolve_pending_destructure_type_bindings after resolve_factory_call_candidates.
- Assistant
Wiring resolve into finalize paths and making them callable before template bound-target seeding.
- Assistant
I'll add resolve_pending destructure to both finalize paths and add a public method for SFC.
- Assistant
Need to add to merge_into as well. Also add a method that finalizes target bindings for SFC template reading.
- Assistant
Exposing the resolve method and calling it from SFC before reading bound targets.
- Assistant
Now update sfc.rs to call resolve before reading bound targets.
- Assistant
I'll add the resolve call before reading bound targets.
- Assistant
I'll look at ObjectPattern property structures and implement the visitor handlers.
- Assistant
Need to fix quoting.
- Assistant
Let me look at BindingProperty in oxc.
- Assistant
Read those lines.
- Assistant
Look at BindingPattern - is it BindingPatternKind interceptor?
- Assistant
Interesting - BindingPattern is the enum_directly (not BindingPattern with kind). But earlier code uses declarator.id which isuzzo BindingPattern with type_annotation. Letme check VariableDeclarator.
- Assistant
Implementing core helpers and visitor logic.
- Assistant
I'll add helpers near extract_nested type_bindings.
- Assistant
I'll add helperfunctions after collect_nested_type_bindings.
- Assistant
I introduced some typos — cleaning those up now.
- Assistant
There's a double closing brace at 741-743. Let me fix the whole broken section properly.
- Assistant
Still need to check the rest of the broken code.
- Assistant
I need to check the Argument enum for oxc and fix the and broken documentation for extract_class_instance_bindings.
- Assistant
Need to add ObjectPattern to imports and fix broken functions. Let me check Argument enum.
- Assistant
Argument inherits Expression, so Argument::NewExpression works and also there's probably no Argument::Expression. Let me look at how other code matches Argument.
- Assistant
So Argument::NewExpression should work. Let me fix the broken try_extract_wrapped_new_class and docstring, and add ObjectPattern to imports.
- Assistant
I accidentally broke the imports. Let me fix the whole top of the file.
- Assistant
The helpers file is messy — restoring it and applying a clean patch.
- Assistant
Good, restored. NowI'll use a Python script to insert cleanly.
- Assistant
Now updating visit_impl with the new binding handlers.
- Assistant
Update imports and add methods / change visit_variable_declaration.
- Assistant
Adding methods on the extractor next to record_typed_binding.
- Assistant
I'll insert methods after record_typed_binding.
- Assistant
I'll fix the helper name and import extract_type_reference_name.
- Assistant
Updating visit_variable_declaration and type shape recording.
- Assistant
Checking for other type-alias/interface declaration paths, then compiling.
- Assistant
There's only one module-scope Declaration path. But there might be export default interface. And exported interface via ExportNamedDeclaration.
- Assistant
Extract tests passed. Now rebuilding the CLI and re-testing the repro.
- Assistant
Three props patterns work. Fixing the type-arg typo and testing
$state. - Assistant
All target cases pass. Bumping the cache version and running existing related tests (withoutadding permanent tests).
- Assistant
cargo test only takes one filter.
- Assistant
Running a broader related test set and checking git diff cleanliness.
- Assistant
Verifying export-interface shapes and running cache/SFC integration tests.
- Assistant
Checking for hardcoded CACHE_VERSION references in tests.
- Assistant
Reviewing the final diff for quality.
- Assistant
Running clippy on the touched crate quickly before submit.
- Assistant
Fixing the three clippy errors.
- Assistant
Fixing collapsible-if and field naming clippy lints.
- Assistant
Clippy is clean. Doing one final end-to-end verification, then submitting.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.