You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/eslint-plugin/README.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -92,7 +92,7 @@ Pro Tip: For larger codebases you may want to consider splitting our linting int
92
92
|[`@typescript-eslint/adjacent-overload-signatures`](./docs/rules/adjacent-overload-signatures.md)| Require that member overloads be consecutive |:heavy_check_mark:|||
93
93
|[`@typescript-eslint/array-type`](./docs/rules/array-type.md)| Requires using either `T[]` or `Array<T>` for arrays ||:wrench:||
94
94
|[`@typescript-eslint/await-thenable`](./docs/rules/await-thenable.md)| Disallows awaiting a value that is not a Thenable |:heavy_check_mark:||:thought_balloon:|
95
-
|[`@typescript-eslint/ban-ts-comment`](./docs/rules/ban-ts-comment.md)| Bans `// @ts-<directive>` comments from being used |:heavy_check_mark:|||
95
+
|[`@typescript-eslint/ban-ts-comment`](./docs/rules/ban-ts-comment.md)| Bans `// @ts-<directive>` comments from being used or requires descriptions after directive|:heavy_check_mark:|||
96
96
|[`@typescript-eslint/ban-types`](./docs/rules/ban-types.md)| Bans specific types from being used |:heavy_check_mark:|:wrench:||
97
97
|[`@typescript-eslint/class-literal-property-style`](./docs/rules/class-literal-property-style.md)| Ensures that literals on classes are exposed in a consistent style ||:wrench:||
98
98
|[`@typescript-eslint/consistent-type-assertions`](./docs/rules/consistent-type-assertions.md)| Enforces consistent usage of type assertions ||||
A value of `true` for a particular directive means that this rule will report if it finds any usage of said directive.
39
43
40
44
For example, with the defaults above the following patterns are considered warnings:
@@ -55,6 +59,50 @@ if (false) {
55
59
}
56
60
```
57
61
62
+
### `allow-with-description`
63
+
64
+
A value of `'allow-with-description'` for a particular directive means that this rule will report if it finds a directive that does not have a description following the directive (on the same line).
65
+
66
+
For example, with `{ 'ts-expect-error': 'allow-with-description' }` the following pattern is considered a warning:
67
+
68
+
```ts
69
+
if (false) {
70
+
// @ts-expect-error
71
+
console.log('hello');
72
+
}
73
+
```
74
+
75
+
The following pattern is not a warning:
76
+
77
+
```ts
78
+
if (false) {
79
+
// @ts-expect-error: Unreachable code error
80
+
console.log('hello');
81
+
}
82
+
```
83
+
84
+
### `minimumDescriptionLength`
85
+
86
+
Use `minimumDescriptionLength` to set a minimum length for descriptions when using the `allow-with-description` option for a directive.
87
+
88
+
For example, with `{ 'ts-expect-error': 'allow-with-description', minimumDescriptionLength: 10 }` the following pattern is considered a warning:
89
+
90
+
```ts
91
+
if (false) {
92
+
// @ts-expect-error: TODO
93
+
console.log('hello');
94
+
}
95
+
```
96
+
97
+
The following pattern is not a warning:
98
+
99
+
```ts
100
+
if (false) {
101
+
// @ts-expect-error The rationale for this override is described in issue #1337 on GitLab
102
+
console.log('hello');
103
+
}
104
+
```
105
+
58
106
## When Not To Use It
59
107
60
108
If you want to use all of the TypeScript directives.
description: 'Bans `// @ts-<directive>` comments from being used',
33
+
description:
34
+
'Bans `// @ts-<directive>` comments from being used or requires descriptions after directive',
28
35
category: 'Best Practices',
29
36
recommended: 'error',
30
37
},
31
38
messages: {
32
39
tsDirectiveComment:
33
40
'Do not use "// @ts-{{directive}}" because it alters compilation errors.',
41
+
tsDirectiveCommentRequiresDescription:
42
+
'Include a description after the "// @ts-{{directive}}" directive to explain why the @ts-{{directive}} is necessary. The description must be {{minimumDescriptionLength}} characters or longer.',
0 commit comments