Skip to content
Fallow home
All docs pages

Docs home

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

FactValue
Issue typeunused-class-member
Rule id in SARIF outputfallow/unused-class-member
Commandfallow dead-code
Default severityerror
Config key in rulesunused-class-members
Filter option--unused-class-members
Suppression comment// fallow-ignore-next-line unused-class-member
Fixable with fallow fixNo
Opt-inNo

When to keep the code

Notes

  • The rule checks public members. A private member is not checked, and Unused protected class members checks protected members.
  • A use through this inside 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 in ignoreDecorators.
  • 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) counts ionViewWillEnter, ionViewDidEnter, ionViewWillLeave and ionViewDidLeave as 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 or for...in, fallow counts each member as used.
  • A Playwright test that test.extend<T>() or mergeTests(...).extend<T>() makes from @playwright/test uses the members of each fixture class that the test reads.