Skip to content

Latest commit

Β 

History

History
56 lines (43 loc) Β· 943 Bytes

File metadata and controls

56 lines (43 loc) Β· 943 Bytes

no-static-only-class

πŸ“ 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() {}
}