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