no-static-only-class

March 27, 2026 ยท View on GitHub

๐Ÿ“ Disallow classes that only have static members.

๐Ÿ’ผ This rule is enabled in the following configs: โœ… recommended, โ˜‘๏ธ unopinionated.

๐Ÿ”ง This rule is automatically fixable by the --fix CLI option.

A class with only static members could just be an object instead.

Examples

// โŒ
class X {
	static foo = false;
	static bar() {};
}

// โœ…
const X = {
	foo: false,
	bar() {},
};
// โœ…
class X {
	static foo = false;
	static bar() {}

	constructor() {}
}
// โœ…
class X {
	static foo = false;
	static bar() {}

	unicorn() {}
}
// โœ…
class X {
	static #foo = false;
	static bar() {}
}