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
I'll trace how Vue/Angular template member-access is credited and how Svelte templates are parsed, then add the same tracking for Svelte member expressions.
- Assistant
Confirming the issue:
$props()destructuring doesn't register typed bindings inbinding_target_names. Implementing the fix. - Assistant
Adding tests and running them:
- Assistant
Fixed. Svelte 5
$props()destructuring wasn’t registering typed instance bindings inbinding_target_names, so template calls likeresultState.pin(...)never mapped toResultState.pin.Root cause: The template scanner already remaps member accesses through
bound_targets(same path ascounter.bump()fromnew Counter()), butresultStatefrom:let { resultState }: Props = $props();was never added to
binding_target_names. Only patterns likeconst x = new Class()were tracked.Fix: In the visitor:
- Store local type shapes — interface/type-alias property→type mappings (e.g.
Props.resultState → ResultState) - Detect props destructuring —
let { ... }: Props = $props()(alsodefineProps()for Vue parity) - Register bindings — map each destructured local to its annotated class type in
binding_target_names
Template scanning then remaps
resultState.pin(...)→ResultState.pin, and the existing unused-class-member analysis credits the method.Tests added:
svelte_props_destructure_template_member_call_marks_class_member_usage— hister-stylePropsinterface +$props()svelte_props_destructure_inline_type_marks_class_member_usage— inline{ resultState: ResultState }template_member_call_maps_props_instance_to_class— template scanner unit test
All 65 Svelte template tests and 305 visitor tests pass; clippy is clean.
- Store local type shapes — interface/type-alias property→type mappings (e.g.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- fable-5Compare side by side →
- fable-5Compare side by side →