@typescript-eslint/eslint-plugin 8.3.1-alpha.5 → 8.3.1-alpha.7
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/rules/ban-ts-comment.js +1 -0
- package/dist/rules/ban-ts-comment.js.map +1 -1
- package/dist/rules/consistent-type-assertions.js +3 -0
- package/dist/rules/consistent-type-assertions.js.map +1 -1
- package/dist/rules/consistent-type-exports.js +1 -0
- package/dist/rules/consistent-type-exports.js.map +1 -1
- package/dist/rules/consistent-type-imports.js +3 -0
- package/dist/rules/consistent-type-imports.js.map +1 -1
- package/dist/rules/dot-notation.js +5 -0
- package/dist/rules/dot-notation.js.map +1 -1
- package/dist/rules/explicit-member-accessibility.js +1 -0
- package/dist/rules/explicit-member-accessibility.js.map +1 -1
- package/dist/rules/max-params.js +5 -2
- package/dist/rules/max-params.js.map +1 -1
- package/dist/rules/no-base-to-string.js +1 -0
- package/dist/rules/no-base-to-string.js.map +1 -1
- package/dist/rules/no-confusing-void-expression.js +8 -2
- package/dist/rules/no-confusing-void-expression.js.map +1 -1
- package/dist/rules/no-duplicate-type-constituents.js +2 -0
- package/dist/rules/no-duplicate-type-constituents.js.map +1 -1
- package/dist/rules/no-empty-function.js +1 -0
- package/dist/rules/no-empty-function.js.map +1 -1
- package/dist/rules/no-empty-interface.js +1 -0
- package/dist/rules/no-empty-interface.js.map +1 -1
- package/dist/rules/no-empty-object-type.js +3 -0
- package/dist/rules/no-empty-object-type.js.map +1 -1
- package/dist/rules/no-floating-promises.js +8 -2
- package/dist/rules/no-floating-promises.js.map +1 -1
- package/dist/rules/no-inferrable-types.js +2 -0
- package/dist/rules/no-inferrable-types.js.map +1 -1
- package/dist/rules/no-invalid-void-type.js +2 -0
- package/dist/rules/no-invalid-void-type.js.map +1 -1
- package/dist/rules/no-magic-numbers.js +4 -0
- package/dist/rules/no-magic-numbers.js.map +1 -1
- package/dist/rules/no-meaningless-void-operator.js +1 -0
- package/dist/rules/no-meaningless-void-operator.js.map +1 -1
- package/dist/rules/no-misused-promises.js +25 -6
- package/dist/rules/no-misused-promises.js.map +1 -1
- package/dist/rules/no-redeclare.js +2 -0
- package/dist/rules/no-redeclare.js.map +1 -1
- package/dist/rules/no-shadow.js +6 -0
- package/dist/rules/no-shadow.js.map +1 -1
- package/dist/rules/no-unused-vars.js +13 -3
- package/dist/rules/no-unused-vars.js.map +1 -1
- package/dist/rules/no-use-before-define.js +24 -6
- package/dist/rules/no-use-before-define.js.map +1 -1
- package/dist/rules/only-throw-error.js +2 -0
- package/dist/rules/only-throw-error.js.map +1 -1
- package/dist/rules/parameter-properties.js +2 -0
- package/dist/rules/parameter-properties.js.map +1 -1
- package/dist/rules/prefer-literal-enum-member.js +1 -0
- package/dist/rules/prefer-literal-enum-member.js.map +1 -1
- package/dist/rules/prefer-nullish-coalescing.js +5 -0
- package/dist/rules/prefer-nullish-coalescing.js.map +1 -1
- package/dist/rules/prefer-promise-reject-errors.js +1 -0
- package/dist/rules/prefer-promise-reject-errors.js.map +1 -1
- package/dist/rules/prefer-readonly-parameter-types.js +10 -2
- package/dist/rules/prefer-readonly-parameter-types.js.map +1 -1
- package/dist/rules/prefer-readonly.js +1 -0
- package/dist/rules/prefer-readonly.js.map +1 -1
- package/dist/rules/promise-function-async.js +4 -0
- package/dist/rules/promise-function-async.js.map +1 -1
- package/dist/rules/return-await.js +21 -5
- package/dist/rules/return-await.js.map +1 -1
- package/dist/rules/strict-boolean-expressions.js +32 -8
- package/dist/rules/strict-boolean-expressions.js.map +1 -1
- package/dist/rules/triple-slash-reference.js +3 -0
- package/dist/rules/triple-slash-reference.js.map +1 -1
- package/dist/rules/typedef.js +32 -8
- package/dist/rules/typedef.js.map +1 -1
- package/docs/rules/ban-ts-comment.mdx +1 -1
- package/docs/rules/consistent-type-assertions.mdx +5 -2
- package/docs/rules/consistent-type-exports.mdx +1 -1
- package/docs/rules/consistent-type-imports.mdx +3 -3
- package/docs/rules/dot-notation.mdx +8 -0
- package/docs/rules/explicit-member-accessibility.mdx +2 -1
- package/docs/rules/max-params.mdx +42 -0
- package/docs/rules/no-base-to-string.mdx +2 -1
- package/docs/rules/no-confusing-void-expression.mdx +6 -2
- package/docs/rules/no-inferrable-types.mdx +4 -0
- package/docs/rules/no-invalid-void-type.mdx +2 -2
- package/docs/rules/no-magic-numbers.mdx +5 -3
- package/docs/rules/no-meaningless-void-operator.mdx +1 -1
- package/docs/rules/no-misused-promises.mdx +2 -0
- package/docs/rules/no-redeclare.mdx +1 -1
- package/docs/rules/no-restricted-imports.mdx +1 -1
- package/docs/rules/no-shadow.mdx +2 -2
- package/docs/rules/no-use-before-define.mdx +7 -1
- package/docs/rules/prefer-literal-enum-member.mdx +1 -1
- package/docs/rules/prefer-nullish-coalescing.mdx +6 -4
- package/docs/rules/prefer-readonly-parameter-types.mdx +6 -4
- package/docs/rules/promise-function-async.mdx +2 -2
- package/docs/rules/typedef.mdx +1 -1
- package/package.json +7 -7
@@ -67,7 +67,7 @@ enum Valid {
|
|
67
67
|
|
68
68
|
### `allowBitwiseExpressions`
|
69
69
|
|
70
|
-
|
70
|
+
Whether to allow using bitwise expressions in enum initializers (default: `false`).
|
71
71
|
|
72
72
|
Examples of code for the `{ "allowBitwiseExpressions": true }` option:
|
73
73
|
|
@@ -25,7 +25,7 @@ This rule will not work as expected if [`strictNullChecks`](https://www.typescri
|
|
25
25
|
|
26
26
|
### `ignoreTernaryTests`
|
27
27
|
|
28
|
-
|
28
|
+
Whether to ignore any ternary expressions that could be simplified by using the nullish coalescing operator. This is set to `false` by default.
|
29
29
|
|
30
30
|
Incorrect code for `ignoreTernaryTests: false`, and correct code for `ignoreTernaryTests: true`:
|
31
31
|
|
@@ -65,7 +65,7 @@ foo ?? 'a string';
|
|
65
65
|
|
66
66
|
### `ignoreConditionalTests`
|
67
67
|
|
68
|
-
|
68
|
+
Whether to ignore cases that are located within a conditional test. This is set to `true` by default.
|
69
69
|
|
70
70
|
Generally expressions within conditional tests intentionally use the falsy fallthrough behavior of the logical or operator, meaning that fixing the operator to the nullish coalesce operator could cause bugs.
|
71
71
|
|
@@ -107,7 +107,7 @@ a ?? b ? true : false;
|
|
107
107
|
|
108
108
|
### `ignoreMixedLogicalExpressions`
|
109
109
|
|
110
|
-
|
110
|
+
Whether to ignore any logical or expressions that are part of a mixed logical expression (with `&&`). This is set to `false` by default.
|
111
111
|
|
112
112
|
Generally expressions within mixed logical expressions intentionally use the falsy fallthrough behavior of the logical or operator, meaning that fixing the operator to the nullish coalesce operator could cause bugs.
|
113
113
|
|
@@ -147,6 +147,8 @@ a ?? (b && c && d);
|
|
147
147
|
|
148
148
|
### `ignorePrimitives`
|
149
149
|
|
150
|
+
Whether to ignore all (`true`) or some (an object with properties) primitive types.
|
151
|
+
|
150
152
|
If you would like to ignore expressions containing operands of certain primitive types that can be falsy then you may pass an object containing a boolean value for each primitive:
|
151
153
|
|
152
154
|
- `string: true`, ignores `null` or `undefined` unions with `string` (default: false).
|
@@ -172,7 +174,7 @@ Also, if you would like to ignore all primitives types, you can set `ignorePrimi
|
|
172
174
|
|
173
175
|
### `allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing`
|
174
176
|
|
175
|
-
|
177
|
+
Unless this is set to `true`, the rule will error on every file whose `tsconfig.json` does _not_ have the `strictNullChecks` compiler option (or `strict`) set to `true`.
|
176
178
|
|
177
179
|
Without `strictNullChecks`, TypeScript essentially erases `undefined` and `null` from the types. This means when this rule inspects the types from a variable, **it will not be able to tell that the variable might be `null` or `undefined`**, which essentially makes this rule useless.
|
178
180
|
|
@@ -140,9 +140,9 @@ interface Foo {
|
|
140
140
|
|
141
141
|
### `allow`
|
142
142
|
|
143
|
+
An array of type specifiers to ignore.
|
143
144
|
Some complex types cannot easily be made readonly, for example the `HTMLElement` type or the `JQueryStatic` type from `@types/jquery`. This option allows you to globally disable reporting of such types.
|
144
145
|
|
145
|
-
This option takes an array of type specifiers to ignore.
|
146
146
|
Each item in the array must have one of the following forms:
|
147
147
|
|
148
148
|
- A type defined in a file (`{ from: "file", name: "Foo", path: "src/foo-file.ts" }` with `path` being an optional path relative to the project root directory)
|
@@ -258,7 +258,7 @@ function fn(arg: Foo) {}
|
|
258
258
|
|
259
259
|
### `checkParameterProperties`
|
260
260
|
|
261
|
-
|
261
|
+
Whether to check class parameter properties.
|
262
262
|
Because parameter properties create properties on the class, it may be undesirable to force them to be readonly.
|
263
263
|
|
264
264
|
Examples of code for this rule with `{checkParameterProperties: true}`:
|
@@ -297,7 +297,8 @@ class Foo {
|
|
297
297
|
|
298
298
|
### `ignoreInferredTypes`
|
299
299
|
|
300
|
-
|
300
|
+
Whether to ignore parameters which don't explicitly specify a type.
|
301
|
+
This may be desirable in cases where an external dependency specifies a callback with mutable parameters, and manually annotating the callback's parameters is undesirable.
|
301
302
|
|
302
303
|
Examples of code for this rule with `{ignoreInferredTypes: true}`:
|
303
304
|
|
@@ -354,7 +355,8 @@ export const acceptsCallback: AcceptsCallback;
|
|
354
355
|
|
355
356
|
### `treatMethodsAsReadonly`
|
356
357
|
|
357
|
-
|
358
|
+
Whether to treat all mutable methods as though they are readonly.
|
359
|
+
This may be desirable when you are never reassigning methods.
|
358
360
|
|
359
361
|
Examples of code for this rule with `{treatMethodsAsReadonly: false}`:
|
360
362
|
|
@@ -68,7 +68,7 @@ async function functionReturnsUnionWithPromiseImplicitly(p: boolean) {
|
|
68
68
|
|
69
69
|
### `allowAny`
|
70
70
|
|
71
|
-
Whether to ignore functions that return `any`
|
71
|
+
Whether to ignore functions that return `any` or `unknown`.
|
72
72
|
If you want additional safety, consider turning this option off, as it makes the rule less able to catch incorrect Promise behaviors.
|
73
73
|
|
74
74
|
Examples of code with `{ "allowAny": false }`:
|
@@ -135,7 +135,7 @@ Whether to check inline function expressions.
|
|
135
135
|
|
136
136
|
### `checkMethodDeclarations`
|
137
137
|
|
138
|
-
Whether to check methods on classes and object literals
|
138
|
+
Whether to check methods on classes and object literals.
|
139
139
|
`true` by default, but can be set to `false` to ignore them.
|
140
140
|
|
141
141
|
## When Not To Use It
|
package/docs/rules/typedef.mdx
CHANGED
@@ -306,7 +306,7 @@ let delayedText: string;
|
|
306
306
|
|
307
307
|
### `variableDeclarationIgnoreFunction`
|
308
308
|
|
309
|
-
|
309
|
+
Whether to ignore variable declarations for non-arrow and arrow functions.
|
310
310
|
|
311
311
|
Examples of code with `{ "variableDeclaration": true, "variableDeclarationIgnoreFunction": true }`:
|
312
312
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@typescript-eslint/eslint-plugin",
|
3
|
-
"version": "8.3.1-alpha.
|
3
|
+
"version": "8.3.1-alpha.7",
|
4
4
|
"description": "TypeScript plugin for ESLint",
|
5
5
|
"files": [
|
6
6
|
"dist",
|
@@ -60,10 +60,10 @@
|
|
60
60
|
},
|
61
61
|
"dependencies": {
|
62
62
|
"@eslint-community/regexpp": "^4.10.0",
|
63
|
-
"@typescript-eslint/scope-manager": "8.3.1-alpha.
|
64
|
-
"@typescript-eslint/type-utils": "8.3.1-alpha.
|
65
|
-
"@typescript-eslint/utils": "8.3.1-alpha.
|
66
|
-
"@typescript-eslint/visitor-keys": "8.3.1-alpha.
|
63
|
+
"@typescript-eslint/scope-manager": "8.3.1-alpha.7",
|
64
|
+
"@typescript-eslint/type-utils": "8.3.1-alpha.7",
|
65
|
+
"@typescript-eslint/utils": "8.3.1-alpha.7",
|
66
|
+
"@typescript-eslint/visitor-keys": "8.3.1-alpha.7",
|
67
67
|
"graphemer": "^1.4.0",
|
68
68
|
"ignore": "^5.3.1",
|
69
69
|
"natural-compare": "^1.4.0",
|
@@ -74,8 +74,8 @@
|
|
74
74
|
"@types/marked": "^5.0.2",
|
75
75
|
"@types/mdast": "^4.0.3",
|
76
76
|
"@types/natural-compare": "*",
|
77
|
-
"@typescript-eslint/rule-schema-to-typescript-types": "8.3.1-alpha.
|
78
|
-
"@typescript-eslint/rule-tester": "8.3.1-alpha.
|
77
|
+
"@typescript-eslint/rule-schema-to-typescript-types": "8.3.1-alpha.7",
|
78
|
+
"@typescript-eslint/rule-tester": "8.3.1-alpha.7",
|
79
79
|
"ajv": "^6.12.6",
|
80
80
|
"cross-env": "^7.0.3",
|
81
81
|
"cross-fetch": "*",
|