Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(eslint-plugin): [lines-around-comment] add extension rule #5327

Merged
merged 24 commits into from Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
b3b6319
replicate eslint rule and add base test case
chbdetta Jun 30, 2022
62efad9
port the eslint lines-around-comment
chbdetta Jul 9, 2022
c2433b4
check for comment in interface and allow options
chbdetta Jul 9, 2022
d97237e
check for comment in type literals and allow options
chbdetta Jul 9, 2022
e9df0ec
add lines-around-comment in index
chbdetta Jul 9, 2022
14db2f7
add lines-around-comment in all config
chbdetta Jul 9, 2022
7f2661f
add lines-around-comment doc
chbdetta Jul 9, 2022
30825c6
delegate non-TS check to the base rule
chbdetta Sep 25, 2022
b153dba
Merge branch 'main' into main
chbdetta Sep 25, 2022
793d2e7
fix lint errors
chbdetta Sep 25, 2022
3b74231
fix doc lint errors
chbdetta Sep 25, 2022
b367c61
address comments
chbdetta Sep 25, 2022
b763e3a
address jsdoc comments
chbdetta Sep 25, 2022
59541ed
proper comment language
chbdetta Sep 25, 2022
f92776d
Update packages/eslint-plugin/src/rules/lines-around-comment.ts
chbdetta Oct 9, 2022
01371be
remove irrevalant lines and improve test cov
chbdetta Oct 10, 2022
7a39437
skip more cases
chbdetta Oct 10, 2022
567420a
add enum and module tests
chbdetta Oct 10, 2022
9cf58f2
implement enum and module
chbdetta Oct 10, 2022
88584c6
improve coverage
chbdetta Oct 10, 2022
ade17f3
Merge branch 'main' of github.com:chbdetta/typescript-eslint into main
chbdetta Oct 10, 2022
b6b475a
remove ESilnt base rule test casese
chbdetta Jan 24, 2023
f32e927
improve coverage
chbdetta Jan 24, 2023
75bf6ea
Merge branch 'main' into main
JoshuaKGoldberg Jan 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
41 changes: 41 additions & 0 deletions packages/eslint-plugin/docs/rules/lines-around-comment.md
@@ -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>
2 changes: 2 additions & 0 deletions packages/eslint-plugin/src/configs/all.ts
Expand Up @@ -41,6 +41,8 @@ export = {
'@typescript-eslint/key-spacing': 'error',
'keyword-spacing': 'off',
'@typescript-eslint/keyword-spacing': 'error',
'lines-around-comment': 'off',
'@typescript-eslint/lines-around-comment': 'error',
'lines-between-class-members': 'off',
'@typescript-eslint/lines-between-class-members': 'error',
'@typescript-eslint/member-delimiter-style': 'error',
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-plugin/src/rules/index.ts
Expand Up @@ -24,6 +24,7 @@ import indent from './indent';
import initDeclarations from './init-declarations';
import keySpacing from './key-spacing';
import keywordSpacing from './keyword-spacing';
import linesAroundComment from './lines-around-comment';
import linesBetweenClassMembers from './lines-between-class-members';
import memberDelimiterStyle from './member-delimiter-style';
import memberOrdering from './member-ordering';
Expand Down Expand Up @@ -156,6 +157,7 @@ export default {
'init-declarations': initDeclarations,
'key-spacing': keySpacing,
'keyword-spacing': keywordSpacing,
'lines-around-comment': linesAroundComment,
'lines-between-class-members': linesBetweenClassMembers,
'member-delimiter-style': memberDelimiterStyle,
'member-ordering': memberOrdering,
Expand Down