@typescript-eslint/eslint-plugin 8.0.0-alpha.20 → 8.0.0-alpha.21
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 -2
- 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/recommended-type-checked-only.js +0 -1
- package/dist/configs/recommended-type-checked-only.js.map +1 -1
- package/dist/configs/recommended-type-checked.js +0 -1
- package/dist/configs/recommended-type-checked.js.map +1 -1
- package/dist/configs/strict-type-checked-only.js +1 -1
- package/dist/configs/strict-type-checked-only.js.map +1 -1
- package/dist/configs/strict-type-checked.js +1 -2
- package/dist/configs/strict-type-checked.js.map +1 -1
- package/dist/configs/strict.js +0 -1
- package/dist/configs/strict.js.map +1 -1
- package/dist/rules/consistent-type-assertions.js +3 -5
- package/dist/rules/consistent-type-assertions.js.map +1 -1
- package/dist/rules/dot-notation.js +8 -1
- package/dist/rules/dot-notation.js.map +1 -1
- package/dist/rules/explicit-member-accessibility.js +98 -36
- package/dist/rules/explicit-member-accessibility.js.map +1 -1
- package/dist/rules/index.js +2 -0
- package/dist/rules/index.js.map +1 -1
- package/dist/rules/no-unnecessary-type-assertion.js +15 -13
- package/dist/rules/no-unnecessary-type-assertion.js.map +1 -1
- package/dist/rules/no-useless-template-expression.js +153 -0
- package/dist/rules/no-useless-template-expression.js.map +1 -0
- package/dist/rules/no-useless-template-literals.js +5 -4
- package/dist/rules/no-useless-template-literals.js.map +1 -1
- package/dist/rules/prefer-literal-enum-member.js +43 -2
- package/dist/rules/prefer-literal-enum-member.js.map +1 -1
- package/dist/rules/prefer-ts-expect-error.js +2 -1
- package/dist/rules/prefer-ts-expect-error.js.map +1 -1
- package/dist/rules/switch-exhaustiveness-check.js +7 -9
- package/dist/rules/switch-exhaustiveness-check.js.map +1 -1
- package/dist/util/getOperatorPrecedence.js +1 -1
- package/dist/util/getOperatorPrecedence.js.map +1 -1
- package/docs/rules/no-floating-promises.mdx +5 -1
- package/docs/rules/no-useless-template-expression.mdx +87 -0
- package/docs/rules/no-useless-template-literals.mdx +9 -47
- package/docs/rules/only-throw-error.mdx +9 -0
- package/docs/rules/prefer-ts-expect-error.mdx +10 -0
- package/package.json +7 -7
@@ -9,53 +9,15 @@ import TabItem from '@theme/TabItem';
|
|
9
9
|
>
|
10
10
|
> See **https://typescript-eslint.io/rules/no-useless-template-literals** for documentation.
|
11
11
|
|
12
|
-
This rule reports template literals that
|
12
|
+
This rule reports template literals that contain substitution expressions (also variously referred to as embedded expressions or string interpolations) that are unnecessary and can be simplified.
|
13
13
|
|
14
|
-
|
14
|
+
:::warning
|
15
|
+
This rule is being renamed to [`no-useless-template-expression`](./no-useless-template-expression.mdx).
|
16
|
+
The current name, `no-useless-template-literals`, will be removed in a future major version of typescript-eslint.
|
15
17
|
|
16
|
-
|
17
|
-
|
18
|
+
After the creation of this rule, it was realized that the name `no-useless-template-literals` could be misleading, seeing as this rule only targets template literals with substitution expressions.
|
19
|
+
In particular, it does _not_ aim to flag useless template literals that look like `` `this` `` and could be simplified to `"this"`.
|
20
|
+
If you are looking for such a rule, you can configure the [`@stylistic/ts/quotes`](https://eslint.style/rules/ts/quotes) rule to do this.
|
21
|
+
:::
|
18
22
|
|
19
|
-
|
20
|
-
const ab1 = `${'a'}${'b'}`;
|
21
|
-
const ab2 = `a${'b'}`;
|
22
|
-
|
23
|
-
const stringWithNumber = `${'1 + 1 = '}${2}`;
|
24
|
-
|
25
|
-
const stringWithBoolean = `${'true is '}${true}`;
|
26
|
-
|
27
|
-
const text = 'a';
|
28
|
-
const wrappedText = `${text}`;
|
29
|
-
|
30
|
-
declare const intersectionWithString: string & { _brand: 'test-brand' };
|
31
|
-
const wrappedIntersection = `${intersectionWithString}`;
|
32
|
-
```
|
33
|
-
|
34
|
-
</TabItem>
|
35
|
-
<TabItem value="✅ Correct">
|
36
|
-
|
37
|
-
```ts
|
38
|
-
const ab1 = 'ab';
|
39
|
-
const ab2 = 'ab';
|
40
|
-
|
41
|
-
const stringWithNumber = `1 + 1 = 2`;
|
42
|
-
|
43
|
-
const stringWithBoolean = `true is true`;
|
44
|
-
|
45
|
-
const text = 'a';
|
46
|
-
const wrappedText = text;
|
47
|
-
|
48
|
-
declare const intersectionWithString: string & { _brand: 'test-brand' };
|
49
|
-
const wrappedIntersection = intersectionWithString;
|
50
|
-
```
|
51
|
-
|
52
|
-
</TabItem>
|
53
|
-
</Tabs>
|
54
|
-
|
55
|
-
## When Not To Use It
|
56
|
-
|
57
|
-
When you want to allow string expressions inside template literals.
|
58
|
-
|
59
|
-
## Related To
|
60
|
-
|
61
|
-
- [`restrict-template-expressions`](./restrict-template-expressions.mdx)
|
23
|
+
{/* Intentionally Omitted: When Not To Use It */}
|
@@ -14,6 +14,15 @@ The fundamental benefit of `Error` objects is that they automatically keep track
|
|
14
14
|
|
15
15
|
This rule restricts what can be thrown as an exception.
|
16
16
|
|
17
|
+
:::info[Migration from `no-throw-literal`]
|
18
|
+
|
19
|
+
This rule was formerly known as [`no-throw-literal`](./no-throw-literal.mdx).
|
20
|
+
We encourage users to migrate to the new name, `only-throw-error`, as the old name will be removed in a future major version of typescript-eslint.
|
21
|
+
|
22
|
+
The new name is a drop-in replacement with identical functionality.
|
23
|
+
|
24
|
+
:::
|
25
|
+
|
17
26
|
## Examples
|
18
27
|
|
19
28
|
This rule is aimed at maintaining consistency when throwing exception by disallowing to throw literals and other expressions which cannot possibly be an `Error` object.
|
@@ -9,6 +9,16 @@ import TabItem from '@theme/TabItem';
|
|
9
9
|
>
|
10
10
|
> See **https://typescript-eslint.io/rules/prefer-ts-expect-error** for documentation.
|
11
11
|
|
12
|
+
:::danger Deprecated
|
13
|
+
|
14
|
+
This rule has been deprecated in favor of [`@typescript-eslint/ban-ts-comment`](./ban-ts-comment.mdx).
|
15
|
+
This rule (`@typescript-eslint/prefer-ts-expect-error`) will be removed in a future major version of typescript-eslint.
|
16
|
+
|
17
|
+
When it was first created, `@typescript-eslint/ban-ts-comment` rule was only responsible for suggesting to remove `@ts-ignore` directive.
|
18
|
+
It was later updated to suggest replacing `@ts-ignore` with `@ts-expect-error` directive, so that it replaces `@typescript-eslint/prefer-ts-expect-error` entirely.
|
19
|
+
|
20
|
+
:::
|
21
|
+
|
12
22
|
TypeScript allows you to suppress all errors on a line by placing a comment starting with `@ts-ignore` or `@ts-expect-error` immediately before the erroring line.
|
13
23
|
The two directives work the same, except `@ts-expect-error` causes a type error if placed before a line that's not erroring in the first place.
|
14
24
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@typescript-eslint/eslint-plugin",
|
3
|
-
"version": "8.0.0-alpha.
|
3
|
+
"version": "8.0.0-alpha.21",
|
4
4
|
"description": "TypeScript plugin for ESLint",
|
5
5
|
"files": [
|
6
6
|
"dist",
|
@@ -62,10 +62,10 @@
|
|
62
62
|
},
|
63
63
|
"dependencies": {
|
64
64
|
"@eslint-community/regexpp": "^4.10.0",
|
65
|
-
"@typescript-eslint/scope-manager": "8.0.0-alpha.
|
66
|
-
"@typescript-eslint/type-utils": "8.0.0-alpha.
|
67
|
-
"@typescript-eslint/utils": "8.0.0-alpha.
|
68
|
-
"@typescript-eslint/visitor-keys": "8.0.0-alpha.
|
65
|
+
"@typescript-eslint/scope-manager": "8.0.0-alpha.21",
|
66
|
+
"@typescript-eslint/type-utils": "8.0.0-alpha.21",
|
67
|
+
"@typescript-eslint/utils": "8.0.0-alpha.21",
|
68
|
+
"@typescript-eslint/visitor-keys": "8.0.0-alpha.21",
|
69
69
|
"graphemer": "^1.4.0",
|
70
70
|
"ignore": "^5.3.1",
|
71
71
|
"natural-compare": "^1.4.0",
|
@@ -76,8 +76,8 @@
|
|
76
76
|
"@types/marked": "^5.0.2",
|
77
77
|
"@types/mdast": "^4.0.3",
|
78
78
|
"@types/natural-compare": "*",
|
79
|
-
"@typescript-eslint/rule-schema-to-typescript-types": "8.0.0-alpha.
|
80
|
-
"@typescript-eslint/rule-tester": "8.0.0-alpha.
|
79
|
+
"@typescript-eslint/rule-schema-to-typescript-types": "8.0.0-alpha.21",
|
80
|
+
"@typescript-eslint/rule-tester": "8.0.0-alpha.21",
|
81
81
|
"ajv": "^6.12.6",
|
82
82
|
"cross-env": "^7.0.3",
|
83
83
|
"cross-fetch": "*",
|