xo 0.46.4 → 0.47.0

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.
Files changed (80) hide show
  1. package/config/plugins.cjs +2 -7
  2. package/index.js +7 -1
  3. package/node_modules/@typescript-eslint/eslint-plugin/README.md +2 -2
  4. package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/explicit-member-accessibility.js +3 -0
  5. package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/explicit-member-accessibility.js.map +1 -1
  6. package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/no-base-to-string.js +2 -1
  7. package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/no-base-to-string.js.map +1 -1
  8. package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/no-confusing-non-null-assertion.js.map +1 -1
  9. package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/no-floating-promises.js +5 -1
  10. package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/no-floating-promises.js.map +1 -1
  11. package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/no-implied-eval.js +10 -1
  12. package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/no-implied-eval.js.map +1 -1
  13. package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/prefer-for-of.js.map +1 -1
  14. package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/prefer-string-starts-ends-with.js.map +1 -1
  15. package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/restrict-plus-operands.js.map +1 -1
  16. package/node_modules/@typescript-eslint/eslint-plugin/dist/util/collectUnusedVariables.js +5 -24
  17. package/node_modules/@typescript-eslint/eslint-plugin/dist/util/collectUnusedVariables.js.map +1 -1
  18. package/node_modules/@typescript-eslint/eslint-plugin/dist/util/isTypeReadonly.js +4 -3
  19. package/node_modules/@typescript-eslint/eslint-plugin/dist/util/isTypeReadonly.js.map +1 -1
  20. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/README.md +159 -0
  21. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/comma-dangle.md +1 -1
  22. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/consistent-indexed-object-style.md +5 -2
  23. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/explicit-module-boundary-types.md +0 -2
  24. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/member-delimiter-style.md +29 -26
  25. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-inferrable-types.md +2 -2
  26. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/object-curly-spacing.md +1 -1
  27. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/padding-line-between-statements.md +3 -1
  28. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-string-starts-ends-with.md +2 -2
  29. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/require-array-sort-compare.md +5 -1
  30. package/node_modules/@typescript-eslint/eslint-plugin/package.json +4 -4
  31. package/node_modules/@typescript-eslint/experimental-utils/dist/ast-utils/predicates.d.ts +12 -12
  32. package/node_modules/@typescript-eslint/experimental-utils/dist/eslint-utils/RuleCreator.d.ts +30 -8
  33. package/node_modules/@typescript-eslint/experimental-utils/dist/eslint-utils/RuleCreator.d.ts.map +1 -1
  34. package/node_modules/@typescript-eslint/experimental-utils/dist/eslint-utils/RuleCreator.js +36 -8
  35. package/node_modules/@typescript-eslint/experimental-utils/dist/eslint-utils/RuleCreator.js.map +1 -1
  36. package/node_modules/@typescript-eslint/experimental-utils/dist/ts-eslint/Rule.d.ts +2 -2
  37. package/node_modules/@typescript-eslint/experimental-utils/dist/ts-eslint/Rule.d.ts.map +1 -1
  38. package/node_modules/@typescript-eslint/experimental-utils/package.json +5 -5
  39. package/node_modules/@typescript-eslint/parser/package.json +6 -6
  40. package/node_modules/@typescript-eslint/scope-manager/dist/referencer/PatternVisitor.d.ts +1 -1
  41. package/node_modules/@typescript-eslint/scope-manager/dist/referencer/PatternVisitor.d.ts.map +1 -1
  42. package/node_modules/@typescript-eslint/scope-manager/dist/referencer/PatternVisitor.js +2 -2
  43. package/node_modules/@typescript-eslint/scope-manager/dist/referencer/PatternVisitor.js.map +1 -1
  44. package/node_modules/@typescript-eslint/scope-manager/dist/referencer/Referencer.d.ts +1 -0
  45. package/node_modules/@typescript-eslint/scope-manager/dist/referencer/Referencer.d.ts.map +1 -1
  46. package/node_modules/@typescript-eslint/scope-manager/dist/referencer/Referencer.js +3 -0
  47. package/node_modules/@typescript-eslint/scope-manager/dist/referencer/Referencer.js.map +1 -1
  48. package/node_modules/@typescript-eslint/scope-manager/package.json +5 -5
  49. package/node_modules/@typescript-eslint/types/dist/ast-spec.d.ts +21 -7
  50. package/node_modules/@typescript-eslint/types/dist/ast-spec.d.ts.map +1 -1
  51. package/node_modules/@typescript-eslint/types/dist/ast-spec.js +1 -0
  52. package/node_modules/@typescript-eslint/types/dist/ast-spec.js.map +1 -1
  53. package/node_modules/@typescript-eslint/types/package.json +2 -2
  54. package/node_modules/@typescript-eslint/typescript-estree/dist/convert.d.ts +1 -0
  55. package/node_modules/@typescript-eslint/typescript-estree/dist/convert.d.ts.map +1 -1
  56. package/node_modules/@typescript-eslint/typescript-estree/dist/convert.js +23 -2
  57. package/node_modules/@typescript-eslint/typescript-estree/dist/convert.js.map +1 -1
  58. package/node_modules/@typescript-eslint/typescript-estree/dist/parser.js +2 -2
  59. package/node_modules/@typescript-eslint/typescript-estree/dist/ts-estree/estree-to-ts-node-types.d.ts +1 -0
  60. package/node_modules/@typescript-eslint/typescript-estree/dist/ts-estree/estree-to-ts-node-types.d.ts.map +1 -1
  61. package/node_modules/@typescript-eslint/typescript-estree/dist/ts-estree/ts-nodes.d.ts +1 -1
  62. package/node_modules/@typescript-eslint/typescript-estree/dist/ts-estree/ts-nodes.d.ts.map +1 -1
  63. package/node_modules/@typescript-eslint/typescript-estree/package.json +5 -5
  64. package/node_modules/@typescript-eslint/visitor-keys/dist/visitor-keys.d.ts.map +1 -1
  65. package/node_modules/@typescript-eslint/visitor-keys/dist/visitor-keys.js +2 -0
  66. package/node_modules/@typescript-eslint/visitor-keys/dist/visitor-keys.js.map +1 -1
  67. package/node_modules/@typescript-eslint/visitor-keys/package.json +3 -3
  68. package/node_modules/eslint-visitor-keys/README.md +3 -2
  69. package/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.cjs +3 -0
  70. package/node_modules/eslint-visitor-keys/lib/visitor-keys.js +3 -0
  71. package/node_modules/eslint-visitor-keys/package.json +2 -2
  72. package/package.json +15 -15
  73. package/node_modules/@typescript-eslint/eslint-plugin/CHANGELOG.md +0 -2294
  74. package/node_modules/@typescript-eslint/experimental-utils/CHANGELOG.md +0 -1269
  75. package/node_modules/@typescript-eslint/parser/CHANGELOG.md +0 -1291
  76. package/node_modules/@typescript-eslint/scope-manager/CHANGELOG.md +0 -681
  77. package/node_modules/@typescript-eslint/types/CHANGELOG.md +0 -661
  78. package/node_modules/@typescript-eslint/typescript-estree/CHANGELOG.md +0 -1492
  79. package/node_modules/@typescript-eslint/visitor-keys/CHANGELOG.md +0 -630
  80. package/node_modules/eslint-visitor-keys/CHANGELOG.md +0 -42
