There is no good excuse for an empty class. If it’s being used simply as a common extension point, it should be replaced with an
interface. If it was stubbed in as a placeholder for future development it should be fleshed-out. In any other case, it should be
eliminated.
Additionally, one shouldn’t use a class to define exclusively static methods. Instead one can use a module, or better, export each function separately.
Using an empty class serves no purpose and can hinder the readability of the code.
class Foo {
static bar() {
// ...
}
}
You can export the functions that you wish to make available.
export function bar() {
// ...
}
class Foo { // Noncompliant
static bar() {
// ...
}
}
export function bar() {
// ...
}
class DoAndLog { // Noncompliant
constructor () {
console.log('I\'m done!');
}
}
function doAndLog() {
console.log('I\'m done!');
}