Skip to content

Commit

Permalink
feat(eslint-plugin): add extension rule `padding-line-between-stateme…
Browse files Browse the repository at this point in the history
…nts` (#3418)
  • Loading branch information
yasarsid committed Sep 3, 2021
1 parent 780548c commit f79ae9b
Show file tree
Hide file tree
Showing 7 changed files with 5,927 additions and 37 deletions.
2 changes: 2 additions & 0 deletions packages/ast-spec/src/unions/LeftHandSideExpression.ts
Expand Up @@ -9,6 +9,7 @@ import type { JSXFragment } from '../expression/JSXFragment/spec';
import type { MemberExpression } from '../expression/MemberExpression/spec';
import type { MetaProperty } from '../expression/MetaProperty/spec';
import type { ObjectExpression } from '../expression/ObjectExpression/spec';
import type { SequenceExpression } from '../expression/spec';
import type { Super } from '../expression/Super/spec';
import type { TaggedTemplateExpression } from '../expression/TaggedTemplateExpression/spec';
import type { ThisExpression } from '../expression/ThisExpression/spec';
Expand All @@ -34,6 +35,7 @@ export type LeftHandSideExpression =
| MetaProperty
| ObjectExpression
| ObjectPattern
| SequenceExpression
| Super
| TaggedTemplateExpression
| ThisExpression
Expand Down
75 changes: 38 additions & 37 deletions packages/eslint-plugin/README.md

Large diffs are not rendered by default.

@@ -0,0 +1,48 @@
# require or disallow padding lines between statements (`padding-line-between-statements`)

## Rule Details

This rule extends the base [`eslint/padding-line-between-statements`](https://eslint.org/docs/rules/padding-line-between-statements) rule.

**It adds support for TypeScript constructs such as `interface` and `type`.**

## How to use

```jsonc
{
// note you must disable the base rule as it can report incorrect errors
"padding-line-between-statements": "off",
"@typescript-eslint/padding-line-between-statements": [
"error",
{
"blankLine": "always",
"prev": "var",
"next": "return"
}
]
}
```

```jsonc
{
// Example - Add blank lines before interface and type definitions.
// note you must disable the base rule as it can report incorrect errors
"padding-line-between-statements": "off",
"@typescript-eslint/padding-line-between-statements": [
"error",
{
"blankLine": "always",
"prev": "*",
"next": ["interface", "type"]
}
]
}
```

## Options

See [`eslint/padding-line-between-statements` options](https://eslint.org/docs/rules/padding-line-between-statements#options).

**Note** - In addition to options provided by ESLint, we have also added options for `interface` and `type`.

<sup>Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/master/docs/rules/padding-line-between-statements.md)</sup>
2 changes: 2 additions & 0 deletions packages/eslint-plugin/src/configs/all.ts
Expand Up @@ -116,6 +116,8 @@ export = {
'@typescript-eslint/non-nullable-type-assertion-style': 'error',
'object-curly-spacing': 'off',
'@typescript-eslint/object-curly-spacing': 'error',
'padding-line-between-statements': 'off',
'@typescript-eslint/padding-line-between-statements': 'error',
'@typescript-eslint/prefer-as-const': 'error',
'@typescript-eslint/prefer-enum-initializers': 'error',
'@typescript-eslint/prefer-for-of': 'error',
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-plugin/src/rules/index.ts
Expand Up @@ -81,6 +81,7 @@ import noUselessConstructor from './no-useless-constructor';
import noVarRequires from './no-var-requires';
import nonNullableTypeAssertionStyle from './non-nullable-type-assertion-style';
import objectCurlySpacing from './object-curly-spacing';
import paddingLineBetweenStatements from './padding-line-between-statements';
import preferAsConst from './prefer-as-const';
import preferEnumInitializers from './prefer-enum-initializers';
import preferForOf from './prefer-for-of';
Expand Down Expand Up @@ -200,6 +201,7 @@ export default {
'no-var-requires': noVarRequires,
'non-nullable-type-assertion-style': nonNullableTypeAssertionStyle,
'object-curly-spacing': objectCurlySpacing,
'padding-line-between-statements': paddingLineBetweenStatements,
'prefer-as-const': preferAsConst,
'prefer-enum-initializers': preferEnumInitializers,
'prefer-for-of': preferForOf,
Expand Down

0 comments on commit f79ae9b

Please sign in to comment.