eslint-plugin-classes
custom ESLint rule, checks class style. (will adding more rules for class)
Rule Details
space
should no space between method name and parens.
The following patterns are considered warnings:
{ } static { } { } { }
The following patterns are not warnings:
{ } static { } { } { }
name
- class name should start with upper case.
- method name should start with lower case.
The following patterns are considered warnings:
{ }
The following patterns are not warnings:
{ }
constructor
class should have constructor always even if empty body.
The following patterns are considered warnings:
{ }
The following patterns are not warnings:
{ console; } { } { }
super
extended class should call super()
at the top of constructor.
The following patterns are considered warnings:
{ } { this; } { }
The following patterns are not warnings:
{ super; thisa = 10; } { } { } { super; thisa = 10; } { // comments super; thisa = 10; }
Style
enforce order of definition of method in order of static method => constructor => instance methods.
The following patterns are considered warnings:
{} static {} {} static {} {} {}
The following patterns are not warnings:
static {} static {} {} {} {} {}
Usage
plugins: - classes rules: # Plugins classes/space : 2 classes/name : [2, "class", "method"] classes/constructor : 2 classes/super : 2 classes/style : 2
License
MIT