lines-between-class-members
danger
This rule will soon be moved to eslint-stylistic. See What About Formatting? for more information.
Require or disallow an empty line between class members.
🔧
Some problems reported by this rule are automatically fixable by the --fix
ESLint command line option.
This rule extends the base eslint/lines-between-class-members
rule.
It adds support for ignoring overload methods in a class.
How to Use
.eslintrc.cjs
module.exports = {
"rules": {
// Note: you must disable the base rule as it can report incorrect errors
"lines-between-class-members": "off",
"@typescript-eslint/lines-between-class-members": "error"
}
};
Options
See eslint/lines-between-class-members
options.
In addition to the options supported by the lines-between-class-members
rule in ESLint core, the rule adds the following options:
Object option:
"exceptAfterOverload": true
(default) - Skip checking empty lines after overload class members"exceptAfterOverload": false
- do not skip checking empty lines after overload class members
exceptAfterOverload: true
Examples of correct code for the { "exceptAfterOverload": true }
option:
class foo {
bar(a: string): void;
bar(a: string, b: string): void;
bar(a: string, b: string) {}
baz() {}
qux() {}
}
Open in PlaygroundexceptAfterOverload: false
Examples of correct code for the { "exceptAfterOverload": false }
option:
class foo {
bar(a: string): void;
bar(a: string, b: string): void;
bar(a: string, b: string) {}
baz() {}
qux() {}
}
Open in PlaygroundResources
Taken with ❤️ from ESLint core