Urara-Blog/node_modules/.pnpm-store/v3/files/11/d026e5b0dfe3f8c4f922da54d47af2aaac2b5ca9d2faa607f95e7e0178f5dba47368b1a6f749e15e2f4cc6479b1fbc863340fe234e189134b78f98ea638222
2022-08-14 01:14:53 +08:00

83 lines
2.4 KiB
Text

---
description: 'Require or disallow an empty line between class members.'
---
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/lines-between-class-members** for documentation.
This rule improves readability by enforcing lines between class members. It will not check empty lines before the first member and after the last member. This rule require or disallow an empty line between class members.
## Rule Details
This rule extends the base [`eslint/lines-between-class-members`](https://eslint.org/docs/rules/lines-between-class-members) rule.
It adds support for ignoring overload methods in a class.
See the [ESLint documentation](https://eslint.org/docs/rules/lines-between-class-members) for more details on the `lines-between-class-members` rule.
## Rule Changes
```jsonc
{
// 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"]
}
```
In addition to the options supported by the `lines-between-class-members` rule in ESLint core, the rule adds the following options:
## Options
This rule has a string option and an object option.
- 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
- [See the other options allowed](https://github.com/eslint/eslint/blob/main/docs/rules/lines-between-class-members.md#options)
### `exceptAfterOverload: true`
Examples of **correct** code for the `{ "exceptAfterOverload": true }` option:
```ts
/*eslint @typescript-eslint/lines-between-class-members: ["error", "always", { "exceptAfterOverload": true }]*/
class foo {
bar(a: string): void;
bar(a: string, b: string): void;
bar(a: string, b: string) {}
baz() {}
qux() {}
}
```
### `exceptAfterOverload: false`
Examples of **correct** code for the `{ "exceptAfterOverload": false }` option:
```ts
/*eslint @typescript-eslint/lines-between-class-members: ["error", "always", { "exceptAfterOverload": false }]*/
class foo {
bar(a: string): void;
bar(a: string, b: string): void;
bar(a: string, b: string) {}
baz() {}
qux() {}
}
```
<sup>
Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/docs/rules/lines-between-class-members.md)
</sup>