Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(eslint-plugin): [lines-around-comment] add extension rule (#5327)
* replicate eslint rule and add base test case * port the eslint lines-around-comment * check for comment in interface and allow options * check for comment in type literals and allow options * add lines-around-comment in index * add lines-around-comment in all config * add lines-around-comment doc * delegate non-TS check to the base rule * fix lint errors * fix doc lint errors * address comments * address jsdoc comments * proper comment language * Update packages/eslint-plugin/src/rules/lines-around-comment.ts Co-authored-by: Brad Zacher <brad.zacher@gmail.com> * remove irrevalant lines and improve test cov * skip more cases * add enum and module tests * implement enum and module * improve coverage * remove ESilnt base rule test casese * improve coverage --------- Co-authored-by: Brad Zacher <brad.zacher@gmail.com> Co-authored-by: Josh Goldberg <git@joshuakgoldberg.com>
- Loading branch information
1 parent
d73d7d3
commit d55211c
Showing
7 changed files
with
1,593 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
description: 'Require empty lines around comments.' | ||
--- | ||
|
||
> 🛑 This file is source code, not the primary documentation location! 🛑 | ||
> | ||
> See **https://typescript-eslint.io/rules/lines-around-comment** for documentation. | ||
## Rule Details | ||
|
||
This rule extends the base [`eslint/lines-around-comment`](https://eslint.org/docs/rules/lines-around-comment) rule. | ||
It adds support for TypeScript syntax. | ||
|
||
See the [ESLint documentation](https://eslint.org/docs/rules/lines-around-comment) for more details on the `comma-dangle` rule. | ||
|
||
## Rule Changes | ||
|
||
```jsonc | ||
{ | ||
// note you must disable the base rule as it can report incorrect errors | ||
"lines-around-comment": "off", | ||
"@typescript-eslint/lines-around-comment": ["error"] | ||
} | ||
``` | ||
|
||
In addition to the options supported by the `lines-around-comment` rule in ESLint core, the rule adds the following options: | ||
|
||
## Options | ||
|
||
- `allowInterfaceStart: true` doesn't require a blank line after the interface body block start | ||
- `allowInterfaceEnd: true` doesn't require a blank line before the interface body block end | ||
- `allowTypeStart: true` doesn't require a blank line after the type literal block start | ||
- `allowTypeEnd: true` doesn't require a blank line after the type literal block end | ||
|
||
[See the other options allowed](https://eslint.org/docs/rules/comma-dangle#options) | ||
|
||
<sup> | ||
|
||
Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/main/docs/rules/lines-around-comment.md) | ||
|
||
</sup> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.