Skip to content

Latest commit

 

History

History
50 lines (38 loc) · 703 Bytes

no-static-only-class.md

File metadata and controls

50 lines (38 loc) · 703 Bytes

Forbid classes that only have static members

This rule is part of the recommended config.

🔧 This rule is auto-fixable.

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

Fail

class X {
	static foo = false;
	static bar() {};
}

Pass

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