staticMemberOnlyClasses
Reports classes that only contain static members.
✅ This rule is included in the ts logicalStrict presets.
Classes that contain only static members are essentially being used as namespaces. In JavaScript and TypeScript, objects and module-level exports are more idiomatic and straightforward.
This rule reports on any class that only contains static members.
Examples
Section titled “Examples”class MathUtils { static PI = 3.14159; static add(a: number, b: number) { return a + b; }}class Config { static defaultValue = 42; constructor() {}}class StaticAccessors { static get value() { return 42; }}class Person { name: string; constructor(name: string) { this.name = name; }}class Counter { static count = 0; value: number = 0;}class Child extends Parent { static method() {}}abstract class AbstractService { static factory() {}}class Singleton { private constructor() {} static instance = new Singleton();}@decoratorclass DecoratedClass { static method() {}}export const PI = 3.14159;export function add(a: number, b: number) { return a + b;}Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”If your codebase uses classes as namespaces for organizing related static utilities, and you don’t mind the extra complexity of classes, you may want to disable this rule. Some frameworks or patterns may also require static-only classes for specific use cases. You might consider using Flint disable comments and/or configuration file disables for those specific situations instead of completely disabling this rule.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”- Biome:
noStaticOnlyClass - ESLint:
unicorn/no-static-only-class - Oxlint:
unicorn/no-static-only-class
Made with ❤️🔥 in Boston by
Josh Goldberg and contributors.