Skip to content

Latest commit

 

History

History
30 lines (20 loc) · 980 Bytes

no-class.md

File metadata and controls

30 lines (20 loc) · 980 Bytes

Avoid use of class (no-class)

ECMAScript 6 allows programmers to create class to "help" those coming from a OOP language, such as Java or C++, to create constructors, thus multiple instances of an object. In the JS community this is considered one of the bad parts.

Rule Details

This rule aims to discourage the use of class and to encourage other approaches such as functional inheritance, prototypal inheritance or object composition.

The following patterns are considered warnings:

class Foo {
  constructor() {
    this.foo = 'bar';
  }
}

When Not To Use It

Existing ES6 JavaScript projects that are heavily using classical inheritance may not want to apply this rule if the cost of removing class is too costly.

Further Reading