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.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /fallow, current file: none) bash-$
Assistant
Let me start by exploring the repository structure to understand what we're working with.
Assistant
This is a Rust project (oxlint-like tool called "fallow"). Let me explore the structure more.
Assistant
Let me look at the structure of the unused_members.rs file to understand how it works, particularly how Angular/Vue templates are handled.
Assistant
Let me look at the Angular template handling in unused_members.rs more carefully.
Assistant
Let me search for where ANGULAR_TPL_SENTINEL and HTML template scanners are defined.
Assistant
Let me look at the extract crate's structure and find where template scanning happens (Vue/Svelte).
Assistant
Now let me look at the svelte.rs scanner and the template_usage.rs to understand how member_accesses are collected. Let me look at the
TemplateUsagestruct.Assistant
Let me look at the svelte.rs scanner to understand
collect_template_usage_with_bound_targets.Assistant
Now let me look at sfc.rs which builds the per-SFC pipeline, and how the template usage flows into the analysis phase.
Assistant
Now let me look at
binding_target_namesin the visitor to understand what it captures.Assistant
Let me understand how binding_target_names is populated for
newexpressions.Assistant
Let me look at where
new Foo()is recorded to binding_target_names.Assistant
Let me find where
const x = new Foo()registers the binding target. Let me look at the declarations visitor where variable declarations are processed.Assistant
Now let me find where the variable declarations are processed for
const x = new Foo(). Let me search for variable declarator handling.Assistant
Let me search for where
newexpressions create binding_target_names from variable declarators.Assistant
Let me look at how member_accesses get translated into accessed_members in the analyze phase.
Assistant
Let me look at the general member access processing pipeline around line 900-1000.
Assistant
Let me find the main pipeline function that builds accessed_members from regular member accesses.
Assistant
Let me look at the Svelte scanner's merge functions in detail.
Assistant
Now let me look at the shared merge functions to see how member_accesses are emitted with bound_targets.
Assistant
Let me look at the visitor's visit_static_member_expression and member access recording to understand the guards.
Assistant
Let me check
static_member_object_namehelper.Assistant
Let me look at existing tests for Svelte member access in the analyze layer to understand the test setup.
Assistant
No svelte tests in unused_members.rs. Let me check the integration tests for svelte.
Assistant
Let me look at the sfc_parsing.rs test to understand how svelte tests are set up.
Assistant
There's an existing test
vue_template_event_handlers_mark_class_members_used. Let me look at the vue-project fixture to see how Vue handlesCounter.bump— this likely uses a bound instance similar to the Svelte case.Assistant
Let me check existing svelte fixtures and the Vue scanner's handling to compare with Svelte.
Assistant
The svelte-project fixture has
const counter = new Counter()andcounter.bump(). Let me find the existing test that checksCounter.bumpfor svelte.Assistant
Let me look at the rest of
apply_tagin svelte.rs to find the plain expression case.Assistant
Let me look at the CLI to see if I can run analyze on a fixture directly.
Assistant
Let me create a reproduction fixture mirroring the issue (a Svelte component calling a class method via a member expression in markup).
Assistant
Now let me create a temporary test to reproduce the issue.
Assistant
Let me check how the integration test module is organized - is it a single mod with submodules? Let me check the common module and how to include the temp file.
Assistant
I need to add a mod declaration for my temp test file. Let me append it.
Assistant
Now let me run the reproduction test.
Assistant
The simple reproduction passed. Let me investigate more carefully — the real scenario may differ. Let me check the git log and CHANGELOG for context, and debug what member_accesses are produced.
Assistant
The CHANGELOG confirms the local
new Counter()case was already fixed. So the gap must be a different scenario. The issue says "<local>resolves to an instance of the class" — suggesting resolution through the module graph (instance created elsewhere, imported). Let me test the imported-instance scenario.Assistant
The imported-instance case ALSO passes! So
ResultState.pinis credited even when constructed elsewhere. I need to understand the actual gap. Let me look at whereINSTANCE_EXPORT_SENTINELis emitted and how the analyze resolves exported instances.Assistant
Now I understand — the imported-instance case works via
record_exported_instance_bindings+propagate_accesses_through_instance_exports. The gap must be Svelte-specific syntax. Let me examine the Svelte scanner's attribute/event-handler handling, especiallyon:click(Svelte 4) vsonclick(Svelte 5).Assistant
Let me check whether the unused-class-members rule considers non-exported (private) classes, and test the private-class + exported-instance scenario.
Assistant
Let me re-read
apply_template_usagein sfc.rs to see when it runs and what it passes.Assistant
Let me reconsider — perhaps the real scenario uses Svelte 5 runes (
$state). Let me check whether the visitor handles$state(new ResultState()).Assistant
Let me test the Svelte 5
$staterune scenario, which the visitor doesn't capture as a bound target.Assistant
I reproduced the FP with the Svelte 5
$staterune scenario. But I need to confirm the actual hister scenario. Let me inspect the member_accesses emitted for the svelte file directly via the extract crate to understand the mechanism precisely.Assistant
Let me write a quick standalone test in the extract crate to inspect member_accesses for various svelte binding forms.
Assistant
No tests dir for extract. Let me create a test in the extract crate's existing test module, or use an example. Let me check if there's an examples dir or if I can add a
[[bin]]. Actually, the simplest is to add a#[test]in the lib.rs tests module, or create a tests dir. Let me create the tests dir with the file.Actually, let me just create the directory and the file.
Assistant
Now I have a clear picture. The gaps are:
- STATE-RUNE (
$state(new ResultState())): emits nothing —resultState.pin()not tracked. - OBJ-DESTRUCTURE-PROP (
$props()destructure with type): emits nothing.
Let me reproduce the shared-singleton scenario (state module creates instance via
$state, imported by svelte) which is likely the hister case.- STATE-RUNE (
Assistant
The
$statesingleton + import reproduces the FP. Let me look at how React factory wrappers (useState(() => new Class())) are handled, to mirror for Svelte runes.Assistant
Let me search the codebase for any reference to hister or the specific class/method names, and check a few more binding variations.
Assistant
Let me examine the Vue scanner to compare its member-access tracking with Svelte's.
Assistant
Let me check if I can access the hister repo to confirm the exact scenario.
Assistant
I have network access. Let me clone the hister repo to inspect the exact scenario.
Assistant
I found it. Let me examine the actual hister files.
Assistant
Now let me see how
resultStateis instantiated and used in the svelte files.Assistant
This is the exact scenario.
resultStateis a PROP destructured from$props()typed via an interfaceProps. Let me confirm whereResultStateis instantiated in+page.svelte.Assistant
This is the exact scenario:
resultStateis a prop typed asResultStatevia an interfaceProps, andResultStateis a type-only import inResultActionsMenu.svelte. Let me check whetherbuild_local_to_export_keysincludes type-only imports.Assistant
Let me check whether
all_resolved_importsincludes type-only imports.Assistant
Let me check whether type-only imports are included in
resolved_imports.Assistant
So type-only imports ARE pushed to resolved_imports (with
is_type_only: true). Let me confirm static imports include type-only. Let me look at the static import resolution.Assistant
Type-only imports ARE in
local_to_export_keys. So if the scanner emitsResultState.pin, the analyze phase will credit the class. The gap is thatresultState(a prop typed via interfaceProps) isn't captured inbinding_target_names. Let me check if the visitor collects interface declarations to resolve prop types.Assistant
Let me look at the visitor's finalize steps at the end of
visit_program.Assistant
The finalize steps run after
binding_target_names()is read in sfc.rs. So I need to populate the ObjectPattern bindings during the walk. Let me look atvisit_programto add a pre-scan for interface property types.Assistant
So the visitor uses the default
Visit::visit_program(no override). The walk starts atvisit_programwhich walks the body. Let me check whether there's an override somewhere. Theoxc_ast_visit::Visit::visit_programdefault walks statements. Since there's no override, the default walks the program body viavisit_statements.So to do a pre-scan, I'd need to override
visit_program. Let me check if there's an override pattern. Actually, let me look at how the visitor is implemented — is it the oxcVisittrait? Let me check.Assistant
Let me look at the
visit_declarationforTSInterfaceDeclarationandTSTypeAliasDeclaration.Assistant
Let me check the
walk::walk_programAPI and how the defaultvisit_programwalks.Assistant
I can override
visit_programto pre-scan interface/type-alias property types. Let me look at the existing type-extraction helpers.Assistant
Let me look at
extract_class_instance_bindingsand the interface body AST structure.Assistant
Let me check the oxc AST for
TSInterfaceBodyandTSSignature.Assistant
Let me verify fallow handles
.svelte.tsfiles (parses them as TS, not SFC).Assistant
is_sfc_filechecks only the last extension, so.svelte.tsis parsed as regular TS. Now let me build a fixture that exactly mirrors the hister scenario and confirm the FP reproduces BEFORE the fix.Assistant
I've reproduced the exact hister FP. Now let me implement the fix. First, let me look at the
ModuleInfoExtractorstruct fields.Assistant
Let me look at the
new()constructor and the imports in mod.rs and visit_impl.rs.Assistant
Let me check the imports in visit_impl.rs to know what AST types are available.
Assistant
I have all the context. Let me check the
BindingPropertyandPropertyKeyAST andget_binding_identifiers.Assistant
Now I have everything. Let me check
get_binding_identifierson BindingPattern. Let me confirm it exists on BindingPattern. Line 1322 is in js.rs. Let me check whatselfis there.Assistant
I have everything I need. Let me check helpers.rs imports to add the helper function.
Assistant
I have all the AST knowledge. Now let me implement the fix. First, add a helper function in helpers.rs to collect property types from a TypeScript object-type signature list.
Assistant
Now let me add the helper function after
extract_nested_type_bindings.Assistant
Let me verify the helpers.rs patch didn't duplicate.
Assistant
Good, no duplication. Now let me add the
interface_property_typesfield to the struct in mod.rs.Assistant
Let me confirm the struct derives
Defaultso the new field initializes correctly.Assistant
Good,
#[derive(Default)]so the new field initializes empty. Now let me add thevisit_programoverride with the pre-scan, and therecord_typed_destructurehandling. Let me look at thevisit_variable_declarationlocation for BindingIdentifier handling to add the ObjectPattern case right after.Assistant
Now let me add the ObjectPattern typed-binding handling right after the BindingIdentifier typed-binding block.
Assistant
Now let me add the
visit_programoverride (pre-scan) and therecord_typed_destructure+resolve_destructure_property_typesmethods. Let me addvisit_programright after theimpl Visit for ModuleInfoExtractoropening.Assistant
Now let me add the helper methods near
record_typed_binding. Let me find it.Assistant
Let me add the new methods right after
record_typed_binding(beforeresolve_class_type_param).Assistant
I referenced a helper
static_binding_identifier_name. Let me add it as a free function nearstatic_member_object_name.Assistant
Let me verify the
helpersmodule visibility and the function visibility.Assistant
Now let me build to check for compile errors.
Assistant
oxc uses its own allocator
Vec. Let me see all the errors.Assistant
Two issues: lifetime
'ain inherent methods, and theStatement::Declarationvariant name. Let me check the context ofrecord_typed_bindingand the oxcStatementenum.Assistant
Let me find the oxc
Statementenum variants.Assistant
StatementinheritsDeclarationvariants directly. Let me check how existing code matches declarations in statements.Assistant
Let me check the
Declarationenum variants to use the correct pattern.Assistant
StatementinheritsDeclarationvariants directly, and my methods are inherent (no'ain scope). Let me rewrite the methods block correctly. First let me see what I currently inserted.Assistant
Let me rewrite the methods block. First, get exact line numbers.
Assistant
Now let me replace the whole block (lines 848-950) with corrected code:
Assistant
Now let me build to check for remaining errors.
Assistant
It compiled. Now let me run the repro test to confirm the fix resolves the FP.
Assistant
The fix works. Now let me verify against the real hister repo. Let me check its fallow config and run fallow on it.
Assistant
The hister config disables the rule. Let me build the CLI and run fallow on hister with the rule enabled to verify the real-world fix.
Assistant
Let me check how to override a rule via the CLI, or just temporarily enable the rule in hister's config.
Assistant
Let me temporarily enable the rule in hister's config and run fallow to check for the ResultState FP.
Assistant
With the fix, hister has only 1 unused class member total and NO
ResultStatefindings. Let me confirm what that 1 finding is and that no ResultState members appear.Assistant
Let me check the actual field name and that 1 finding (if any) to confirm it's not a ResultState FP.
Assistant
The only finding is
WebSocketManager.isOpen(unrelated to ResultState). Let me verify this finding is NOT newly introduced by my change by comparing against the unfixed version.Assistant
Interesting — with the original code, hister reports only
WebSocketManager.isOpen, NOT ResultState methods. Let me investigate why. Let me check if+page.sveltecalls the methods directly (crediting them via another path).Assistant
Let me check the original-code output for any
result-statefindings (unused file/export) which would skip member analysis.Assistant
No result-state findings at all in original code — so the original code IS crediting them somehow. Let me find all template calls to these methods across hister.
Assistant
Let me check whether
$libimports resolve in hister (if unresolved,ResultStateexport has no references and member analysis is skipped).Assistant
The original code doesn't reproduce the FP on hister HEAD — it credits the methods somehow. Let me restore my fix and investigate the exact credit path by inspecting the actual hister files' extraction.
Assistant
Let me update my inspect test to read the actual hister files and print member_accesses, to find the credit path.
Assistant
The original code emits nothing for
resultState.Xin ResultActionsMenu, yet doesn't report them. So member analysis must be skipped or they're credited. Let me add a temporary debug in the analyze phase to see what happens for the ResultState export.Assistant
No DEBUG output — so the module is either skipped early (entry point/unreachable) or not in the analyzed set. Let me add an earlier debug.
Assistant
Still no DEBUG output. Let me check the full stderr and whether result-state.svelte.ts is even discovered.
Assistant
Key finding: hister's
.svelte-kit/tsconfig.jsonis missing (repo not built), so the$libalias is broken andresult-state.svelte.tsis unreachable — that's why no findings. Let me check how the SvelteKit plugin maps$lib.Assistant
The SvelteKit plugin maps
$lib->src/lib, but it only activates when@sveltejs/kitis found (no node_modules here). Let me force-enable it via config and re-verify on hister.Assistant
Let me check how plugins activate (from package.json deps or node_modules) and whether hister's app declares
@sveltejs/kit.Assistant
Let me check whether
.svelte.tsfiles are discovered at all in hister, and inspect thelist filesoutput for the lib directory.Assistant
list filesreturns 0 (different output). Let me check active plugins and whether$libresolves for hister.Assistant
The hister environment can't fully resolve
$libhere, but my fixture faithfully mirrors hister's exact code structure and confirms the fix. Let me now remove the debug code I added to unused_members.rs.Assistant
Let me try to make hister's
$libresolve so I can do a real-world verification. Let me check hister's tsconfig setup.Assistant
Let me check the
listcommand usage and whether the SvelteKit plugin activates for hister.Assistant
list --filesshows result-state.svelte.ts IS discovered. Let me re-add a focused debug and run with the FIXED code to see whether ResultState's members are credited (accessed_members) or analysis is skipped.Assistant
With the fix, ResultState's methods (
onOpen,pin,updateLabel,addSkipRule) ARE inaccessed_members! Let me confirm the original code does NOT credit them (the FP) by running with the stashed original.Assistant
The stash reverted the debug too. Let me revert only the extract files to original (keeping the core debug) to compare accessed_members with the original code.
Assistant
Surprising — the ORIGINAL code ALSO credits the methods on hister! So the FP doesn't reproduce on current hister HEAD. Let me find the credit path. Let me inspect
+page.svelte's member_accesses.Assistant
The original code credits the methods via some path my fixture lacks. Let me find all
ResultState.static accesses and method calls across hister.Assistant
The original code credits the methods on hister via some path my fixture lacks. Let me find which access contributes by adding a debug in the main
accessed_members-building loop.Assistant
Let me find the main loop that builds accessed_members from member_accesses (the one with
local_to_export_keys.get(access.object.as_str())). That's around line 1530-1575. Let me add a debug there that prints when an access resolves to the ResultState export key.Actually, let me find the ResultState export key's file_id first. The result-state.svelte.ts file_id. I can't easily know it. Let me instead print, for each access where the object resolves to an export whose name is "ResultState" AND the file path contains "result-state", the source module path and the access.
Let me find the main loop.
Assistant
The full analysis shows ResultActionsMenu emits
object=ResultStateeven with original extract code — but my single-file inspect test showed nothing. Let me check whetherparse_source_to_moduleruns the SFCapply_template_usagepipeline differently.Assistant
The single-file inspect and full analysis disagree. Let me re-run the ResultActionsMenu inspect with the current (original-extract) code to recheck.
Assistant
The discrepancy is likely a stale cache (my fix didn't bump
CACHE_VERSION, so the original-code run read cached FIXED results). Let me find and clear the cache, then re-run with original extract.Assistant
There's a cache at
/tmp/hister/.fallow/cache.bin. Let me clear it and re-run with original extract.Assistant
The FP IS reproduced on hister with original code + clean cache (
accessed=None, methods reported unused). My earlier "no FP" was stale cache. Now I need to re-apply my extract fix (I discarded it withgit checkout). Let me verify current state and re-apply.Assistant
Let me revert the core debug, then re-apply the extract fix cleanly.
Assistant
Now let me re-apply the extract fix. First, the helper function in helpers.rs.
Assistant
Now re-apply the visit_impl.rs changes:
visit_programoverride, therecord_typed_destructurecall, the helper methods, andstatic_binding_identifier_name.Assistant
Compiled. Let me run my repro test to confirm the fix works again.
Assistant
Now let me rebuild the CLI and verify on hister with a clean cache (the definitive real-world test).
Assistant
The fix resolves the real-world hister FP (only
WebSocketManager.isOpenremains). Now I must bump the extraction cache version so warm caches re-extract. Let me find theCACHE_VERSION.Assistant
Let me check for tests that assert the cache version value, which the bump might affect.
Assistant
No test asserts the exact value. Let me build everything and run the cache tests + relevant extract tests.
Assistant
All 1638 extract lib tests pass. Let me run the relevant core integration tests (sfc_parsing, angular_template_members, member_detection).
Assistant
All pass. Now let me run the full core integration test suite to ensure no regressions.
Assistant
All 524 core integration tests pass. Let me run the CLI snapshot tests (they may reflect changed unused-class-member output) and graph tests.
Assistant
One CLI test failed (
fix_batch_aborts_when_a_target_directory_is_read_only) — likely environment-related (running as root makes "read-only" dirs writable). Let me verify it fails WITHOUT my changes too.Assistant
The read-only test fails without my changes too (pre-existing, root-related). Let me confirm the snapshot/check tests pass (they cover unused-class-member output).
Assistant
All snapshot/check tests pass. Let me run the graph crate tests too, since the extract change feeds into the graph.
Assistant
Let me run the extract cache tests (since I bumped the cache version).
Assistant
All tests pass (the one CLI failure is pre-existing and root-related). The fix is verified on both my fixture and the real hister repo. Now let me clean up all temporary test files and fixtures. First, remove the temp mod from integration_test.rs.
Assistant
Let me verify integration_test.rs is back to its original state (only the temp mod was added).
Assistant
Let me revert integration_test.rs to its original state (it shouldn't be modified).
Assistant
Let me confirm no untracked/temp files remain.
Assistant
Clean — only the 4 source files are modified. Let me do a final review of the complete diff.
Assistant
The diff is clean and correct. Let me run the core lib unit tests to be thorough.
Assistant
All 2415 core lib tests pass. Let me check the CHANGELOG structure to add a consistent entry for this fix.
Assistant
Let me add a CHANGELOG entry under the
[Unreleased] / ### Fixedsection, consistent with the repo's style.Assistant
Let me do a final build and re-verify on hister with a clean cache.
Assistant
The fix is confirmed on the real hister repo. Let me restore hister's config (I temporarily modified it) and do a final check of the complete diff.
Assistant
All clean. Let me run clippy to ensure no lint warnings (the repo uses strict clippy settings).
Assistant
No clippy warnings. Let me verify the CHANGELOG diff is well-formed.
Assistant
The CHANGELOG entry is well-formed. Let me do a final full workspace build and a combined test run of the affected crates to confirm everything is green.
Assistant
All green (workspace builds; extract lib 1638 passed; core integration 523 passed — back to original count after removing the temp test). Let me do a final review of the helpers.rs and mod.rs diffs.
Assistant
Everything is clean and correct. Let me do a final status check before submitting.
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
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →