Unused class members
What an unused-class-member finding of fallow dead-code means, why it matters and how to fix it.
What it reports
Class member is never referenced.
Dead code explains how fallow finds it.
Why it matters
No code calls the member, but it stays in the public shape of the class. People keep it in step during refactors, and readers assume that some caller depends on it.
Example
class Parser has a public parseLegacy method that is never called in the project.
Fix
Remove or privatize the member. For reflection/framework lifecycle hooks, configure or suppress the intentional entry point.
Facts
| Fact | Value |
|---|---|
| Issue type | unused-class-member |
| Rule id in SARIF output | fallow/unused-class-member |
| Command | fallow dead-code |
| Default severity | error |
Config key in rules | unused-class-members |
| Filter option | --unused-class-members |
| Suppression comment | // fallow-ignore-next-line unused-class-member |
Fixable with fallow fix | No |
| Opt-in | No |
When to keep the code
- A framework calls the member at run time. Add its name to
usedClassMembers.
Notes
- The rule checks public members. A
privatemember is not checked, and Unused protected class members checksprotectedmembers. - A use through
thisinside the class counts as a use. - Fallow does not report a member with a decorator, because a framework uses it at run time. A Lit
@state()property is checked. To check members with some decorators, list those decorators inignoreDecorators. - Fallow does not report the lifecycle methods of React, Angular and custom elements. A plugin can declare the lifecycle methods that its framework calls, and fallow counts them as used while the plugin is on. For example, the Ionic plugin (
@ionic/angular) countsionViewWillEnter,ionViewDidEnter,ionViewWillLeaveandionViewDidLeaveas used. The plugin source lists the names that each plugin knows. - When the class extends another class, a call of the member in the parent class counts as a use of the override.
- When code gives an instance in a variable to
Object.keys,Object.values, a rest pattern orfor...in, fallow counts each member as used. - A Playwright test that
test.extend<T>()ormergeTests(...).extend<T>()makes from@playwright/testuses the members of each fixture class that the test reads.