Skip to content

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.

RuleSettingFilesWhat it checksWhy
constructor-supererrorJS + TSRequire super() calls in constructors—
getter-returnerrorJS + TSEnforce return statements in getters—
no-class-assignerrorJS + TSDisallow reassigning class members—
no-constructor-returnerrorJS + TSDisallow returning value from constructor—
no-dupe-class-memberserrorJS + TSDisallow duplicate class membersReplaced by the TS version.
no-new-native-nonconstructorerrorJS + TSDisallow new operators with global non-constructor functions—
no-setter-returnerrorJS + TSDisallow returning values from setters—
no-this-before-supererrorJS + TSDisallow this/super before calling super() in constructors—
no-unused-private-class-memberserrorJS + TSDisallow unused private class membersReplaced by the TS version.
accessor-pairsinfoJS + TSEnforce getter and setter pairs in objects and classes—
class-methods-use-thiswarnJS + TSEnforce that class methods utilize thisWarn: a method may implement an interface without using this.
consistent-thisinfoJS + TSEnforce consistent naming when capturing the current execution contextOff: no-this-alias forbids aliasing this at all.
grouped-accessor-pairsinfoJS + TSRequire grouped accessor pairs in object literals and classes—
max-classes-per-filewarnJS + TSEnforce a maximum number of classes per fileWarn: a size limit: a justified exception (a data table, a state machine) may pass.
no-empty-static-blockwarnJS + TSDisallow empty static blocks—
no-extend-nativeerrorJS + TSDisallow extending native types—
no-invalid-thiswarnJS + TSDisallow use of this in contexts where the value of this is undefinedOff: the core rule misreads this: parameters; the TS version is off by choice.
no-newwarnJS + TSDisallow new operators outside of assignments or comparisons—
no-object-constructorinfoJS + TSDisallow calls to the Object constructor without an argument—
no-useless-constructorinfoJS + TSDisallow unnecessary constructorsReplaced by the TS version.
sonarjs/no-built-in-overrideoffJS + TSBuilt-in objects should not be overriddenOff: not in the Sonar way profile of SonarQube.
sonarjs/new-operator-misuseerrorJS + TS"new" should only be used with functions and classes—
constructor-superoffTSRequire super() calls in constructors—
getter-returnoffTSEnforce return statements in getters—
no-class-assignoffTSDisallow reassigning class members—
no-new-native-nonconstructoroffTSDisallow new operators with global non-constructor functions—
no-setter-returnoffTSDisallow returning values from setters—
no-this-before-superoffTSDisallow this/super before calling super() in constructors—
@typescript-eslint/class-literal-property-styleerrorTSEnforce that literals on classes are exposed in a consistent style—
class-methods-use-thisoffTSEnforce that class methods utilize thisWarn: a method may implement an interface without using this.
@typescript-eslint/class-methods-use-thiswarnTSEnforce that class methods utilize thisWarn: a method may implement an interface without using this.
@typescript-eslint/explicit-member-accessibilityerrorTSRequire explicit accessibility modifiers on class properties and methods—
@typescript-eslint/member-orderinginfoTSRequire a consistent member declaration order—
no-dupe-class-membersoffTSDisallow duplicate class membersReplaced by the TS version.
@typescript-eslint/no-dupe-class-memberserrorTSDisallow duplicate class members—
@typescript-eslint/no-extraneous-classwarnTSDisallow classes used as namespaces—
no-invalid-thisoffTSDisallow use of this in contexts where the value of this is undefinedOff: the core rule misreads this: parameters; the TS version is off by choice.
@typescript-eslint/no-invalid-thisoffTSDisallow this keywords outside of classes or class-like objects—
consistent-thisoffTSEnforce consistent naming when capturing the current execution contextOff: no-this-alias forbids aliasing this at all.
@typescript-eslint/no-this-aliaswarnTSDisallow aliasing this—
no-unused-private-class-membersoffTSDisallow unused private class membersReplaced by the TS version.
@typescript-eslint/no-unused-private-class-memberserrorTSDisallow unused private class members—
no-useless-constructoroffTSDisallow unnecessary constructorsReplaced by the TS version.
@typescript-eslint/no-useless-constructorerrorTSDisallow unnecessary constructors—
@typescript-eslint/parameter-propertieserrorTSRequire or disallow parameter properties in class constructors—
@typescript-eslint/related-getter-setter-pairserrorTSEnforce that get() types should be assignable to their equivalent set() type—
@typescript-eslint/unbound-methoderrorTSEnforce unbound methods are called with their expected scope—

Generated from the JSDoc of the sources.