eslint/rules/classes
Classes: Constructors, members, accessors, this and inheritance. Rules of ESLint, typescript-eslint and SonarJS (the Sonar way profile of SonarQube) on this subject, every rule listed; the TypeScript rules apply to TypeScript files only.
47 rules, 33 on. Source: lint/eslint/rules/classes.mjs.
| Rule | Setting | Files | What it checks | Why |
|---|---|---|---|---|
constructor-super | error | JS + TS | Require super() calls in constructors | — |
getter-return | error | JS + TS | Enforce return statements in getters | — |
no-class-assign | error | JS + TS | Disallow reassigning class members | — |
no-constructor-return | error | JS + TS | Disallow returning value from constructor | — |
no-dupe-class-members | error | JS + TS | Disallow duplicate class members | Replaced by the TS version. |
no-new-native-nonconstructor | error | JS + TS | Disallow new operators with global non-constructor functions | — |
no-setter-return | error | JS + TS | Disallow returning values from setters | — |
no-this-before-super | error | JS + TS | Disallow this/super before calling super() in constructors | — |
no-unused-private-class-members | error | JS + TS | Disallow unused private class members | Replaced by the TS version. |
accessor-pairs | info | JS + TS | Enforce getter and setter pairs in objects and classes | — |
class-methods-use-this | warn | JS + TS | Enforce that class methods utilize this | Warn: a method may implement an interface without using this. |
consistent-this | info | JS + TS | Enforce consistent naming when capturing the current execution context | Off: no-this-alias forbids aliasing this at all. |
grouped-accessor-pairs | info | JS + TS | Require grouped accessor pairs in object literals and classes | — |
max-classes-per-file | warn | JS + TS | Enforce a maximum number of classes per file | Warn: a size limit: a justified exception (a data table, a state machine) may pass. |
no-empty-static-block | warn | JS + TS | Disallow empty static blocks | — |
no-extend-native | error | JS + TS | Disallow extending native types | — |
no-invalid-this | warn | JS + TS | Disallow use of this in contexts where the value of this is undefined | Off: the core rule misreads this: parameters; the TS version is off by choice. |
no-new | warn | JS + TS | Disallow new operators outside of assignments or comparisons | — |
no-object-constructor | info | JS + TS | Disallow calls to the Object constructor without an argument | — |
no-useless-constructor | info | JS + TS | Disallow unnecessary constructors | Replaced by the TS version. |
sonarjs/no-built-in-override | off | JS + TS | Built-in objects should not be overridden | Off: not in the Sonar way profile of SonarQube. |
sonarjs/new-operator-misuse | error | JS + TS | "new" should only be used with functions and classes | — |
constructor-super | off | TS | Require super() calls in constructors | — |
getter-return | off | TS | Enforce return statements in getters | — |
no-class-assign | off | TS | Disallow reassigning class members | — |
no-new-native-nonconstructor | off | TS | Disallow new operators with global non-constructor functions | — |
no-setter-return | off | TS | Disallow returning values from setters | — |
no-this-before-super | off | TS | Disallow this/super before calling super() in constructors | — |
@typescript-eslint/class-literal-property-style | error | TS | Enforce that literals on classes are exposed in a consistent style | — |
class-methods-use-this | off | TS | Enforce that class methods utilize this | Warn: a method may implement an interface without using this. |
@typescript-eslint/class-methods-use-this | warn | TS | Enforce that class methods utilize this | Warn: a method may implement an interface without using this. |
@typescript-eslint/explicit-member-accessibility | error | TS | Require explicit accessibility modifiers on class properties and methods | — |
@typescript-eslint/member-ordering | info | TS | Require a consistent member declaration order | — |
no-dupe-class-members | off | TS | Disallow duplicate class members | Replaced by the TS version. |
@typescript-eslint/no-dupe-class-members | error | TS | Disallow duplicate class members | — |
@typescript-eslint/no-extraneous-class | warn | TS | Disallow classes used as namespaces | — |
no-invalid-this | off | TS | Disallow use of this in contexts where the value of this is undefined | Off: the core rule misreads this: parameters; the TS version is off by choice. |
@typescript-eslint/no-invalid-this | off | TS | Disallow this keywords outside of classes or class-like objects | — |
consistent-this | off | TS | Enforce consistent naming when capturing the current execution context | Off: no-this-alias forbids aliasing this at all. |
@typescript-eslint/no-this-alias | warn | TS | Disallow aliasing this | — |
no-unused-private-class-members | off | TS | Disallow unused private class members | Replaced by the TS version. |
@typescript-eslint/no-unused-private-class-members | error | TS | Disallow unused private class members | — |
no-useless-constructor | off | TS | Disallow unnecessary constructors | Replaced by the TS version. |
@typescript-eslint/no-useless-constructor | error | TS | Disallow unnecessary constructors | — |
@typescript-eslint/parameter-properties | error | TS | Require or disallow parameter properties in class constructors | — |
@typescript-eslint/related-getter-setter-pairs | error | TS | Enforce that get() types should be assignable to their equivalent set() type | — |
@typescript-eslint/unbound-method | error | TS | Enforce unbound methods are called with their expected scope | — |