@typescript-eslint/eslint-plugin 7.2.1-alpha.2 → 7.2.1-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/configs/all.js +1 -0
- package/dist/configs/all.js.map +1 -1
- package/dist/configs/disable-type-checked.js +1 -0
- package/dist/configs/disable-type-checked.js.map +1 -1
- package/dist/configs/strict-type-checked-only.js +23 -3
- package/dist/configs/strict-type-checked-only.js.map +1 -1
- package/dist/configs/strict-type-checked.js +27 -4
- package/dist/configs/strict-type-checked.js.map +1 -1
- package/dist/configs/strict.js +4 -1
- package/dist/configs/strict.js.map +1 -1
- package/dist/rules/ban-ts-comment.js +4 -1
- package/dist/rules/ban-ts-comment.js.map +1 -1
- package/dist/rules/index.js +2 -0
- package/dist/rules/index.js.map +1 -1
- package/dist/rules/no-floating-promises.js +4 -1
- package/dist/rules/no-floating-promises.js.map +1 -1
- package/dist/rules/no-misused-promises.js +1 -1
- package/dist/rules/no-misused-promises.js.map +1 -1
- package/dist/rules/no-unnecessary-qualifier.js +1 -1
- package/dist/rules/no-unnecessary-qualifier.js.map +1 -1
- package/dist/rules/no-unsafe-argument.js +1 -25
- package/dist/rules/no-unsafe-argument.js.map +1 -1
- package/dist/rules/no-unused-expressions.js +6 -2
- package/dist/rules/no-unused-expressions.js.map +1 -1
- package/dist/rules/restrict-plus-operands.js +12 -1
- package/dist/rules/restrict-plus-operands.js.map +1 -1
- package/dist/rules/restrict-template-expressions.js +13 -1
- package/dist/rules/restrict-template-expressions.js.map +1 -1
- package/dist/rules/use-unknown-in-catch-callback-variable.js +283 -0
- package/dist/rules/use-unknown-in-catch-callback-variable.js.map +1 -0
- package/dist/util/misc.js +10 -1
- package/dist/util/misc.js.map +1 -1
- package/docs/rules/TEMPLATE.md +10 -4
- package/docs/rules/{adjacent-overload-signatures.md → adjacent-overload-signatures.mdx} +11 -5
- package/docs/rules/{array-type.md → array-type.mdx} +24 -12
- package/docs/rules/{await-thenable.md → await-thenable.mdx} +10 -4
- package/docs/rules/{ban-ts-comment.md → ban-ts-comment.mdx} +32 -18
- package/docs/rules/{ban-tslint-comment.md → ban-tslint-comment.mdx} +10 -4
- package/docs/rules/{ban-types.md → ban-types.mdx} +11 -5
- package/docs/rules/{block-spacing.md → block-spacing.mdx} +3 -0
- package/docs/rules/{brace-style.md → brace-style.mdx} +3 -0
- package/docs/rules/camelcase.md +3 -5
- package/docs/rules/{class-literal-property-style.md → class-literal-property-style.mdx} +18 -11
- package/docs/rules/{class-methods-use-this.md → class-methods-use-this.mdx} +12 -6
- package/docs/rules/{comma-dangle.md → comma-dangle.mdx} +3 -0
- package/docs/rules/{comma-spacing.md → comma-spacing.mdx} +3 -0
- package/docs/rules/{consistent-generic-constructors.md → consistent-generic-constructors.mdx} +17 -8
- package/docs/rules/{consistent-indexed-object-style.md → consistent-indexed-object-style.mdx} +17 -8
- package/docs/rules/{consistent-return.md → consistent-return.mdx} +10 -4
- package/docs/rules/{consistent-type-assertions.md → consistent-type-assertions.mdx} +15 -10
- package/docs/rules/{consistent-type-definitions.md → consistent-type-definitions.mdx} +17 -8
- package/docs/rules/{consistent-type-exports.md → consistent-type-exports.mdx} +17 -8
- package/docs/rules/{consistent-type-imports.md → consistent-type-imports.mdx} +13 -8
- package/docs/rules/{default-param-last.md → default-param-last.mdx} +10 -4
- package/docs/rules/{dot-notation.md → dot-notation.mdx} +3 -0
- package/docs/rules/{explicit-function-return-type.md → explicit-function-return-type.mdx} +59 -32
- package/docs/rules/{explicit-member-accessibility.md → explicit-member-accessibility.mdx} +3 -0
- package/docs/rules/{explicit-module-boundary-types.md → explicit-module-boundary-types.mdx} +39 -21
- package/docs/rules/{func-call-spacing.md → func-call-spacing.mdx} +3 -0
- package/docs/rules/{indent.md → indent.mdx} +3 -0
- package/docs/rules/{init-declarations.md → init-declarations.mdx} +3 -0
- package/docs/rules/{key-spacing.md → key-spacing.mdx} +3 -0
- package/docs/rules/{keyword-spacing.md → keyword-spacing.mdx} +3 -0
- package/docs/rules/{lines-around-comment.md → lines-around-comment.mdx} +3 -0
- package/docs/rules/{lines-between-class-members.md → lines-between-class-members.mdx} +3 -0
- package/docs/rules/{max-params.md → max-params.mdx} +3 -0
- package/docs/rules/{member-delimiter-style.md → member-delimiter-style.mdx} +13 -7
- package/docs/rules/{member-ordering.md → member-ordering.mdx} +92 -56
- package/docs/rules/{method-signature-style.md → method-signature-style.mdx} +17 -8
- package/docs/rules/{naming-convention.md → naming-convention.mdx} +3 -0
- package/docs/rules/{no-array-constructor.md → no-array-constructor.mdx} +10 -4
- package/docs/rules/{no-array-delete.md → no-array-delete.mdx} +9 -5
- package/docs/rules/{no-base-to-string.md → no-base-to-string.mdx} +12 -6
- package/docs/rules/{no-confusing-non-null-assertion.md → no-confusing-non-null-assertion.mdx} +11 -5
- package/docs/rules/{no-confusing-void-expression.md → no-confusing-void-expression.mdx} +10 -4
- package/docs/rules/{no-dupe-class-members.md → no-dupe-class-members.mdx} +4 -1
- package/docs/rules/{no-duplicate-enum-values.md → no-duplicate-enum-values.mdx} +10 -4
- package/docs/rules/{no-duplicate-imports.md → no-duplicate-imports.mdx} +1 -1
- package/docs/rules/{no-duplicate-type-constituents.md → no-duplicate-type-constituents.mdx} +10 -4
- package/docs/rules/{no-dynamic-delete.md → no-dynamic-delete.mdx} +10 -4
- package/docs/rules/{no-empty-function.md → no-empty-function.mdx} +3 -0
- package/docs/rules/{no-empty-interface.md → no-empty-interface.mdx} +9 -5
- package/docs/rules/{no-explicit-any.md → no-explicit-any.mdx} +15 -9
- package/docs/rules/{no-extra-non-null-assertion.md → no-extra-non-null-assertion.mdx} +11 -5
- package/docs/rules/{no-extra-parens.md → no-extra-parens.mdx} +3 -0
- package/docs/rules/{no-extra-semi.md → no-extra-semi.mdx} +3 -0
- package/docs/rules/{no-extraneous-class.md → no-extraneous-class.mdx} +61 -33
- package/docs/rules/{no-floating-promises.md → no-floating-promises.mdx} +12 -6
- package/docs/rules/{no-for-in-array.md → no-for-in-array.mdx} +10 -4
- package/docs/rules/{no-implied-eval.md → no-implied-eval.mdx} +10 -4
- package/docs/rules/{no-import-type-side-effects.md → no-import-type-side-effects.mdx} +12 -6
- package/docs/rules/{no-inferrable-types.md → no-inferrable-types.mdx} +9 -5
- package/docs/rules/{no-invalid-this.md → no-invalid-this.mdx} +4 -1
- package/docs/rules/{no-invalid-void-type.md → no-invalid-void-type.mdx} +10 -4
- package/docs/rules/{no-loop-func.md → no-loop-func.mdx} +3 -0
- package/docs/rules/{no-loss-of-precision.md → no-loss-of-precision.mdx} +3 -0
- package/docs/rules/{no-magic-numbers.md → no-magic-numbers.mdx} +3 -0
- package/docs/rules/{no-meaningless-void-operator.md → no-meaningless-void-operator.mdx} +12 -4
- package/docs/rules/{no-misused-new.md → no-misused-new.mdx} +10 -4
- package/docs/rules/{no-misused-promises.md → no-misused-promises.mdx} +24 -16
- package/docs/rules/{no-mixed-enums.md → no-mixed-enums.mdx} +14 -6
- package/docs/rules/{no-namespace.md → no-namespace.mdx} +29 -18
- package/docs/rules/{no-non-null-asserted-nullish-coalescing.md → no-non-null-asserted-nullish-coalescing.mdx} +10 -4
- package/docs/rules/{no-non-null-asserted-optional-chain.md → no-non-null-asserted-optional-chain.mdx} +10 -4
- package/docs/rules/{no-non-null-assertion.md → no-non-null-assertion.mdx} +10 -4
- package/docs/rules/{no-redeclare.md → no-redeclare.mdx} +4 -1
- package/docs/rules/{no-redundant-type-constituents.md → no-redundant-type-constituents.mdx} +10 -4
- package/docs/rules/{no-require-imports.md → no-require-imports.mdx} +18 -9
- package/docs/rules/{no-restricted-imports.md → no-restricted-imports.mdx} +10 -4
- package/docs/rules/{no-shadow.md → no-shadow.mdx} +4 -1
- package/docs/rules/{no-this-alias.md → no-this-alias.mdx} +24 -12
- package/docs/rules/{no-throw-literal.md → no-throw-literal.mdx} +11 -5
- package/docs/rules/{no-type-alias.md → no-type-alias.mdx} +5 -2
- package/docs/rules/{no-unnecessary-boolean-literal-compare.md → no-unnecessary-boolean-literal-compare.mdx} +24 -12
- package/docs/rules/{no-unnecessary-condition.md → no-unnecessary-condition.mdx} +11 -5
- package/docs/rules/{no-unnecessary-qualifier.md → no-unnecessary-qualifier.mdx} +10 -4
- package/docs/rules/{no-unnecessary-type-arguments.md → no-unnecessary-type-arguments.mdx} +10 -4
- package/docs/rules/{no-unnecessary-type-assertion.md → no-unnecessary-type-assertion.mdx} +10 -4
- package/docs/rules/{no-unnecessary-type-constraint.md → no-unnecessary-type-constraint.mdx} +10 -4
- package/docs/rules/{no-unsafe-argument.md → no-unsafe-argument.mdx} +14 -10
- package/docs/rules/{no-unsafe-assignment.md → no-unsafe-assignment.mdx} +14 -10
- package/docs/rules/{no-unsafe-call.md → no-unsafe-call.mdx} +15 -9
- package/docs/rules/{no-unsafe-declaration-merging.md → no-unsafe-declaration-merging.mdx} +10 -4
- package/docs/rules/{no-unsafe-enum-comparison.md → no-unsafe-enum-comparison.mdx} +9 -5
- package/docs/rules/{no-unsafe-member-access.md → no-unsafe-member-access.mdx} +15 -9
- package/docs/rules/{no-unsafe-return.md → no-unsafe-return.mdx} +14 -10
- package/docs/rules/{no-unsafe-unary-minus.md → no-unsafe-unary-minus.mdx} +11 -5
- package/docs/rules/{no-unused-expressions.md → no-unused-expressions.mdx} +3 -0
- package/docs/rules/{no-unused-vars.md → no-unused-vars.mdx} +3 -0
- package/docs/rules/{no-use-before-define.md → no-use-before-define.mdx} +10 -4
- package/docs/rules/{no-useless-constructor.md → no-useless-constructor.mdx} +3 -0
- package/docs/rules/{no-useless-empty-export.md → no-useless-empty-export.mdx} +10 -4
- package/docs/rules/{no-useless-template-literals.md → no-useless-template-literals.mdx} +10 -6
- package/docs/rules/{no-var-requires.md → no-var-requires.mdx} +18 -9
- package/docs/rules/{non-nullable-type-assertion-style.md → non-nullable-type-assertion-style.mdx} +10 -4
- package/docs/rules/{object-curly-spacing.md → object-curly-spacing.mdx} +3 -0
- package/docs/rules/{padding-line-between-statements.md → padding-line-between-statements.mdx} +3 -0
- package/docs/rules/{parameter-properties.md → parameter-properties.mdx} +66 -36
- package/docs/rules/{prefer-as-const.md → prefer-as-const.mdx} +9 -5
- package/docs/rules/{prefer-destructuring.md → prefer-destructuring.mdx} +23 -12
- package/docs/rules/{prefer-enum-initializers.md → prefer-enum-initializers.mdx} +10 -4
- package/docs/rules/{prefer-find.md → prefer-find.mdx} +10 -4
- package/docs/rules/{prefer-for-of.md → prefer-for-of.mdx} +11 -5
- package/docs/rules/{prefer-function-type.md → prefer-function-type.mdx} +10 -4
- package/docs/rules/{prefer-includes.md → prefer-includes.mdx} +11 -5
- package/docs/rules/{prefer-literal-enum-member.md → prefer-literal-enum-member.mdx} +16 -9
- package/docs/rules/{prefer-namespace-keyword.md → prefer-namespace-keyword.mdx} +9 -5
- package/docs/rules/{prefer-nullish-coalescing.md → prefer-nullish-coalescing.mdx} +3 -0
- package/docs/rules/{prefer-optional-chain.md → prefer-optional-chain.mdx} +58 -33
- package/docs/rules/{prefer-promise-reject-errors.md → prefer-promise-reject-errors.mdx} +10 -4
- package/docs/rules/{prefer-readonly-parameter-types.md → prefer-readonly-parameter-types.mdx} +36 -22
- package/docs/rules/{prefer-readonly.md → prefer-readonly.mdx} +17 -8
- package/docs/rules/{prefer-reduce-type-parameter.md → prefer-reduce-type-parameter.mdx} +10 -4
- package/docs/rules/{prefer-regexp-exec.md → prefer-regexp-exec.mdx} +10 -4
- package/docs/rules/{prefer-return-this-type.md → prefer-return-this-type.mdx} +10 -4
- package/docs/rules/{prefer-string-starts-ends-with.md → prefer-string-starts-ends-with.mdx} +9 -5
- package/docs/rules/{prefer-ts-expect-error.md → prefer-ts-expect-error.mdx} +10 -4
- package/docs/rules/{promise-function-async.md → promise-function-async.mdx} +24 -12
- package/docs/rules/{quotes.md → quotes.mdx} +3 -0
- package/docs/rules/{require-array-sort-compare.md → require-array-sort-compare.mdx} +17 -8
- package/docs/rules/{require-await.md → require-await.mdx} +3 -0
- package/docs/rules/{restrict-plus-operands.md → restrict-plus-operands.mdx} +54 -30
- package/docs/rules/{restrict-template-expressions.md → restrict-template-expressions.mdx} +13 -7
- package/docs/rules/{return-await.md → return-await.mdx} +24 -12
- package/docs/rules/{semi.md → semi.mdx} +4 -1
- package/docs/rules/{sort-type-constituents.md → sort-type-constituents.mdx} +31 -16
- package/docs/rules/{space-before-blocks.md → space-before-blocks.mdx} +10 -4
- package/docs/rules/{space-before-function-paren.md → space-before-function-paren.mdx} +3 -0
- package/docs/rules/{space-infix-ops.md → space-infix-ops.mdx} +3 -0
- package/docs/rules/{strict-boolean-expressions.md → strict-boolean-expressions.mdx} +11 -5
- package/docs/rules/{switch-exhaustiveness-check.md → switch-exhaustiveness-check.mdx} +19 -14
- package/docs/rules/{triple-slash-reference.md → triple-slash-reference.mdx} +30 -17
- package/docs/rules/{type-annotation-spacing.md → type-annotation-spacing.mdx} +49 -31
- package/docs/rules/{typedef.md → typedef.mdx} +60 -33
- package/docs/rules/{unbound-method.md → unbound-method.mdx} +12 -6
- package/docs/rules/{unified-signatures.md → unified-signatures.mdx} +18 -9
- package/docs/rules/use-unknown-in-catch-callback-variable.mdx +84 -0
- package/package.json +7 -7
- /package/docs/rules/{no-parameter-properties.md → no-parameter-properties.mdx} +0 -0
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
description: 'Enforce consistent spacing between property names and type annotations in types and interfaces.'
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
+
import Tabs from '@theme/Tabs';
|
|
6
|
+
import TabItem from '@theme/TabItem';
|
|
7
|
+
|
|
5
8
|
> 🛑 This file is source code, not the primary documentation location! 🛑
|
|
6
9
|
>
|
|
7
10
|
> See **https://typescript-eslint.io/rules/key-spacing** for documentation.
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
description: 'Enforce consistent spacing before and after keywords.'
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
+
import Tabs from '@theme/Tabs';
|
|
6
|
+
import TabItem from '@theme/TabItem';
|
|
7
|
+
|
|
5
8
|
> 🛑 This file is source code, not the primary documentation location! 🛑
|
|
6
9
|
>
|
|
7
10
|
> See **https://typescript-eslint.io/rules/keyword-spacing** for documentation.
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
description: 'Require empty lines around comments.'
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
+
import Tabs from '@theme/Tabs';
|
|
6
|
+
import TabItem from '@theme/TabItem';
|
|
7
|
+
|
|
5
8
|
> 🛑 This file is source code, not the primary documentation location! 🛑
|
|
6
9
|
>
|
|
7
10
|
> See **https://typescript-eslint.io/rules/lines-around-comment** for documentation.
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
description: 'Require or disallow an empty line between class members.'
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
+
import Tabs from '@theme/Tabs';
|
|
6
|
+
import TabItem from '@theme/TabItem';
|
|
7
|
+
|
|
5
8
|
> 🛑 This file is source code, not the primary documentation location! 🛑
|
|
6
9
|
>
|
|
7
10
|
> See **https://typescript-eslint.io/rules/lines-between-class-members** for documentation.
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
description: 'Enforce a maximum number of parameters in function definitions.'
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
+
import Tabs from '@theme/Tabs';
|
|
6
|
+
import TabItem from '@theme/TabItem';
|
|
7
|
+
|
|
5
8
|
> 🛑 This file is source code, not the primary documentation location! 🛑
|
|
6
9
|
>
|
|
7
10
|
> See **https://typescript-eslint.io/rules/max-params** for documentation.
|
|
@@ -2,13 +2,16 @@
|
|
|
2
2
|
description: 'Require a specific member delimiter style for interfaces and type literals.'
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
+
import Tabs from '@theme/Tabs';
|
|
6
|
+
import TabItem from '@theme/TabItem';
|
|
7
|
+
|
|
5
8
|
> 🛑 This file is source code, not the primary documentation location! 🛑
|
|
6
9
|
>
|
|
7
10
|
> See **https://typescript-eslint.io/rules/member-delimiter-style** for documentation.
|
|
8
11
|
|
|
9
12
|
TypeScript allows three delimiters between members in interfaces and type aliases:
|
|
10
13
|
|
|
11
|
-
|
|
14
|
+
{/* prettier-ignore */}
|
|
12
15
|
```ts
|
|
13
16
|
interface Foo {
|
|
14
17
|
// Semicolons (default, preferred in TypeScript):
|
|
@@ -104,11 +107,10 @@ For example, to require commas for `type`s, and semicolons for multiline `interf
|
|
|
104
107
|
|
|
105
108
|
Examples of code for this rule with the default config:
|
|
106
109
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
### ❌ Incorrect
|
|
110
|
+
<Tabs>
|
|
111
|
+
<TabItem value="❌ Incorrect">
|
|
110
112
|
|
|
111
|
-
|
|
113
|
+
{/* prettier-ignore */}
|
|
112
114
|
```ts
|
|
113
115
|
// missing semicolon delimiter
|
|
114
116
|
interface Foo {
|
|
@@ -135,9 +137,10 @@ type FooBar = { name: string, greet(): string }
|
|
|
135
137
|
type FooBar = { name: string; greet(): string; }
|
|
136
138
|
```
|
|
137
139
|
|
|
138
|
-
|
|
140
|
+
</TabItem>
|
|
141
|
+
<TabItem value="✅ Correct">
|
|
139
142
|
|
|
140
|
-
|
|
143
|
+
{/* prettier-ignore */}
|
|
141
144
|
```ts
|
|
142
145
|
interface Foo {
|
|
143
146
|
name: string;
|
|
@@ -156,6 +159,9 @@ type Bar = { name: string }
|
|
|
156
159
|
type FooBar = { name: string; greet(): string }
|
|
157
160
|
```
|
|
158
161
|
|
|
162
|
+
</TabItem>
|
|
163
|
+
</Tabs>
|
|
164
|
+
|
|
159
165
|
## When Not To Use It
|
|
160
166
|
|
|
161
167
|
If you specifically want to use both member delimiter kinds for stylistic reasons, or don't wish to enforce one style over the other, you can avoid this rule.
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
description: 'Require a consistent member declaration order.'
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
+
import Tabs from '@theme/Tabs';
|
|
6
|
+
import TabItem from '@theme/TabItem';
|
|
7
|
+
|
|
5
8
|
> 🛑 This file is source code, not the primary documentation location! 🛑
|
|
6
9
|
>
|
|
7
10
|
> See **https://typescript-eslint.io/rules/member-ordering** for documentation.
|
|
@@ -285,9 +288,8 @@ It also ignores accessibility and scope.
|
|
|
285
288
|
}
|
|
286
289
|
```
|
|
287
290
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
#### ❌ Incorrect
|
|
291
|
+
<Tabs>
|
|
292
|
+
<TabItem value="❌ Incorrect">
|
|
291
293
|
|
|
292
294
|
```ts option='{ "default": ["signature", "method", "constructor", "field"] }'
|
|
293
295
|
interface Foo {
|
|
@@ -344,7 +346,8 @@ const Foo = class {
|
|
|
344
346
|
};
|
|
345
347
|
```
|
|
346
348
|
|
|
347
|
-
|
|
349
|
+
</TabItem>
|
|
350
|
+
<TabItem value="✅ Correct">
|
|
348
351
|
|
|
349
352
|
```ts option='{ "default": ["signature", "method", "constructor", "field"] }'
|
|
350
353
|
interface Foo {
|
|
@@ -400,6 +403,9 @@ const Foo = class {
|
|
|
400
403
|
};
|
|
401
404
|
```
|
|
402
405
|
|
|
406
|
+
</TabItem>
|
|
407
|
+
</Tabs>
|
|
408
|
+
|
|
403
409
|
### Classes
|
|
404
410
|
|
|
405
411
|
#### Public Instance Methods Before Public Static Fields
|
|
@@ -420,9 +426,8 @@ It doesn't apply to interfaces or type literals as accessibility and scope are n
|
|
|
420
426
|
}
|
|
421
427
|
```
|
|
422
428
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
##### ❌ Incorrect
|
|
429
|
+
<Tabs>
|
|
430
|
+
<TabItem value="❌ Incorrect">
|
|
426
431
|
|
|
427
432
|
```ts option='{ "default": ["public-instance-method", "public-static-field"] }'
|
|
428
433
|
class Foo {
|
|
@@ -460,7 +465,8 @@ const Foo = class {
|
|
|
460
465
|
};
|
|
461
466
|
```
|
|
462
467
|
|
|
463
|
-
|
|
468
|
+
</TabItem>
|
|
469
|
+
<TabItem value="✅ Correct">
|
|
464
470
|
|
|
465
471
|
```ts option='{ "default": ["public-instance-method", "public-static-field"] }'
|
|
466
472
|
class Foo {
|
|
@@ -498,6 +504,9 @@ const Foo = class {
|
|
|
498
504
|
};
|
|
499
505
|
```
|
|
500
506
|
|
|
507
|
+
</TabItem>
|
|
508
|
+
</Tabs>
|
|
509
|
+
|
|
501
510
|
#### Static Fields Before Instance Fields
|
|
502
511
|
|
|
503
512
|
This config specifies that static fields should come before instance fields, with public static fields first.
|
|
@@ -514,9 +523,8 @@ It doesn't apply to interfaces or type literals as accessibility and scope are n
|
|
|
514
523
|
}
|
|
515
524
|
```
|
|
516
525
|
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
##### ❌ Incorrect
|
|
526
|
+
<Tabs>
|
|
527
|
+
<TabItem value="❌ Incorrect">
|
|
520
528
|
|
|
521
529
|
```ts option='{ "default": ["public-static-field", "static-field", "instance-field"] }'
|
|
522
530
|
class Foo {
|
|
@@ -551,7 +559,8 @@ const foo = class {
|
|
|
551
559
|
};
|
|
552
560
|
```
|
|
553
561
|
|
|
554
|
-
|
|
562
|
+
</TabItem>
|
|
563
|
+
<TabItem value="✅ Correct">
|
|
555
564
|
|
|
556
565
|
```ts option='{ "default": ["public-static-field", "static-field", "instance-field"] }'
|
|
557
566
|
class Foo {
|
|
@@ -585,6 +594,9 @@ const foo = class {
|
|
|
585
594
|
};
|
|
586
595
|
```
|
|
587
596
|
|
|
597
|
+
</TabItem>
|
|
598
|
+
</Tabs>
|
|
599
|
+
|
|
588
600
|
#### Class Declarations
|
|
589
601
|
|
|
590
602
|
This config only specifies an order for classes: methods, then the constructor, then fields.
|
|
@@ -603,9 +615,8 @@ Default settings will be used for class declarations and all other syntax constr
|
|
|
603
615
|
}
|
|
604
616
|
```
|
|
605
617
|
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
##### ❌ Incorrect
|
|
618
|
+
<Tabs>
|
|
619
|
+
<TabItem value="❌ Incorrect">
|
|
609
620
|
|
|
610
621
|
```ts option='{ "classes": ["method", "constructor", "field"] }'
|
|
611
622
|
class Foo {
|
|
@@ -620,7 +631,8 @@ class Foo {
|
|
|
620
631
|
}
|
|
621
632
|
```
|
|
622
633
|
|
|
623
|
-
|
|
634
|
+
</TabItem>
|
|
635
|
+
<TabItem value="✅ Correct">
|
|
624
636
|
|
|
625
637
|
```ts option='{ "classes": ["method", "constructor", "field"] }'
|
|
626
638
|
class Foo {
|
|
@@ -635,6 +647,9 @@ class Foo {
|
|
|
635
647
|
}
|
|
636
648
|
```
|
|
637
649
|
|
|
650
|
+
</TabItem>
|
|
651
|
+
</Tabs>
|
|
652
|
+
|
|
638
653
|
#### Class Expressions
|
|
639
654
|
|
|
640
655
|
This config only specifies an order for classes expressions: methods, then the constructor, then fields.
|
|
@@ -653,9 +668,8 @@ Default settings will be used for class declarations and all other syntax constr
|
|
|
653
668
|
}
|
|
654
669
|
```
|
|
655
670
|
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
##### ❌ Incorrect
|
|
671
|
+
<Tabs>
|
|
672
|
+
<TabItem value="❌ Incorrect">
|
|
659
673
|
|
|
660
674
|
```ts option='{ "classExpressions": ["method", "constructor", "field"] }'
|
|
661
675
|
const foo = class {
|
|
@@ -670,7 +684,8 @@ const foo = class {
|
|
|
670
684
|
};
|
|
671
685
|
```
|
|
672
686
|
|
|
673
|
-
|
|
687
|
+
</TabItem>
|
|
688
|
+
<TabItem value="✅ Correct">
|
|
674
689
|
|
|
675
690
|
```ts option='{ "classExpressions": ["method", "constructor", "field"] }'
|
|
676
691
|
const foo = class {
|
|
@@ -685,6 +700,9 @@ const foo = class {
|
|
|
685
700
|
};
|
|
686
701
|
```
|
|
687
702
|
|
|
703
|
+
</TabItem>
|
|
704
|
+
</Tabs>
|
|
705
|
+
|
|
688
706
|
### Interfaces
|
|
689
707
|
|
|
690
708
|
This config only specifies an order for interfaces: signatures, then methods, then constructors, then fields.
|
|
@@ -707,9 +725,8 @@ These member types are the only ones allowed for `interfaces`.
|
|
|
707
725
|
}
|
|
708
726
|
```
|
|
709
727
|
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
#### ❌ Incorrect
|
|
728
|
+
<Tabs>
|
|
729
|
+
<TabItem value="❌ Incorrect">
|
|
713
730
|
|
|
714
731
|
```ts option='{ "interfaces": ["signature", "method", "constructor", "field"] }'
|
|
715
732
|
interface Foo {
|
|
@@ -723,7 +740,8 @@ interface Foo {
|
|
|
723
740
|
}
|
|
724
741
|
```
|
|
725
742
|
|
|
726
|
-
|
|
743
|
+
</TabItem>
|
|
744
|
+
<TabItem value="✅ Correct">
|
|
727
745
|
|
|
728
746
|
```ts option='{ "interfaces": ["signature", "method", "constructor", "field"] }'
|
|
729
747
|
interface Foo {
|
|
@@ -737,6 +755,9 @@ interface Foo {
|
|
|
737
755
|
}
|
|
738
756
|
```
|
|
739
757
|
|
|
758
|
+
</TabItem>
|
|
759
|
+
</Tabs>
|
|
760
|
+
|
|
740
761
|
### Type Literals
|
|
741
762
|
|
|
742
763
|
This config only specifies an order for type literals: signatures, then methods, then constructors, then fields.
|
|
@@ -759,9 +780,8 @@ These member types are the only ones allowed for `typeLiterals`.
|
|
|
759
780
|
}
|
|
760
781
|
```
|
|
761
782
|
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
#### ❌ Incorrect
|
|
783
|
+
<Tabs>
|
|
784
|
+
<TabItem value="❌ Incorrect">
|
|
765
785
|
|
|
766
786
|
```ts option='{ "typeLiterals": ["signature", "method", "constructor", "field"] }'
|
|
767
787
|
type Foo = {
|
|
@@ -775,7 +795,8 @@ type Foo = {
|
|
|
775
795
|
};
|
|
776
796
|
```
|
|
777
797
|
|
|
778
|
-
|
|
798
|
+
</TabItem>
|
|
799
|
+
<TabItem value="✅ Correct">
|
|
779
800
|
|
|
780
801
|
```ts option='{ "typeLiterals": ["signature", "method", "constructor", "field"] }'
|
|
781
802
|
type Foo = {
|
|
@@ -789,11 +810,13 @@ type Foo = {
|
|
|
789
810
|
};
|
|
790
811
|
```
|
|
791
812
|
|
|
813
|
+
</TabItem>
|
|
814
|
+
</Tabs>
|
|
815
|
+
|
|
792
816
|
### Sorting Options
|
|
793
817
|
|
|
794
818
|
#### Sorting Alphabetically Within Member Groups
|
|
795
819
|
|
|
796
|
-
This config specifies that within each `memberTypes` group, members are in an alphabetic case-sensitive order.
|
|
797
820
|
The default member order will be applied if `memberTypes` is not specified.
|
|
798
821
|
You can see the default order in [Default Configuration](#default-configuration).
|
|
799
822
|
|
|
@@ -813,9 +836,8 @@ You can see the default order in [Default Configuration](#default-configuration)
|
|
|
813
836
|
}
|
|
814
837
|
```
|
|
815
838
|
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
##### ❌ Incorrect
|
|
839
|
+
<Tabs>
|
|
840
|
+
<TabItem value="❌ Incorrect">
|
|
819
841
|
|
|
820
842
|
```ts option='{"default":{"order":"alphabetically"}}'
|
|
821
843
|
interface Foo {
|
|
@@ -829,7 +851,8 @@ interface Foo {
|
|
|
829
851
|
}
|
|
830
852
|
```
|
|
831
853
|
|
|
832
|
-
|
|
854
|
+
</TabItem>
|
|
855
|
+
<TabItem value="✅ Correct">
|
|
833
856
|
|
|
834
857
|
```ts option='{"default":{"order":"alphabetically"}}'
|
|
835
858
|
interface Foo {
|
|
@@ -843,6 +866,9 @@ interface Foo {
|
|
|
843
866
|
}
|
|
844
867
|
```
|
|
845
868
|
|
|
869
|
+
</TabItem>
|
|
870
|
+
</Tabs>
|
|
871
|
+
|
|
846
872
|
#### Sorting Alphabetically Within Custom Member Groups
|
|
847
873
|
|
|
848
874
|
This config specifies that within each custom `memberTypes` group, members are in an alphabetic case-sensitive order.
|
|
@@ -864,9 +890,8 @@ This config specifies that within each custom `memberTypes` group, members are i
|
|
|
864
890
|
}
|
|
865
891
|
```
|
|
866
892
|
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
##### ❌ Incorrect
|
|
893
|
+
<Tabs>
|
|
894
|
+
<TabItem value="❌ Incorrect">
|
|
870
895
|
|
|
871
896
|
```ts option='{"default":{"memberTypes":["method","field"],"order":"alphabetically"}}'
|
|
872
897
|
interface Foo {
|
|
@@ -880,7 +905,8 @@ interface Foo {
|
|
|
880
905
|
}
|
|
881
906
|
```
|
|
882
907
|
|
|
883
|
-
|
|
908
|
+
</TabItem>
|
|
909
|
+
<TabItem value="✅ Correct">
|
|
884
910
|
|
|
885
911
|
```ts option='{"default":{"memberTypes":["method","field"],"order":"alphabetically"}}'
|
|
886
912
|
interface Foo {
|
|
@@ -894,9 +920,11 @@ interface Foo {
|
|
|
894
920
|
}
|
|
895
921
|
```
|
|
896
922
|
|
|
923
|
+
</TabItem>
|
|
924
|
+
</Tabs>
|
|
925
|
+
|
|
897
926
|
#### Sorting Alphabetically Case Insensitive Within Member Groups
|
|
898
927
|
|
|
899
|
-
This config specifies that within each `memberTypes` group, members are in an alphabetic case-insensitive order.
|
|
900
928
|
The default member order will be applied if `memberTypes` is not specified.
|
|
901
929
|
You can see the default order in [Default Configuration](#default-configuration).
|
|
902
930
|
|
|
@@ -916,9 +944,8 @@ You can see the default order in [Default Configuration](#default-configuration)
|
|
|
916
944
|
}
|
|
917
945
|
```
|
|
918
946
|
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
##### ❌ Incorrect
|
|
947
|
+
<Tabs>
|
|
948
|
+
<TabItem value="❌ Incorrect">
|
|
922
949
|
|
|
923
950
|
```ts option='{"default":{"order":"alphabetically-case-insensitive"}}'
|
|
924
951
|
interface Foo {
|
|
@@ -932,7 +959,8 @@ interface Foo {
|
|
|
932
959
|
}
|
|
933
960
|
```
|
|
934
961
|
|
|
935
|
-
|
|
962
|
+
</TabItem>
|
|
963
|
+
<TabItem value="✅ Correct">
|
|
936
964
|
|
|
937
965
|
```ts option='{"default":{"order":"alphabetically-case-insensitive"}}'
|
|
938
966
|
interface Foo {
|
|
@@ -946,6 +974,9 @@ interface Foo {
|
|
|
946
974
|
}
|
|
947
975
|
```
|
|
948
976
|
|
|
977
|
+
</TabItem>
|
|
978
|
+
</Tabs>
|
|
979
|
+
|
|
949
980
|
#### Sorting Alphabetically Ignoring Member Groups
|
|
950
981
|
|
|
951
982
|
This config specifies that members are all sorted in an alphabetic case-sensitive order.
|
|
@@ -963,9 +994,8 @@ It ignores any member group types completely by specifying `"never"` for `member
|
|
|
963
994
|
}
|
|
964
995
|
```
|
|
965
996
|
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
##### ❌ Incorrect
|
|
997
|
+
<Tabs>
|
|
998
|
+
<TabItem value="❌ Incorrect">
|
|
969
999
|
|
|
970
1000
|
```ts option='{ "default": { "memberTypes": "never", "order": "alphabetically" } }'
|
|
971
1001
|
interface Foo {
|
|
@@ -978,7 +1008,8 @@ interface Foo {
|
|
|
978
1008
|
}
|
|
979
1009
|
```
|
|
980
1010
|
|
|
981
|
-
|
|
1011
|
+
</TabItem>
|
|
1012
|
+
<TabItem value="✅ Correct">
|
|
982
1013
|
|
|
983
1014
|
```ts option='{ "default": { "memberTypes": "never", "order": "alphabetically" } }'
|
|
984
1015
|
interface Foo {
|
|
@@ -991,6 +1022,9 @@ interface Foo {
|
|
|
991
1022
|
}
|
|
992
1023
|
```
|
|
993
1024
|
|
|
1025
|
+
</TabItem>
|
|
1026
|
+
</Tabs>
|
|
1027
|
+
|
|
994
1028
|
#### Sorting Optional Members First or Last
|
|
995
1029
|
|
|
996
1030
|
The `optionalityOrder` option may be enabled to place all optional members in a group at the beginning or end of that group.
|
|
@@ -1014,9 +1048,8 @@ This config places all optional members before all required members:
|
|
|
1014
1048
|
}
|
|
1015
1049
|
```
|
|
1016
1050
|
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
##### ❌ Incorrect
|
|
1051
|
+
<Tabs>
|
|
1052
|
+
<TabItem value="❌ Incorrect">
|
|
1020
1053
|
|
|
1021
1054
|
```ts option='{ "default": { "optionalityOrder": "optional-first", "order": "alphabetically" } }'
|
|
1022
1055
|
interface Foo {
|
|
@@ -1026,7 +1059,8 @@ interface Foo {
|
|
|
1026
1059
|
}
|
|
1027
1060
|
```
|
|
1028
1061
|
|
|
1029
|
-
|
|
1062
|
+
</TabItem>
|
|
1063
|
+
<TabItem value="✅ Correct">
|
|
1030
1064
|
|
|
1031
1065
|
```ts option='{ "default": { "optionalityOrder": "optional-first", "order": "alphabetically" } }'
|
|
1032
1066
|
interface Foo {
|
|
@@ -1036,7 +1070,8 @@ interface Foo {
|
|
|
1036
1070
|
}
|
|
1037
1071
|
```
|
|
1038
1072
|
|
|
1039
|
-
|
|
1073
|
+
</TabItem>
|
|
1074
|
+
</Tabs>
|
|
1040
1075
|
|
|
1041
1076
|
This config places all required members before all optional members:
|
|
1042
1077
|
|
|
@@ -1057,9 +1092,8 @@ This config places all required members before all optional members:
|
|
|
1057
1092
|
}
|
|
1058
1093
|
```
|
|
1059
1094
|
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
##### ❌ Incorrect
|
|
1095
|
+
<Tabs>
|
|
1096
|
+
<TabItem value="❌ Incorrect">
|
|
1063
1097
|
|
|
1064
1098
|
```ts option='{ "default": { "optionalityOrder": "required-first", "order": "alphabetically" } }'
|
|
1065
1099
|
interface Foo {
|
|
@@ -1069,7 +1103,8 @@ interface Foo {
|
|
|
1069
1103
|
}
|
|
1070
1104
|
```
|
|
1071
1105
|
|
|
1072
|
-
|
|
1106
|
+
</TabItem>
|
|
1107
|
+
<TabItem value="✅ Correct">
|
|
1073
1108
|
|
|
1074
1109
|
```ts option='{ "default": { "optionalityOrder": "required-first", "order": "alphabetically" } }'
|
|
1075
1110
|
interface Foo {
|
|
@@ -1079,7 +1114,8 @@ interface Foo {
|
|
|
1079
1114
|
}
|
|
1080
1115
|
```
|
|
1081
1116
|
|
|
1082
|
-
|
|
1117
|
+
</TabItem>
|
|
1118
|
+
</Tabs>
|
|
1083
1119
|
|
|
1084
1120
|
## All Supported Options
|
|
1085
1121
|
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
description: 'Enforce using a particular method signature syntax.'
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
+
import Tabs from '@theme/Tabs';
|
|
6
|
+
import TabItem from '@theme/TabItem';
|
|
7
|
+
|
|
5
8
|
> 🛑 This file is source code, not the primary documentation location! 🛑
|
|
6
9
|
>
|
|
7
10
|
> See **https://typescript-eslint.io/rules/method-signature-style** for documentation.
|
|
@@ -42,9 +45,8 @@ The default is `"property"`.
|
|
|
42
45
|
|
|
43
46
|
Examples of code with `property` option.
|
|
44
47
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
#### ❌ Incorrect
|
|
48
|
+
<Tabs>
|
|
49
|
+
<TabItem value="❌ Incorrect">
|
|
48
50
|
|
|
49
51
|
```ts option='"property"'
|
|
50
52
|
interface T1 {
|
|
@@ -60,7 +62,8 @@ interface T3 {
|
|
|
60
62
|
}
|
|
61
63
|
```
|
|
62
64
|
|
|
63
|
-
|
|
65
|
+
</TabItem>
|
|
66
|
+
<TabItem value="✅ Correct">
|
|
64
67
|
|
|
65
68
|
```ts option='"property"'
|
|
66
69
|
interface T1 {
|
|
@@ -77,13 +80,15 @@ interface T3 {
|
|
|
77
80
|
}
|
|
78
81
|
```
|
|
79
82
|
|
|
83
|
+
</TabItem>
|
|
84
|
+
</Tabs>
|
|
85
|
+
|
|
80
86
|
### `method`
|
|
81
87
|
|
|
82
88
|
Examples of code with `method` option.
|
|
83
89
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
#### ❌ Incorrect
|
|
90
|
+
<Tabs>
|
|
91
|
+
<TabItem value="❌ Incorrect">
|
|
87
92
|
|
|
88
93
|
```ts option='"method"'
|
|
89
94
|
interface T1 {
|
|
@@ -94,7 +99,8 @@ type T2 = {
|
|
|
94
99
|
};
|
|
95
100
|
```
|
|
96
101
|
|
|
97
|
-
|
|
102
|
+
</TabItem>
|
|
103
|
+
<TabItem value="✅ Correct">
|
|
98
104
|
|
|
99
105
|
```ts option='"method"'
|
|
100
106
|
interface T1 {
|
|
@@ -105,6 +111,9 @@ type T2 = {
|
|
|
105
111
|
};
|
|
106
112
|
```
|
|
107
113
|
|
|
114
|
+
</TabItem>
|
|
115
|
+
</Tabs>
|
|
116
|
+
|
|
108
117
|
## When Not To Use It
|
|
109
118
|
|
|
110
119
|
If you don't want to enforce a particular style for object/interface function types, and/or if you don't use `strictFunctionTypes`, then you don't need this rule.
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
description: 'Enforce naming conventions for everything across a codebase.'
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
+
import Tabs from '@theme/Tabs';
|
|
6
|
+
import TabItem from '@theme/TabItem';
|
|
7
|
+
|
|
5
8
|
> 🛑 This file is source code, not the primary documentation location! 🛑
|
|
6
9
|
>
|
|
7
10
|
> See **https://typescript-eslint.io/rules/naming-convention** for documentation.
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
description: 'Disallow generic `Array` constructors.'
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
+
import Tabs from '@theme/Tabs';
|
|
6
|
+
import TabItem from '@theme/TabItem';
|
|
7
|
+
|
|
5
8
|
> 🛑 This file is source code, not the primary documentation location! 🛑
|
|
6
9
|
>
|
|
7
10
|
> See **https://typescript-eslint.io/rules/no-array-constructor** for documentation.
|
|
@@ -9,16 +12,16 @@ description: 'Disallow generic `Array` constructors.'
|
|
|
9
12
|
This rule extends the base [`eslint/no-array-constructor`](https://eslint.org/docs/rules/no-array-constructor) rule.
|
|
10
13
|
It adds support for the generically typed `Array` constructor (`new Array<Foo>()`).
|
|
11
14
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
### ❌ Incorrect
|
|
15
|
+
<Tabs>
|
|
16
|
+
<TabItem value="❌ Incorrect">
|
|
15
17
|
|
|
16
18
|
```ts
|
|
17
19
|
Array(0, 1, 2);
|
|
18
20
|
new Array(0, 1, 2);
|
|
19
21
|
```
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
</TabItem>
|
|
24
|
+
<TabItem value="✅ Correct">
|
|
22
25
|
|
|
23
26
|
```ts
|
|
24
27
|
Array<number>(0, 1, 2);
|
|
@@ -27,3 +30,6 @@ new Array<Foo>(x, y, z);
|
|
|
27
30
|
Array(500);
|
|
28
31
|
new Array(someOtherArray.length);
|
|
29
32
|
```
|
|
33
|
+
|
|
34
|
+
</TabItem>
|
|
35
|
+
</Tabs>
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
description: 'Disallow using the `delete` operator on array values.'
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
+
import Tabs from '@theme/Tabs';
|
|
6
|
+
import TabItem from '@theme/TabItem';
|
|
7
|
+
|
|
5
8
|
> 🛑 This file is source code, not the primary documentation location! 🛑
|
|
6
9
|
>
|
|
7
10
|
> See **https://typescript-eslint.io/rules/no-array-delete** for documentation.
|
|
@@ -15,9 +18,8 @@ the recommended way to remove an element from an array is by using the
|
|
|
15
18
|
|
|
16
19
|
## Examples
|
|
17
20
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
### ❌ Incorrect
|
|
21
|
+
<Tabs>
|
|
22
|
+
<TabItem value="❌ Incorrect">
|
|
21
23
|
|
|
22
24
|
```ts
|
|
23
25
|
declare const arr: number[];
|
|
@@ -25,7 +27,8 @@ declare const arr: number[];
|
|
|
25
27
|
delete arr[0];
|
|
26
28
|
```
|
|
27
29
|
|
|
28
|
-
|
|
30
|
+
</TabItem>
|
|
31
|
+
<TabItem value="✅ Correct">
|
|
29
32
|
|
|
30
33
|
```ts
|
|
31
34
|
declare const arr: number[];
|
|
@@ -33,7 +36,8 @@ declare const arr: number[];
|
|
|
33
36
|
arr.splice(0, 1);
|
|
34
37
|
```
|
|
35
38
|
|
|
36
|
-
|
|
39
|
+
</TabItem>
|
|
40
|
+
</Tabs>
|
|
37
41
|
|
|
38
42
|
## When Not To Use It
|
|
39
43
|
|