Skip to content

Latest commit

Β 

History

History
54 lines (42 loc) Β· 915 Bytes

File metadata and controls

54 lines (42 loc) Β· 915 Bytes

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() {}
}