@@ -0,0 +1,159 @@
1
+ ---
2
+ title: Overview
3
+ sidebar_label: Overview
4
+ pagination_next: null
5
+ pagination_prev: null
6
+ slug: /
7
+ ---
8
+
9
+ `@typescript-eslint/eslint-plugin` comes with two rulesets you can extend from to pull in the recommended starting rules:
10
+
11
+ - `'plugin:@typescript-eslint/recommended'`: recommended rules for code correctness that you can drop in without additional configuration.
12
+ See [Linting](/docs/linting/linting) for more details.
13
+ - `'plugin:@typescript-eslint/recommended-requiring-type-checking'` additional recommended rules that require type information.
14
+ See [Linting](/docs/linting/type-linting) for more details.
15
+
16
+ ## Supported Rules
17
+
18
+ <!-- begin base rule list -->
19
+
20
+ **Key**: :white_check_mark: = recommended, :wrench: = fixable, :thought_balloon: = requires type information
21
+
22
+ | Name | Description | :white_check_mark: | :wrench: | :thought_balloon: |
23
+ | ------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------- | ------------------ | -------- | ----------------- |
24
+ | [`@typescript-eslint/adjacent-overload-signatures`](./adjacent-overload-signatures.md) | Require that member overloads be consecutive | :white_check_mark: | | |
25
+ | [`@typescript-eslint/array-type`](./array-type.md) | Requires using either `T[]` or `Array<T>` for arrays | | :wrench: | |
26
+ | [`@typescript-eslint/await-thenable`](./await-thenable.md) | Disallows awaiting a value that is not a Thenable | :white_check_mark: | | :thought_balloon: |
27
+ | [`@typescript-eslint/ban-ts-comment`](./ban-ts-comment.md) | Bans `@ts-<directive>` comments from being used or requires descriptions after directive | :white_check_mark: | | |
28
+ | [`@typescript-eslint/ban-tslint-comment`](./ban-tslint-comment.md) | Bans `// tslint:<rule-flag>` comments from being used | | :wrench: | |
29
+ | [`@typescript-eslint/ban-types`](./ban-types.md) | Bans specific types from being used | :white_check_mark: | :wrench: | |
30
+ | [`@typescript-eslint/class-literal-property-style`](./class-literal-property-style.md) | Ensures that literals on classes are exposed in a consistent style | | :wrench: | |
31
+ | [`@typescript-eslint/consistent-indexed-object-style`](./consistent-indexed-object-style.md) | Enforce or disallow the use of the record type | | :wrench: | |
32
+ | [`@typescript-eslint/consistent-type-assertions`](./consistent-type-assertions.md) | Enforces consistent usage of type assertions | | | |
33
+ | [`@typescript-eslint/consistent-type-definitions`](./consistent-type-definitions.md) | Consistent with type definition either `interface` or `type` | | :wrench: | |
34
+ | [`@typescript-eslint/consistent-type-exports`](./consistent-type-exports.md) | Enforces consistent usage of type exports | | :wrench: | :thought_balloon: |
35
+ | [`@typescript-eslint/consistent-type-imports`](./consistent-type-imports.md) | Enforces consistent usage of type imports | | :wrench: | |
36
+ | [`@typescript-eslint/explicit-function-return-type`](./explicit-function-return-type.md) | Require explicit return types on functions and class methods | | | |
37
+ | [`@typescript-eslint/explicit-member-accessibility`](./explicit-member-accessibility.md) | Require explicit accessibility modifiers on class properties and methods | | :wrench: | |
38
+ | [`@typescript-eslint/explicit-module-boundary-types`](./explicit-module-boundary-types.md) | Require explicit return and argument types on exported functions' and classes' public class methods | | | |
39
+ | [`@typescript-eslint/member-delimiter-style`](./member-delimiter-style.md) | Require a specific member delimiter style for interfaces and type literals | | :wrench: | |
40
+ | [`@typescript-eslint/member-ordering`](./member-ordering.md) | Require a consistent member declaration order | | | |
41
+ | [`@typescript-eslint/method-signature-style`](./method-signature-style.md) | Enforces using a particular method signature syntax. | | :wrench: | |
42
+ | [`@typescript-eslint/naming-convention`](./naming-convention.md) | Enforces naming conventions for everything across a codebase | | | :thought_balloon: |
43
+ | [`@typescript-eslint/no-base-to-string`](./no-base-to-string.md) | Requires that `.toString()` is only called on objects which provide useful information when stringified | | | :thought_balloon: |
44
+ | [`@typescript-eslint/no-confusing-non-null-assertion`](./no-confusing-non-null-assertion.md) | Disallow non-null assertion in locations that may be confusing | | :wrench: | |
45
+ | [`@typescript-eslint/no-confusing-void-expression`](./no-confusing-void-expression.md) | Requires expressions of type void to appear in statement position | | :wrench: | :thought_balloon: |
46
+ | [`@typescript-eslint/no-dynamic-delete`](./no-dynamic-delete.md) | Disallow the delete operator with computed key expressions | | :wrench: | |
47
+ | [`@typescript-eslint/no-empty-interface`](./no-empty-interface.md) | Disallow the declaration of empty interfaces | :white_check_mark: | :wrench: | |
48
+ | [`@typescript-eslint/no-explicit-any`](./no-explicit-any.md) | Disallow usage of the `any` type | :white_check_mark: | :wrench: | |
49
+ | [`@typescript-eslint/no-extra-non-null-assertion`](./no-extra-non-null-assertion.md) | Disallow extra non-null assertion | :white_check_mark: | :wrench: | |
50
+ | [`@typescript-eslint/no-extraneous-class`](./no-extraneous-class.md) | Forbids the use of classes as namespaces | | | |
51
+ | [`@typescript-eslint/no-floating-promises`](./no-floating-promises.md) | Requires Promise-like values to be handled appropriately | :white_check_mark: | | :thought_balloon: |
52
+ | [`@typescript-eslint/no-for-in-array`](./no-for-in-array.md) | Disallow iterating over an array with a for-in loop | :white_check_mark: | | :thought_balloon: |
53
+ | [`@typescript-eslint/no-inferrable-types`](./no-inferrable-types.md) | Disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean | :white_check_mark: | :wrench: | |
54
+ | [`@typescript-eslint/no-invalid-void-type`](./no-invalid-void-type.md) | Disallows usage of `void` type outside of generic or return types | | | |
55
+ | [`@typescript-eslint/no-meaningless-void-operator`](./no-meaningless-void-operator.md) | Disallow the `void` operator except when used to discard a value | | :wrench: | :thought_balloon: |
56
+ | [`@typescript-eslint/no-misused-new`](./no-misused-new.md) | Enforce valid definition of `new` and `constructor` | :white_check_mark: | | |
57
+ | [`@typescript-eslint/no-misused-promises`](./no-misused-promises.md) | Avoid using promises in places not designed to handle them | :white_check_mark: | | :thought_balloon: |
58
+ | [`@typescript-eslint/no-namespace`](./no-namespace.md) | Disallow the use of custom TypeScript modules and namespaces | :white_check_mark: | | |
59
+ | [`@typescript-eslint/no-non-null-asserted-nullish-coalescing`](./no-non-null-asserted-nullish-coalescing.md) | Disallows using a non-null assertion in the left operand of the nullish coalescing operator | | | |
60
+ | [`@typescript-eslint/no-non-null-asserted-optional-chain`](./no-non-null-asserted-optional-chain.md) | Disallows using a non-null assertion after an optional chain expression | :white_check_mark: | | |
61
+ | [`@typescript-eslint/no-non-null-assertion`](./no-non-null-assertion.md) | Disallows non-null assertions using the `!` postfix operator | :white_check_mark: | | |
62
+ | [`@typescript-eslint/no-parameter-properties`](./no-parameter-properties.md) | Disallow the use of parameter properties in class constructors | | | |
63
+ | [`@typescript-eslint/no-require-imports`](./no-require-imports.md) | Disallows invocation of `require()` | | | |
64
+ | [`@typescript-eslint/no-this-alias`](./no-this-alias.md) | Disallow aliasing `this` | :white_check_mark: | | |
65
+ | [`@typescript-eslint/no-type-alias`](./no-type-alias.md) | Disallow the use of type aliases | | | |
66
+ | [`@typescript-eslint/no-unnecessary-boolean-literal-compare`](./no-unnecessary-boolean-literal-compare.md) | Flags unnecessary equality comparisons against boolean literals | | :wrench: | :thought_balloon: |
67
+ | [`@typescript-eslint/no-unnecessary-condition`](./no-unnecessary-condition.md) | Prevents conditionals where the type is always truthy or always falsy | | :wrench: | :thought_balloon: |
68
+ | [`@typescript-eslint/no-unnecessary-qualifier`](./no-unnecessary-qualifier.md) | Warns when a namespace qualifier is unnecessary | | :wrench: | :thought_balloon: |
69
+ | [`@typescript-eslint/no-unnecessary-type-arguments`](./no-unnecessary-type-arguments.md) | Enforces that type arguments will not be used if not required | | :wrench: | :thought_balloon: |
70
+ | [`@typescript-eslint/no-unnecessary-type-assertion`](./no-unnecessary-type-assertion.md) | Warns if a type assertion does not change the type of an expression | :white_check_mark: | :wrench: | :thought_balloon: |
71
+ | [`@typescript-eslint/no-unnecessary-type-constraint`](./no-unnecessary-type-constraint.md) | Disallows unnecessary constraints on generic types | :white_check_mark: | :wrench: | |
72
+ | [`@typescript-eslint/no-unsafe-argument`](./no-unsafe-argument.md) | Disallows calling a function with an any type value | :white_check_mark: | | :thought_balloon: |
73
+ | [`@typescript-eslint/no-unsafe-assignment`](./no-unsafe-assignment.md) | Disallows assigning any to variables and properties | :white_check_mark: | | :thought_balloon: |
74
+ | [`@typescript-eslint/no-unsafe-call`](./no-unsafe-call.md) | Disallows calling an any type value | :white_check_mark: | | :thought_balloon: |
75
+ | [`@typescript-eslint/no-unsafe-member-access`](./no-unsafe-member-access.md) | Disallows member access on any typed variables | :white_check_mark: | | :thought_balloon: |
76
+ | [`@typescript-eslint/no-unsafe-return`](./no-unsafe-return.md) | Disallows returning any from a function | :white_check_mark: | | :thought_balloon: |
77
+ | [`@typescript-eslint/no-var-requires`](./no-var-requires.md) | Disallows the use of require statements except in import statements | :white_check_mark: | | |
78
+ | [`@typescript-eslint/non-nullable-type-assertion-style`](./non-nullable-type-assertion-style.md) | Prefers a non-null assertion over explicit type cast when possible | | :wrench: | :thought_balloon: |
79
+ | [`@typescript-eslint/prefer-as-const`](./prefer-as-const.md) | Prefer usage of `as const` over literal type | :white_check_mark: | :wrench: | |
80
+ | [`@typescript-eslint/prefer-enum-initializers`](./prefer-enum-initializers.md) | Prefer initializing each enums member value | | | |
81
+ | [`@typescript-eslint/prefer-for-of`](./prefer-for-of.md) | Prefer a ‘for-of’ loop over a standard ‘for’ loop if the index is only used to access the array being iterated | | | |
82
+ | [`@typescript-eslint/prefer-function-type`](./prefer-function-type.md) | Use function types instead of interfaces with call signatures | | :wrench: | |
83
+ | [`@typescript-eslint/prefer-includes`](./prefer-includes.md) | Enforce `includes` method over `indexOf` method | | :wrench: | :thought_balloon: |
84
+ | [`@typescript-eslint/prefer-literal-enum-member`](./prefer-literal-enum-member.md) | Require that all enum members be literal values to prevent unintended enum member name shadow issues | | | |
85
+ | [`@typescript-eslint/prefer-namespace-keyword`](./prefer-namespace-keyword.md) | Require the use of the `namespace` keyword instead of the `module` keyword to declare custom TypeScript modules | :white_check_mark: | :wrench: | |
86
+ | [`@typescript-eslint/prefer-nullish-coalescing`](./prefer-nullish-coalescing.md) | Enforce the usage of the nullish coalescing operator instead of logical chaining | | | :thought_balloon: |
87
+ | [`@typescript-eslint/prefer-optional-chain`](./prefer-optional-chain.md) | Prefer using concise optional chain expressions instead of chained logical ands | | | |
88
+ | [`@typescript-eslint/prefer-readonly`](./prefer-readonly.md) | Requires that private members are marked as `readonly` if they're never modified outside of the constructor | | :wrench: | :thought_balloon: |
89
+ | [`@typescript-eslint/prefer-readonly-parameter-types`](./prefer-readonly-parameter-types.md) | Requires that function parameters are typed as readonly to prevent accidental mutation of inputs | | | :thought_balloon: |
90
+ | [`@typescript-eslint/prefer-reduce-type-parameter`](./prefer-reduce-type-parameter.md) | Prefer using type parameter when calling `Array#reduce` instead of casting | | :wrench: | :thought_balloon: |
91
+ | [`@typescript-eslint/prefer-regexp-exec`](./prefer-regexp-exec.md) | Enforce that `RegExp#exec` is used instead of `String#match` if no global flag is provided | | :wrench: | :thought_balloon: |
92
+ | [`@typescript-eslint/prefer-return-this-type`](./prefer-return-this-type.md) | Enforce that `this` is used when only `this` type is returned | | :wrench: | :thought_balloon: |
93
+ | [`@typescript-eslint/prefer-string-starts-ends-with`](./prefer-string-starts-ends-with.md) | Enforce the use of `String#startsWith` and `String#endsWith` instead of other equivalent methods of checking substrings | | :wrench: | :thought_balloon: |
94
+ | [`@typescript-eslint/prefer-ts-expect-error`](./prefer-ts-expect-error.md) | Recommends using `@ts-expect-error` over `@ts-ignore` | | :wrench: | |
95
+ | [`@typescript-eslint/promise-function-async`](./promise-function-async.md) | Requires any function or method that returns a Promise to be marked async | | :wrench: | :thought_balloon: |
96
+ | [`@typescript-eslint/require-array-sort-compare`](./require-array-sort-compare.md) | Requires `Array#sort` calls to always provide a `compareFunction` | | | :thought_balloon: |
97
+ | [`@typescript-eslint/restrict-plus-operands`](./restrict-plus-operands.md) | When adding two variables, operands must both be of type number or of type string | :white_check_mark: | | :thought_balloon: |
98
+ | [`@typescript-eslint/restrict-template-expressions`](./restrict-template-expressions.md) | Enforce template literal expressions to be of string type | :white_check_mark: | | :thought_balloon: |
99
+ | [`@typescript-eslint/sort-type-union-intersection-members`](./sort-type-union-intersection-members.md) | Enforces that members of a type union/intersection are sorted alphabetically | | :wrench: | |
100
+ | [`@typescript-eslint/strict-boolean-expressions`](./strict-boolean-expressions.md) | Restricts the types allowed in boolean expressions | | :wrench: | :thought_balloon: |
101
+ | [`@typescript-eslint/switch-exhaustiveness-check`](./switch-exhaustiveness-check.md) | Exhaustiveness checking in switch with union type | | | :thought_balloon: |
102
+ | [`@typescript-eslint/triple-slash-reference`](./triple-slash-reference.md) | Sets preference level for triple slash directives versus ES6-style import declarations | :white_check_mark: | | |
103
+ | [`@typescript-eslint/type-annotation-spacing`](./type-annotation-spacing.md) | Require consistent spacing around type annotations | | :wrench: | |
104
+ | [`@typescript-eslint/typedef`](./typedef.md) | Requires type annotations to exist | | | |
105
+ | [`@typescript-eslint/unbound-method`](./unbound-method.md) | Enforces unbound methods are called with their expected scope | :white_check_mark: | | :thought_balloon: |
106
+ | [`@typescript-eslint/unified-signatures`](./unified-signatures.md) | Warns for any two overloads that could be unified into one by using a union or an optional/rest parameter | | | |
107
+
108
+ <!-- end base rule list -->
109
+
110
+ ### Extension Rules
111
+
112
+ In some cases, ESLint provides a rule itself, but it doesn't support TypeScript syntax; either it crashes, or it ignores the syntax, or it falsely reports against it.
113
+ In these cases, we create what we call an extension rule; a rule within our plugin that has the same functionality, but also supports TypeScript.
114
+
115
+ <!-- begin extension rule list -->
116
+
117
+ **Key**: :white_check_mark: = recommended, :wrench: = fixable, :thought_balloon: = requires type information
118
+
119
+ | Name | Description | :white_check_mark: | :wrench: | :thought_balloon: |
120
+ | -------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ | ------------------ | -------- | ----------------- |
121
+ | [`@typescript-eslint/brace-style`](./brace-style.md) | Enforce consistent brace style for blocks | | :wrench: | |
122
+ | [`@typescript-eslint/comma-dangle`](./comma-dangle.md) | Require or disallow trailing comma | | :wrench: | |
123
+ | [`@typescript-eslint/comma-spacing`](./comma-spacing.md) | Enforces consistent spacing before and after commas | | :wrench: | |
124
+ | [`@typescript-eslint/default-param-last`](./default-param-last.md) | Enforce default parameters to be last | | | |
125
+ | [`@typescript-eslint/dot-notation`](./dot-notation.md) | enforce dot notation whenever possible | | :wrench: | :thought_balloon: |
126
+ | [`@typescript-eslint/func-call-spacing`](./func-call-spacing.md) | Require or disallow spacing between function identifiers and their invocations | | :wrench: | |
127
+ | [`@typescript-eslint/indent`](./indent.md) | Enforce consistent indentation | | :wrench: | |
128
+ | [`@typescript-eslint/init-declarations`](./init-declarations.md) | require or disallow initialization in variable declarations | | | |
129
+ | [`@typescript-eslint/keyword-spacing`](./keyword-spacing.md) | Enforce consistent spacing before and after keywords | | :wrench: | |
130
+ | [`@typescript-eslint/lines-between-class-members`](./lines-between-class-members.md) | Require or disallow an empty line between class members | | :wrench: | |
131
+ | [`@typescript-eslint/no-array-constructor`](./no-array-constructor.md) | Disallow generic `Array` constructors | :white_check_mark: | :wrench: | |
132
+ | [`@typescript-eslint/no-dupe-class-members`](./no-dupe-class-members.md) | Disallow duplicate class members | | | |
133
+ | [`@typescript-eslint/no-duplicate-imports`](./no-duplicate-imports.md) | Disallow duplicate imports | | | |
134
+ | [`@typescript-eslint/no-empty-function`](./no-empty-function.md) | Disallow empty functions | :white_check_mark: | | |
135
+ | [`@typescript-eslint/no-extra-parens`](./no-extra-parens.md) | Disallow unnecessary parentheses | | :wrench: | |
136
+ | [`@typescript-eslint/no-extra-semi`](./no-extra-semi.md) | Disallow unnecessary semicolons | :white_check_mark: | :wrench: | |
137
+ | [`@typescript-eslint/no-implied-eval`](./no-implied-eval.md) | Disallow the use of `eval()`-like methods | :white_check_mark: | | :thought_balloon: |
138
+ | [`@typescript-eslint/no-invalid-this`](./no-invalid-this.md) | Disallow `this` keywords outside of classes or class-like objects | | | |
139
+ | [`@typescript-eslint/no-loop-func`](./no-loop-func.md) | Disallow function declarations that contain unsafe references inside loop statements | | | |
140
+ | [`@typescript-eslint/no-loss-of-precision`](./no-loss-of-precision.md) | Disallow literal numbers that lose precision | :white_check_mark: | | |
141
+ | [`@typescript-eslint/no-magic-numbers`](./no-magic-numbers.md) | Disallow magic numbers | | | |
142
+ | [`@typescript-eslint/no-redeclare`](./no-redeclare.md) | Disallow variable redeclaration | | | |
143
+ | [`@typescript-eslint/no-restricted-imports`](./no-restricted-imports.md) | Disallow specified modules when loaded by `import` | | | |
144
+ | [`@typescript-eslint/no-shadow`](./no-shadow.md) | Disallow variable declarations from shadowing variables declared in the outer scope | | | |
145
+ | [`@typescript-eslint/no-throw-literal`](./no-throw-literal.md) | Disallow throwing literals as exceptions | | | :thought_balloon: |
146
+ | [`@typescript-eslint/no-unused-expressions`](./no-unused-expressions.md) | Disallow unused expressions | | | |
147
+ | [`@typescript-eslint/no-unused-vars`](./no-unused-vars.md) | Disallow unused variables | :white_check_mark: | | |
148
+ | [`@typescript-eslint/no-use-before-define`](./no-use-before-define.md) | Disallow the use of variables before they are defined | | | |
149
+ | [`@typescript-eslint/no-useless-constructor`](./no-useless-constructor.md) | Disallow unnecessary constructors | | | |
150
+ | [`@typescript-eslint/object-curly-spacing`](./object-curly-spacing.md) | Enforce consistent spacing inside braces | | :wrench: | |
151
+ | [`@typescript-eslint/padding-line-between-statements`](./padding-line-between-statements.md) | require or disallow padding lines between statements | | :wrench: | |
152
+ | [`@typescript-eslint/quotes`](./quotes.md) | Enforce the consistent use of either backticks, double, or single quotes | | :wrench: | |
153
+ | [`@typescript-eslint/require-await`](./require-await.md) | Disallow async functions which have no `await` expression | :white_check_mark: | | :thought_balloon: |
154
+ | [`@typescript-eslint/return-await`](./return-await.md) | Enforces consistent returning of awaited values | | :wrench: | :thought_balloon: |
155
+ | [`@typescript-eslint/semi`](./semi.md) | Require or disallow semicolons instead of ASI | | :wrench: | |
156
+ | [`@typescript-eslint/space-before-function-paren`](./space-before-function-paren.md) | Enforces consistent spacing before function parenthesis | | :wrench: | |
157
+ | [`@typescript-eslint/space-infix-ops`](./space-infix-ops.md) | This rule is aimed at ensuring there are spaces around infix operators. | | :wrench: | |
158
+
159
+ <!-- end extension rule list -->
@@ -9,7 +9,7 @@ See the [ESLint documentation](https://eslint.org/docs/rules/comma-dangle) for m
9
9
 
10
10
  ## Rule Changes
11
11
 
12
- ```cjson
12
+ ```jsonc
13
13
  {
14
14
  // note you must disable the base rule as it can report incorrect errors
15
15
  "comma-dangle": "off",
@@ -20,9 +20,12 @@ type Foo = Record<string, unknown>;
20
20
 
21
21
  For example:
22
22
 
23
- ```CJSON
23
+ ```json
24
24
  {
25
- "@typescript-eslint/consistent-indexed-object-style": ["error", "index-signature"]
25
+ "@typescript-eslint/consistent-indexed-object-style": [
26
+ "error",
27
+ "index-signature"
28
+ ]
26
29
  }
27
30
  ```
28
31
 
@@ -2,8 +2,6 @@
2
2
 
3
3
  Explicit types for function return values and arguments makes it clear to any calling code what is the module boundary's input and output.
4
4
 
5
- Consider using this rule in place of [`no-untyped-public-signature`](./no-untyped-public-signature.md) which has been deprecated.
6
-
7
5
  ## Rule Details
8
6
 
9
7
  This rule aims to ensure that the values returned from a module are of the expected type.
@@ -78,17 +78,17 @@ type Config = BaseConfig & {
78
78
 
79
79
  Default config:
80
80
 
81
- ```JSON
81
+ ```json
82
82
  {
83
- "multiline": {
84
- "delimiter": "semi",
85
- "requireLast": true
86
- },
87
- "singleline": {
88
- "delimiter": "semi",
89
- "requireLast": false
90
- },
91
- "multilineDetection": "brackets"
83
+ "multiline": {
84
+ "delimiter": "semi",
85
+ "requireLast": true
86
+ },
87
+ "singleline": {
88
+ "delimiter": "semi",
89
+ "requireLast": false
90
+ },
91
+ "multilineDetection": "brackets"
92
92
  }
93
93
  ```
94
94
 
@@ -108,7 +108,10 @@ Accepts three values (or two for `singleline`):
108
108
  - `comma` - each member should be delimited with a comma (`,`).
109
109
  - `semi` - each member should be delimited with a semicolon (`;`).
110
110
  - `none` - each member should be delimited with nothing.
111
- - NOTE - this is not an option for `singleline` because having no delimiter between members on a single line is a syntax error in TS.
111
+
112
+ :::note
113
+ `none` is not an option for `singleline` because having no delimiter between members on a single line is a syntax error in TS.
114
+ :::
112
115
 
113
116
  ### `requireLast`
114
117
 
@@ -123,24 +126,24 @@ Allows you to specify options specifically for either `interface`s or `type` def
123
126
 
124
127
  For example, to require commas for `type`s, and semicolons for multiline `interface`s:
125
128
 
126
- ```JSON
129
+ ```json
127
130
  {
128
- "multiline": {
129
- "delimiter": "comma",
130
- "requireLast": true
131
- },
132
- "singleline": {
133
- "delimiter": "comma",
131
+ "multiline": {
132
+ "delimiter": "comma",
133
+ "requireLast": true
134
+ },
135
+ "singleline": {
136
+ "delimiter": "comma",
137
+ "requireLast": true
138
+ },
139
+ "overrides": {
140
+ "interface": {
141
+ "multiline": {
142
+ "delimiter": "semi",
134
143
  "requireLast": true
135
- },
136
- "overrides": {
137
- "interface": {
138
- "multiline": {
139
- "delimiter": "semi",
140
- "requireLast": true
141
- }
142
- }
144
+ }
143
145
  }
146
+ }
144
147
  }
145
148
  ```
146
149
 
@@ -22,10 +22,10 @@ interface Options {
22
22
 
23
23
  The default options are:
24
24
 
25
- ```JSON
25
+ ```json
26
26
  {
27
27
  "ignoreParameters": false,
28
- "ignoreProperties": false,
28
+ "ignoreProperties": false
29
29
  }
30
30
  ```
31
31
 
@@ -7,7 +7,7 @@ It adds support for TypeScript's object types.
7
7
 
8
8
  ## How to use
9
9
 
10
- ```cjson
10
+ ```jsonc
11
11
  {
12
12
  // note you must disable the base rule as it can report incorrect errors
13
13
  "object-curly-spacing": "off",
@@ -43,7 +43,9 @@ This rule extends the base [`eslint/padding-line-between-statements`](https://es
43
43
 
44
44
  See [`eslint/padding-line-between-statements` options](https://eslint.org/docs/rules/padding-line-between-statements#options).
45
45
 
46
- **Note** - In addition to options provided by ESLint, we have also added options for `interface` and `type`.
46
+ In addition to options provided by ESLint, `interface` and `type` can be used as statement types.
47
+
48
+ **Note:** ESLint `cjs-export` and `cjs-import` statement types are renamed to `exports` and `require` respectively.
47
49
 
48
50
  <sup>Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/master/docs/rules/padding-line-between-statements.md)</sup>
49
51
 
@@ -43,9 +43,9 @@ foo.endsWith('bar');
43
43
 
44
44
  There are no options.
45
45
 
46
- ```JSON
46
+ ```json
47
47
  {
48
- "@typescript-eslint/prefer-string-starts-ends-with": "error"
48
+ "@typescript-eslint/prefer-string-starts-ends-with": "error"
49
49
  }
50
50
  ```
51
51
 
@@ -13,7 +13,11 @@ When sorting numbers, this results in the classic "10 before 2" order:
13
13
 
14
14
  This also means that `Array#sort` does not always sort consistently, as elements may have custom `#toString` implementations that are not deterministic; this trap is noted in the language specification thusly:
15
15
 
16
- > NOTE 2: Method calls performed by the `ToString` abstract operations in steps 5 and 7 have the potential to cause `SortCompare` to not behave as a consistent comparison function.<br> > https://www.ecma-international.org/ecma-262/9.0/#sec-sortcompare
16
+ :::note
17
+ Method calls performed by the `ToString` abstract operations in steps 5 and 7 have the potential to cause `SortCompare` to not behave as a consistent comparison function.
18
+
19
+ https://www.ecma-international.org/ecma-262/9.0/#sec-sortcompare
20
+ :::
17
21
 
18
22
  ## Rule Details
19
23
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typescript-eslint/eslint-plugin",
3
- "version": "5.3.0",
3
+ "version": "5.4.0",
4
4
  "description": "TypeScript plugin for ESLint",
5
5
  "keywords": [
6
6
  "eslint",
@@ -44,8 +44,8 @@
44
44
  "typecheck": "tsc -p tsconfig.json --noEmit"
45
45
  },
46
46
  "dependencies": {
47
- "@typescript-eslint/experimental-utils": "5.3.0",
48
- "@typescript-eslint/scope-manager": "5.3.0",
47
+ "@typescript-eslint/experimental-utils": "5.4.0",
48
+ "@typescript-eslint/scope-manager": "5.4.0",
49
49
  "debug": "^4.3.2",
50
50
  "functional-red-black-tree": "^1.0.1",
51
51
  "ignore": "^5.1.8",
@@ -75,5 +75,5 @@
75
75
  "type": "opencollective",
76
76
  "url": "https://opencollective.com/typescript-eslint"
77
77
  },
78
- "gitHead": "c289d1358c62c41847ee2f32d135f13321dca177"
78
+ "gitHead": "0060a74413a3efb7872a3c8e2f4d45a733f3d149"
79
79
  }
@@ -48,19 +48,19 @@ declare const isVariableDeclarator: (node: TSESTree.Node | null | undefined) =>
48
48
  };
49
49
  declare const isFunction: (node: TSESTree.Node | null | undefined) => node is (TSESTree.ArrowFunctionExpression & {
50
50
  type: AST_NODE_TYPES.ArrowFunctionExpression | AST_NODE_TYPES.FunctionDeclaration | AST_NODE_TYPES.FunctionExpression;
51
- }) | (TSESTree.FunctionExpression & {
52
- type: AST_NODE_TYPES.ArrowFunctionExpression | AST_NODE_TYPES.FunctionDeclaration | AST_NODE_TYPES.FunctionExpression;
53
51
  }) | (TSESTree.FunctionDeclaration & {
54
52
  type: AST_NODE_TYPES.ArrowFunctionExpression | AST_NODE_TYPES.FunctionDeclaration | AST_NODE_TYPES.FunctionExpression;
53
+ }) | (TSESTree.FunctionExpression & {
54
+ type: AST_NODE_TYPES.ArrowFunctionExpression | AST_NODE_TYPES.FunctionDeclaration | AST_NODE_TYPES.FunctionExpression;
55
55
  });
56
- declare const isFunctionType: (node: TSESTree.Node | null | undefined) => node is (TSESTree.TSEmptyBodyFunctionExpression & {
57
- type: AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructorType | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSFunctionType | AST_NODE_TYPES.TSMethodSignature;
58
- }) | (TSESTree.TSCallSignatureDeclaration & {
56
+ declare const isFunctionType: (node: TSESTree.Node | null | undefined) => node is (TSESTree.TSCallSignatureDeclaration & {
59
57
  type: AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructorType | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSFunctionType | AST_NODE_TYPES.TSMethodSignature;
60
58
  }) | (TSESTree.TSConstructorType & {
61
59
  type: AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructorType | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSFunctionType | AST_NODE_TYPES.TSMethodSignature;
62
60
  }) | (TSESTree.TSConstructSignatureDeclaration & {
63
61
  type: AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructorType | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSFunctionType | AST_NODE_TYPES.TSMethodSignature;
62
+ }) | (TSESTree.TSEmptyBodyFunctionExpression & {
63
+ type: AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructorType | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSFunctionType | AST_NODE_TYPES.TSMethodSignature;
64
64
  }) | (TSESTree.TSFunctionType & {
65
65
  type: AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructorType | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSFunctionType | AST_NODE_TYPES.TSMethodSignature;
66
66
  }) | (TSESTree.TSMethodSignatureComputedName & {
@@ -70,11 +70,9 @@ declare const isFunctionType: (node: TSESTree.Node | null | undefined) => node i
70
70
  });
71
71
  declare const isFunctionOrFunctionType: (node: TSESTree.Node | null | undefined) => node is (TSESTree.ArrowFunctionExpression & {
72
72
  type: AST_NODE_TYPES.ArrowFunctionExpression | AST_NODE_TYPES.FunctionDeclaration | AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructorType | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSFunctionType | AST_NODE_TYPES.TSMethodSignature;
73
- }) | (TSESTree.FunctionExpression & {
74
- type: AST_NODE_TYPES.ArrowFunctionExpression | AST_NODE_TYPES.FunctionDeclaration | AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructorType | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSFunctionType | AST_NODE_TYPES.TSMethodSignature;
75
73
  }) | (TSESTree.FunctionDeclaration & {
76
74
  type: AST_NODE_TYPES.ArrowFunctionExpression | AST_NODE_TYPES.FunctionDeclaration | AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructorType | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSFunctionType | AST_NODE_TYPES.TSMethodSignature;
77
- }) | (TSESTree.TSEmptyBodyFunctionExpression & {
75
+ }) | (TSESTree.FunctionExpression & {
78
76
  type: AST_NODE_TYPES.ArrowFunctionExpression | AST_NODE_TYPES.FunctionDeclaration | AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructorType | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSFunctionType | AST_NODE_TYPES.TSMethodSignature;
79
77
  }) | (TSESTree.TSCallSignatureDeclaration & {
80
78
  type: AST_NODE_TYPES.ArrowFunctionExpression | AST_NODE_TYPES.FunctionDeclaration | AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructorType | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSFunctionType | AST_NODE_TYPES.TSMethodSignature;
@@ -82,6 +80,8 @@ declare const isFunctionOrFunctionType: (node: TSESTree.Node | null | undefined)
82
80
  type: AST_NODE_TYPES.ArrowFunctionExpression | AST_NODE_TYPES.FunctionDeclaration | AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructorType | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSFunctionType | AST_NODE_TYPES.TSMethodSignature;
83
81
  }) | (TSESTree.TSConstructSignatureDeclaration & {
84
82
  type: AST_NODE_TYPES.ArrowFunctionExpression | AST_NODE_TYPES.FunctionDeclaration | AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructorType | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSFunctionType | AST_NODE_TYPES.TSMethodSignature;
83
+ }) | (TSESTree.TSEmptyBodyFunctionExpression & {
84
+ type: AST_NODE_TYPES.ArrowFunctionExpression | AST_NODE_TYPES.FunctionDeclaration | AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructorType | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSFunctionType | AST_NODE_TYPES.TSMethodSignature;
85
85
  }) | (TSESTree.TSFunctionType & {
86
86
  type: AST_NODE_TYPES.ArrowFunctionExpression | AST_NODE_TYPES.FunctionDeclaration | AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructorType | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSFunctionType | AST_NODE_TYPES.TSMethodSignature;
87
87
  }) | (TSESTree.TSMethodSignatureComputedName & {
@@ -113,14 +113,14 @@ declare const isClassOrTypeElement: (node: TSESTree.Node | null | undefined) =>
113
113
  type: AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.MethodDefinition | AST_NODE_TYPES.PropertyDefinition | AST_NODE_TYPES.TSAbstractMethodDefinition | AST_NODE_TYPES.TSAbstractPropertyDefinition | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSIndexSignature | AST_NODE_TYPES.TSMethodSignature | AST_NODE_TYPES.TSPropertySignature;
114
114
  }) | (TSESTree.TSAbstractPropertyDefinitionNonComputedName & {
115
115
  type: AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.MethodDefinition | AST_NODE_TYPES.PropertyDefinition | AST_NODE_TYPES.TSAbstractMethodDefinition | AST_NODE_TYPES.TSAbstractPropertyDefinition | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSIndexSignature | AST_NODE_TYPES.TSMethodSignature | AST_NODE_TYPES.TSPropertySignature;
116
- }) | (TSESTree.TSIndexSignature & {
117
- type: AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.MethodDefinition | AST_NODE_TYPES.PropertyDefinition | AST_NODE_TYPES.TSAbstractMethodDefinition | AST_NODE_TYPES.TSAbstractPropertyDefinition | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSIndexSignature | AST_NODE_TYPES.TSMethodSignature | AST_NODE_TYPES.TSPropertySignature;
118
- }) | (TSESTree.TSEmptyBodyFunctionExpression & {
119
- type: AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.MethodDefinition | AST_NODE_TYPES.PropertyDefinition | AST_NODE_TYPES.TSAbstractMethodDefinition | AST_NODE_TYPES.TSAbstractPropertyDefinition | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSIndexSignature | AST_NODE_TYPES.TSMethodSignature | AST_NODE_TYPES.TSPropertySignature;
120
116
  }) | (TSESTree.TSCallSignatureDeclaration & {
121
117
  type: AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.MethodDefinition | AST_NODE_TYPES.PropertyDefinition | AST_NODE_TYPES.TSAbstractMethodDefinition | AST_NODE_TYPES.TSAbstractPropertyDefinition | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSIndexSignature | AST_NODE_TYPES.TSMethodSignature | AST_NODE_TYPES.TSPropertySignature;
122
118
  }) | (TSESTree.TSConstructSignatureDeclaration & {
123
119
  type: AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.MethodDefinition | AST_NODE_TYPES.PropertyDefinition | AST_NODE_TYPES.TSAbstractMethodDefinition | AST_NODE_TYPES.TSAbstractPropertyDefinition | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSIndexSignature | AST_NODE_TYPES.TSMethodSignature | AST_NODE_TYPES.TSPropertySignature;
120
+ }) | (TSESTree.TSEmptyBodyFunctionExpression & {
121
+ type: AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.MethodDefinition | AST_NODE_TYPES.PropertyDefinition | AST_NODE_TYPES.TSAbstractMethodDefinition | AST_NODE_TYPES.TSAbstractPropertyDefinition | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSIndexSignature | AST_NODE_TYPES.TSMethodSignature | AST_NODE_TYPES.TSPropertySignature;
122
+ }) | (TSESTree.TSIndexSignature & {
123
+ type: AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.MethodDefinition | AST_NODE_TYPES.PropertyDefinition | AST_NODE_TYPES.TSAbstractMethodDefinition | AST_NODE_TYPES.TSAbstractPropertyDefinition | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSIndexSignature | AST_NODE_TYPES.TSMethodSignature | AST_NODE_TYPES.TSPropertySignature;
124
124
  }) | (TSESTree.TSMethodSignatureComputedName & {
125
125
  type: AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.MethodDefinition | AST_NODE_TYPES.PropertyDefinition | AST_NODE_TYPES.TSAbstractMethodDefinition | AST_NODE_TYPES.TSAbstractPropertyDefinition | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSIndexSignature | AST_NODE_TYPES.TSMethodSignature | AST_NODE_TYPES.TSPropertySignature;
126
126
  }) | (TSESTree.TSMethodSignatureNonComputedName & {
@@ -1,13 +1,35 @@
1
1
  import { RuleMetaData, RuleMetaDataDocs, RuleListener, RuleContext, RuleModule } from '../ts-eslint/Rule';
2
- declare type CreateRuleMetaDocs = Omit<RuleMetaDataDocs, 'url'>;
3
- declare type CreateRuleMeta<TMessageIds extends string> = {
4
- docs: CreateRuleMetaDocs;
2
+ declare type NamedCreateRuleMetaDocs = Omit<RuleMetaDataDocs, 'url'>;
3
+ declare type NamedCreateRuleMeta<TMessageIds extends string> = {
4
+ docs: NamedCreateRuleMetaDocs;
5
5
  } & Omit<RuleMetaData<TMessageIds>, 'docs'>;
6
- declare function RuleCreator(urlCreator: (ruleName: string) => string): <TOptions extends readonly unknown[], TMessageIds extends string, TRuleListener extends RuleListener = RuleListener>({ name, meta, defaultOptions, create, }: Readonly<{
7
- name: string;
8
- meta: CreateRuleMeta<TMessageIds>;
9
- defaultOptions: Readonly<TOptions>;
6
+ interface CreateAndOptions<TOptions extends readonly unknown[], TMessageIds extends string, TRuleListener extends RuleListener> {
10
7
  create: (context: Readonly<RuleContext<TMessageIds, TOptions>>, optionsWithDefault: Readonly<TOptions>) => TRuleListener;
11
- }>) => RuleModule<TMessageIds, TOptions, TRuleListener>;
8
+ defaultOptions: Readonly<TOptions>;
9
+ }
10
+ interface RuleWithMeta<TOptions extends readonly unknown[], TMessageIds extends string, TRuleListener extends RuleListener> extends CreateAndOptions<TOptions, TMessageIds, TRuleListener> {
11
+ meta: RuleMetaData<TMessageIds>;
12
+ }
13
+ interface RuleWithMetaAndName<TOptions extends readonly unknown[], TMessageIds extends string, TRuleListener extends RuleListener> extends CreateAndOptions<TOptions, TMessageIds, TRuleListener> {
14
+ meta: NamedCreateRuleMeta<TMessageIds>;
15
+ name: string;
16
+ }
17
+ /**
18
+ * Creates reusable function to create rules with default options and docs URLs.
19
+ *
20
+ * @param urlCreator Creates a documentation URL for a given rule name.
21
+ * @returns Function to create a rule with the docs URL format.
22
+ */
23
+ declare function RuleCreator(urlCreator: (ruleName: string) => string): <TOptions extends readonly unknown[], TMessageIds extends string, TRuleListener extends RuleListener = RuleListener>({ name, meta, ...rule }: Readonly<RuleWithMetaAndName<TOptions, TMessageIds, TRuleListener>>) => RuleModule<TMessageIds, TOptions, TRuleListener>;
24
+ declare namespace RuleCreator {
25
+ var withoutDocs: typeof createRule;
26
+ }
27
+ /**
28
+ * Creates a well-typed TSESLint custom ESLint rule without a docs URL.
29
+ *
30
+ * @returns Well-typed TSESLint custom ESLint rule.
31
+ * @remarks It is generally better to provide a docs URL function to RuleCreator.
32
+ */
33
+ declare function createRule<TOptions extends readonly unknown[], TMessageIds extends string, TRuleListener extends RuleListener = RuleListener>({ create, defaultOptions, meta, }: Readonly<RuleWithMeta<TOptions, TMessageIds, TRuleListener>>): RuleModule<TMessageIds, TOptions, TRuleListener>;
12
34
  export { RuleCreator };
13
35
  //# sourceMappingURL=RuleCreator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RuleCreator.d.ts","sourceRoot":"","sources":["../../src/eslint-utils/RuleCreator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,UAAU,EACX,MAAM,mBAAmB,CAAC;AAI3B,aAAK,kBAAkB,GAAG,IAAI,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;AACxD,aAAK,cAAc,CAAC,WAAW,SAAS,MAAM,IAAI;IAChD,IAAI,EAAE,kBAAkB,CAAC;CAC1B,GAAG,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,CAAC;AAE5C,iBAAS,WAAW,CAAC,UAAU,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM;UAanD,MAAM;;;;wDA2Bf;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
1
+ {"version":3,"file":"RuleCreator.d.ts","sourceRoot":"","sources":["../../src/eslint-utils/RuleCreator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,UAAU,EACX,MAAM,mBAAmB,CAAC;AAI3B,aAAK,uBAAuB,GAAG,IAAI,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;AAC7D,aAAK,mBAAmB,CAAC,WAAW,SAAS,MAAM,IAAI;IACrD,IAAI,EAAE,uBAAuB,CAAC;CAC/B,GAAG,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,CAAC;AAE5C,UAAU,gBAAgB,CACxB,QAAQ,SAAS,SAAS,OAAO,EAAE,EACnC,WAAW,SAAS,MAAM,EAC1B,aAAa,SAAS,YAAY;IAElC,MAAM,EAAE,CACN,OAAO,EAAE,QAAQ,CAAC,WAAW,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,EACrD,kBAAkB,EAAE,QAAQ,CAAC,QAAQ,CAAC,KACnC,aAAa,CAAC;IACnB,cAAc,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;CACpC;AAED,UAAU,YAAY,CACpB,QAAQ,SAAS,SAAS,OAAO,EAAE,EACnC,WAAW,SAAS,MAAM,EAC1B,aAAa,SAAS,YAAY,CAClC,SAAQ,gBAAgB,CAAC,QAAQ,EAAE,WAAW,EAAE,aAAa,CAAC;IAC9D,IAAI,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC;CACjC;AAED,UAAU,mBAAmB,CAC3B,QAAQ,SAAS,SAAS,OAAO,EAAE,EACnC,WAAW,SAAS,MAAM,EAC1B,aAAa,SAAS,YAAY,CAClC,SAAQ,gBAAgB,CAAC,QAAQ,EAAE,WAAW,EAAE,aAAa,CAAC;IAC9D,IAAI,EAAE,mBAAmB,CAAC,WAAW,CAAC,CAAC;IACvC,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;GAKG;AACH,iBAAS,WAAW,CAAC,UAAU,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,0QAyB5D;kBAzBQ,WAAW;;;AA2BpB;;;;;GAKG;AACH,iBAAS,UAAU,CACjB,QAAQ,SAAS,SAAS,OAAO,EAAE,EACnC,WAAW,SAAS,MAAM,EAC1B,aAAa,SAAS,YAAY,GAAG,YAAY,EACjD,EACA,MAAM,EACN,cAAc,EACd,IAAI,GACL,EAAE,QAAQ,CAAC,YAAY,CAAC,QAAQ,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC,GAAG,UAAU,CAC1E,WAAW,EACX,QAAQ,EACR,aAAa,CACd,CAUA;AAID,OAAO,EAAE,WAAW,EAAE,CAAC"}
@@ -1,19 +1,47 @@
1
1
  "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
2
13
  Object.defineProperty(exports, "__esModule", { value: true });
3
14
  exports.RuleCreator = void 0;
4
15
  const applyDefault_1 = require("./applyDefault");
16
+ /**
17
+ * Creates reusable function to create rules with default options and docs URLs.
18
+ *
19
+ * @param urlCreator Creates a documentation URL for a given rule name.
20
+ * @returns Function to create a rule with the docs URL format.
21
+ */
5
22
  function RuleCreator(urlCreator) {
6
23
  // This function will get much easier to call when this is merged https://github.com/Microsoft/TypeScript/pull/26349
7
24
  // TODO - when the above PR lands; add type checking for the context.report `data` property
8
- return function createRule({ name, meta, defaultOptions, create, }) {
9
- return {
10
- meta: Object.assign(Object.assign({}, meta), { docs: Object.assign(Object.assign({}, meta.docs), { url: urlCreator(name) }) }),
11
- create(context) {
12
- const optionsWithDefault = (0, applyDefault_1.applyDefault)(defaultOptions, context.options);
13
- return create(context, optionsWithDefault);
14
- },
15
- };
25
+ return function createNamedRule(_a) {
26
+ var { name, meta } = _a, rule = __rest(_a, ["name", "meta"]);
27
+ return createRule(Object.assign({ meta: Object.assign(Object.assign({}, meta), { docs: Object.assign(Object.assign({}, meta.docs), { url: urlCreator(name) }) }) }, rule));
16
28
  };
17
29
  }
18
30
  exports.RuleCreator = RuleCreator;
31
+ /**
32
+ * Creates a well-typed TSESLint custom ESLint rule without a docs URL.
33
+ *
34
+ * @returns Well-typed TSESLint custom ESLint rule.
35
+ * @remarks It is generally better to provide a docs URL function to RuleCreator.
36
+ */
37
+ function createRule({ create, defaultOptions, meta, }) {
38
+ return {
39
+ meta,
40
+ create(context) {
41
+ const optionsWithDefault = (0, applyDefault_1.applyDefault)(defaultOptions, context.options);
42
+ return create(context, optionsWithDefault);
43
+ },
44
+ };
45
+ }
46
+ RuleCreator.withoutDocs = createRule;
19
47
  //# sourceMappingURL=RuleCreator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RuleCreator.js","sourceRoot":"","sources":["../../src/eslint-utils/RuleCreator.ts"],"names":[],"mappings":";;;AAOA,iDAA8C;AAQ9C,SAAS,WAAW,CAAC,UAAwC;IAC3D,oHAAoH;IACpH,2FAA2F;IAC3F,OAAO,SAAS,UAAU,CAIxB,EACA,IAAI,EACJ,IAAI,EACJ,cAAc,EACd,MAAM,GASN;QACA,OAAO;YACL,IAAI,kCACC,IAAI,KACP,IAAI,kCACC,IAAI,CAAC,IAAI,KACZ,GAAG,EAAE,UAAU,CAAC,IAAI,CAAC,MAExB;YACD,MAAM,CACJ,OAAqD;gBAErD,MAAM,kBAAkB,GAAG,IAAA,2BAAY,EACrC,cAAc,EACd,OAAO,CAAC,OAAO,CAChB,CAAC;gBACF,OAAO,MAAM,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;YAC7C,CAAC;SACF,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAEQ,kCAAW"}
1
+ {"version":3,"file":"RuleCreator.js","sourceRoot":"","sources":["../../src/eslint-utils/RuleCreator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAOA,iDAA8C;AAqC9C;;;;;GAKG;AACH,SAAS,WAAW,CAAC,UAAwC;IAC3D,oHAAoH;IACpH,2FAA2F;IAC3F,OAAO,SAAS,eAAe,CAI7B,EAMD;YANC,EACA,IAAI,EACJ,IAAI,OAIL,EAHI,IAAI,cAHP,gBAID,CADQ;QAIP,OAAO,UAAU,iBACf,IAAI,kCACC,IAAI,KACP,IAAI,kCACC,IAAI,CAAC,IAAI,KACZ,GAAG,EAAE,UAAU,CAAC,IAAI,CAAC,UAGtB,IAAI,EACP,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAkCQ,kCAAW;AAhCpB;;;;;GAKG;AACH,SAAS,UAAU,CAIjB,EACA,MAAM,EACN,cAAc,EACd,IAAI,GACyD;IAK7D,OAAO;QACL,IAAI;QACJ,MAAM,CACJ,OAAqD;YAErD,MAAM,kBAAkB,GAAG,IAAA,2BAAY,EAAC,cAAc,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;YACzE,OAAO,MAAM,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;QAC7C,CAAC;KACF,CAAC;AACJ,CAAC;AAED,WAAW,CAAC,WAAW,GAAG,UAAU,CAAC"}