unused-class-members FP: methods called only from Svelte <template> member expressions…
- User
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.
- Assistant
Investigating how Fallow tracks template member access in Svelte vs Vue/Angular, and where unused-class-members are detected.
- Assistant
Checking the hister repro and how
ResultStateis bound in script. - Assistant
Implementing typed
$props()destructuring so props likeresultState: ResultStatepopulatebinding_target_namesfor template member-access tracking. - Assistant
Implementing the fix: adding helper functions and visitor logic.
- Assistant
Adding an integration test and bumping the cache version.
- Assistant
Fixed. The Svelte template scanner already remapped member expressions like
resultState.pin()whenresultStatewas inbound_targets— but Svelte 5$props()destructuring never seeded that map.Root cause:
let { resultState }: Props = $props()uses anObjectPatternwith a type annotation. The visitor only handledBindingIdentifierpatterns (const x: Foo), soresultStatenever gotresultState → ResultStateinbinding_target_names, and template calls were invisible tounused-class-members.Fix: During extraction we now:
- Index structural types from
interface/ objecttypealiases (Props.resultState → ResultState) - On typed object destructuring, map each destructured local to its property’s class type
- Feed those into the existing Svelte template
bound_targetspipeline (same as Vue/new Counter())
Tests added in
crates/extract/src/tests/sfc.rsmirroring the hister pattern (interface Props+$props()+ / ). Verified on — no false positives on , , , . bumped to 103. - Index structural types from
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.