@typescript-eslint/eslint-plugin 6.13.2-alpha.5 → 6.13.2

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 (99) hide show
  1. package/dist/rules/consistent-type-exports.js +1 -0
  2. package/dist/rules/consistent-type-exports.js.map +1 -1
  3. package/dist/rules/consistent-type-imports.js +1 -0
  4. package/dist/rules/consistent-type-imports.js.map +1 -1
  5. package/dist/rules/no-extra-parens.js +1 -0
  6. package/dist/rules/no-extra-parens.js.map +1 -1
  7. package/dist/rules/no-shadow.js.map +1 -1
  8. package/dist/rules/prefer-readonly.js.map +1 -1
  9. package/dist/rules/return-await.js.map +1 -1
  10. package/dist/rules/unified-signatures.js.map +1 -1
  11. package/dist/util/getThisExpression.js +1 -1
  12. package/docs/rules/adjacent-overload-signatures.md +7 -1
  13. package/docs/rules/array-type.md +8 -0
  14. package/docs/rules/await-thenable.md +3 -1
  15. package/docs/rules/ban-ts-comment.md +2 -1
  16. package/docs/rules/ban-tslint-comment.md +1 -1
  17. package/docs/rules/ban-types.md +5 -0
  18. package/docs/rules/class-literal-property-style.md +1 -2
  19. package/docs/rules/class-methods-use-this.md +5 -0
  20. package/docs/rules/consistent-generic-constructors.md +3 -0
  21. package/docs/rules/consistent-indexed-object-style.md +8 -0
  22. package/docs/rules/consistent-type-assertions.md +3 -0
  23. package/docs/rules/consistent-type-definitions.md +8 -1
  24. package/docs/rules/consistent-type-exports.md +7 -2
  25. package/docs/rules/consistent-type-imports.md +4 -1
  26. package/docs/rules/dot-notation.md +7 -0
  27. package/docs/rules/explicit-function-return-type.md +1 -2
  28. package/docs/rules/explicit-member-accessibility.md +5 -1
  29. package/docs/rules/explicit-module-boundary-types.md +5 -1
  30. package/docs/rules/member-delimiter-style.md +4 -1
  31. package/docs/rules/method-signature-style.md +3 -0
  32. package/docs/rules/naming-convention.md +8 -1
  33. package/docs/rules/no-base-to-string.md +1 -1
  34. package/docs/rules/no-confusing-void-expression.md +1 -1
  35. package/docs/rules/no-duplicate-enum-values.md +8 -0
  36. package/docs/rules/no-duplicate-type-constituents.md +7 -0
  37. package/docs/rules/no-dynamic-delete.md +1 -1
  38. package/docs/rules/no-empty-function.md +9 -0
  39. package/docs/rules/no-explicit-any.md +4 -0
  40. package/docs/rules/no-extra-non-null-assertion.md +2 -0
  41. package/docs/rules/no-extraneous-class.md +2 -1
  42. package/docs/rules/no-floating-promises.md +3 -1
  43. package/docs/rules/no-for-in-array.md +2 -1
  44. package/docs/rules/no-implied-eval.md +2 -1
  45. package/docs/rules/no-import-type-side-effects.md +1 -2
  46. package/docs/rules/no-inferrable-types.md +2 -2
  47. package/docs/rules/no-invalid-void-type.md +1 -2
  48. package/docs/rules/no-magic-numbers.md +6 -0
  49. package/docs/rules/no-meaningless-void-operator.md +4 -0
  50. package/docs/rules/no-misused-new.md +2 -1
  51. package/docs/rules/no-misused-promises.md +3 -2
  52. package/docs/rules/no-namespace.md +3 -1
  53. package/docs/rules/no-non-null-asserted-nullish-coalescing.md +5 -0
  54. package/docs/rules/no-non-null-asserted-optional-chain.md +5 -0
  55. package/docs/rules/no-non-null-assertion.md +2 -2
  56. package/docs/rules/no-redundant-type-constituents.md +14 -0
  57. package/docs/rules/no-require-imports.md +2 -1
  58. package/docs/rules/no-this-alias.md +2 -1
  59. package/docs/rules/no-throw-literal.md +2 -0
  60. package/docs/rules/no-type-alias.md +1 -4
  61. package/docs/rules/no-unnecessary-boolean-literal-compare.md +1 -1
  62. package/docs/rules/no-unnecessary-condition.md +2 -1
  63. package/docs/rules/no-unnecessary-qualifier.md +1 -1
  64. package/docs/rules/no-unnecessary-type-arguments.md +4 -0
  65. package/docs/rules/no-unsafe-argument.md +10 -0
  66. package/docs/rules/no-unsafe-assignment.md +10 -0
  67. package/docs/rules/no-unsafe-call.md +10 -0
  68. package/docs/rules/no-unsafe-declaration-merging.md +5 -0
  69. package/docs/rules/no-unsafe-enum-comparison.md +3 -0
  70. package/docs/rules/no-unsafe-member-access.md +10 -0
  71. package/docs/rules/no-unsafe-return.md +10 -0
  72. package/docs/rules/no-unsafe-unary-minus.md +2 -0
  73. package/docs/rules/no-useless-empty-export.md +4 -0
  74. package/docs/rules/no-var-requires.md +2 -1
  75. package/docs/rules/non-nullable-type-assertion-style.md +1 -1
  76. package/docs/rules/parameter-properties.md +4 -1
  77. package/docs/rules/prefer-as-const.md +4 -1
  78. package/docs/rules/prefer-for-of.md +1 -3
  79. package/docs/rules/prefer-function-type.md +1 -1
  80. package/docs/rules/prefer-includes.md +1 -3
  81. package/docs/rules/prefer-literal-enum-member.md +1 -1
  82. package/docs/rules/prefer-namespace-keyword.md +1 -1
  83. package/docs/rules/prefer-optional-chain.md +2 -1
  84. package/docs/rules/prefer-readonly-parameter-types.md +4 -0
  85. package/docs/rules/prefer-readonly.md +4 -0
  86. package/docs/rules/prefer-reduce-type-parameter.md +3 -1
  87. package/docs/rules/prefer-string-starts-ends-with.md +2 -1
  88. package/docs/rules/prefer-ts-expect-error.md +1 -0
  89. package/docs/rules/promise-function-async.md +5 -0
  90. package/docs/rules/require-array-sort-compare.md +1 -1
  91. package/docs/rules/restrict-plus-operands.md +1 -1
  92. package/docs/rules/restrict-template-expressions.md +4 -0
  93. package/docs/rules/sort-type-constituents.md +6 -0
  94. package/docs/rules/strict-boolean-expressions.md +7 -0
  95. package/docs/rules/switch-exhaustiveness-check.md +1 -1
  96. package/docs/rules/triple-slash-reference.md +5 -2
  97. package/docs/rules/unbound-method.md +3 -1
  98. package/docs/rules/unified-signatures.md +9 -0
  99. package/package.json +8 -8
@@ -317,8 +317,7 @@ var bar = (function () {
317
317
 
318
318
  ## When Not To Use It
319
319
 
320
- If you don't wish to prevent calling code from using function return values in unexpected ways, then
321
- you will not need this rule.
320
+ If you don't find the added cost of explicitly writing function return types to be worth the visual clarity, or your project is not large enough for it to be a factor in type checking performance, then you will not need this rule.
322
321
 
323
322
  ## Further Reading
324
323
 
@@ -333,7 +333,11 @@ class Animal {
333
333
 
334
334
  ## When Not To Use It
335
335
 
336
- If you think defaulting to public is a good default, then you should consider using the `no-public` setting. If you want to mix implicit and explicit public members then disable this rule.
336
+ If you think defaulting to public is a good default, then you should consider using the `no-public` setting.
337
+ If you want to mix implicit and explicit public members then you can disable this rule.
338
+
339
+ However, keep in mind that inconsistent style can harm readability in a project.
340
+ We recommend picking a single option for this rule that works best for your project.
337
341
 
338
342
  ## Further Reading
339
343
 
@@ -243,8 +243,12 @@ export const foo: FooType = bar => {};
243
243
 
244
244
  ## When Not To Use It
245
245
 
246
- If you wish to make sure all functions have explicit return types, as opposed to only the module boundaries, you can use [explicit-function-return-type](./explicit-function-return-type.md)
246
+ If your project is not used by downstream consumers that are sensitive to API types, you can disable this rule.
247
247
 
248
248
  ## Further Reading
249
249
 
250
250
  - TypeScript [Functions](https://www.typescriptlang.org/docs/handbook/functions.html#function-types)
251
+
252
+ ## Related To
253
+
254
+ - [explicit-function-return-type](./explicit-function-return-type.md)
@@ -158,4 +158,7 @@ type FooBar = { name: string; greet(): string }
158
158
 
159
159
  ## When Not To Use It
160
160
 
161
- If you don't care about enforcing a consistent member delimiter in interfaces and type literals, then you will not need this rule.
161
+ 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.
162
+
163
+ However, keep in mind that inconsistent style can harm readability in a project.
164
+ We recommend picking a single option for this rule that works best for your project.
@@ -108,3 +108,6 @@ type T2 = {
108
108
  ## When Not To Use It
109
109
 
110
110
  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.
111
+
112
+ However, keep in mind that inconsistent style can harm readability in a project.
113
+ We recommend picking a single option for this rule that works best for your project.
@@ -711,4 +711,11 @@ You can use the `destructured` modifier to match these names, and explicitly set
711
711
 
712
712
  ## When Not To Use It
713
713
 
714
- If you do not want to enforce naming conventions for anything.
714
+ This rule can be very strict.
715
+ If you don't have strong needs for enforcing naming conventions, we recommend using it only to flag very egregious violations of your naming standards.
716
+ Consider documenting your naming conventions and enforcing them in code review if you have processes like that.
717
+
718
+ If you do not want to enforce naming conventions for anything, you can disable this rule.
719
+
720
+ However, keep in mind that inconsistent style can harm readability in a project.
721
+ We recommend that if you care about naming conventions, pick a single option for this rule that works best for your project.
@@ -76,7 +76,7 @@ let text = `${value}`;
76
76
 
77
77
  ## When Not To Use It
78
78
 
79
- If you don't mind `"[object Object]"` in your strings, then you will not need this rule.
79
+ If you don't mind a risk of `"[object Object]"` or incorrect type coercions in your values, then you will not need this rule.
80
80
 
81
81
  ## Related To
82
82
 
@@ -113,4 +113,4 @@ console.log(void alert('Hello, world!'));
113
113
 
114
114
  The return type of a function can be inspected by going to its definition or hovering over it in an IDE.
115
115
  If you don't care about being explicit about the void type in actual code then don't use this rule.
116
- Also, if you prefer concise coding style then also don't use it.
116
+ Also, if you strongly prefer a concise coding style more strongly than any fear of `void`-related bugs then you can avoid this rule.
@@ -48,3 +48,11 @@ enum E {
48
48
  B = 'B',
49
49
  }
50
50
  ```
51
+
52
+ ## When Not To Use It
53
+
54
+ It can sometimes be useful to include duplicate enum members for very specific use cases.
55
+ For example, when renaming an enum member, it can sometimes be useful to keep the old name until a scheduled major breaking change.
56
+ You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
57
+
58
+ In general, if your project intentionally duplicates enum member values, you can avoid this rule.
@@ -57,3 +57,10 @@ When set to true, duplicate checks on intersection type constituents are ignored
57
57
  ### `ignoreUnions`
58
58
 
59
59
  When set to true, duplicate checks on union type constituents are ignored.
60
+
61
+ ## When Not To Use It
62
+
63
+ It can sometimes be useful for the sake of documentation to include aliases for the same type.
64
+ You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
65
+
66
+ > In some of those cases, [branded types](https://basarat.gitbook.io/typescript/main-1/nominaltyping#using-interfaces) might be a type-safe way to represent the underlying data types.
@@ -47,7 +47,7 @@ delete container['-Infinity'];
47
47
  ## When Not To Use It
48
48
 
49
49
  When you know your keys are safe to delete, this rule can be unnecessary.
50
- Some environments such as older browsers might not support `Map` and `Set`.
50
+ You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
51
51
 
52
52
  Do not consider this rule as performance advice before profiling your code's bottlenecks.
53
53
  Even repeated minor performance slowdowns likely do not significantly affect your application's general perceived speed.
@@ -84,3 +84,12 @@ class Foo extends Base {
84
84
  protected override greet(): void {}
85
85
  }
86
86
  ```
87
+
88
+ ## When Not To Use It
89
+
90
+ If you are working with external APIs that require functions even if they do nothing, then you may want to avoid this rule.
91
+ You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
92
+
93
+ Test code often violates this rule as well.
94
+ If your testing setup doesn't support "mock" or "spy" functions such as [`jest.fn()`](https://jestjs.io/docs/mock-functions), [`sinon.spy()`](https://sinonjs.org/releases/latest/spies), or [`vi.fn()`](https://vitest.dev/guide/mocking.html), you may wish to disable this rule in test files.
95
+ Again, if those cases aren't extremely common, you might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule in test files.
@@ -138,6 +138,8 @@ Most commonly:
138
138
  - If an external package doesn't yet have typings and you want to use `any` pending adding a `.d.ts` for it
139
139
  - You're working with particularly complex or nuanced code that can't yet be represented in the TypeScript type system
140
140
 
141
+ You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
142
+
141
143
  ## Related To
142
144
 
143
145
  - [`no-unsafe-argument`](./no-unsafe-argument.md)
@@ -148,5 +150,7 @@ Most commonly:
148
150
 
149
151
  ## Further Reading
150
152
 
153
+ - TypeScript [`any` type](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#any)
154
+ - TypeScript's [`unknown` type](https://www.typescriptlang.org/docs/handbook/2/functions.html#unknown)
151
155
  - TypeScript [`any` type documentation](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#any)
152
156
  - TypeScript [`unknown` type release notes](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-0.html#new-unknown-top-type)
@@ -50,3 +50,5 @@ function foo(bar?: { n: number }) {
50
50
  return bar?.n;
51
51
  }
52
52
  ```
53
+
54
+ <!-- Intentionally Omitted: When Not To Use It -->
@@ -291,4 +291,5 @@ class Constants {
291
291
 
292
292
  ## When Not To Use It
293
293
 
294
- You can disable this rule if you are unable -or unwilling- to switch off using classes as namespaces.
294
+ If your project was set up before modern class and namespace practices, and you don't have the time to switch over, you might not be practically able to use this rule.
295
+ You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
@@ -99,7 +99,9 @@ await(async function () {
99
99
 
100
100
  ## When Not To Use It
101
101
 
102
- If you do not use Promise-like values in your codebase, or want to allow them to remain unhandled.
102
+ This rule can be difficult to enable on large existing projects that set up many floating Promises.
103
+ Alternately, if you're not worried about crashes from floating or misused Promises -such as if you have global unhandled Promise handlers registered- then in some cases it may be safe to not use this rule.
104
+ You might consider using `void`s and/or [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
103
105
 
104
106
  ## Related To
105
107
 
@@ -53,4 +53,5 @@ for (const [i, value] of array.entries()) {
53
53
 
54
54
  ## When Not To Use It
55
55
 
56
- If you want to iterate through a loop using the indices in an array as strings, you can turn off this rule.
56
+ If your project is a rare one that intentionally loops over string indices of arrays, you can turn off this rule.
57
+ You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
@@ -98,4 +98,5 @@ setTimeout(Foo.fn, 100);
98
98
 
99
99
  ## When Not To Use It
100
100
 
101
- If you want to allow `new Function()` or `setTimeout()`, `setInterval()`, `setImmediate()` and `execScript()` with string arguments, then you can safely disable this rule.
101
+ If your project is a rare one that needs to allow `new Function()` or `setTimeout()`, `setInterval()`, `setImmediate()` and `execScript()` with string arguments, then you can disable this rule.
102
+ You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
@@ -65,8 +65,7 @@ import T, { type U } from 'mod';
65
65
 
66
66
  ## When Not To Use It
67
67
 
68
- - If you want to leave behind side effect imports, then you shouldn't use this rule.
69
- - If you're not using TypeScript 5.0's `verbatimModuleSyntax` option, then you don't need this rule.
68
+ If you're not using TypeScript 5.0's `verbatimModuleSyntax` option and your project is built with a bundler that manages import side effects for you, this rule may not be as useful for you.
70
69
 
71
70
  ## Related To
72
71
 
@@ -96,8 +96,8 @@ class Foo {
96
96
 
97
97
  ## When Not To Use It
98
98
 
99
- If you do not want to enforce inferred types.
99
+ If you strongly prefer to have explicit types regardless of whether they can be inferred, this rule may not be for you.
100
100
 
101
101
  ## Further Reading
102
102
 
103
- TypeScript [Inference](https://www.typescriptlang.org/docs/handbook/type-inference.html)
103
+ - [TpeScript Inference](https://www.typescriptlang.org/docs/handbook/type-inference.html)
@@ -109,5 +109,4 @@ class Example {
109
109
 
110
110
  ## When Not To Use It
111
111
 
112
- If you don't care about if `void` is used with other types,
113
- or in invalid places, then you don't need this rule.
112
+ If you don't care about if `void` is used with other types, or in invalid places, then you don't need this rule.
@@ -111,3 +111,9 @@ Examples of **correct** code for the `{ "ignoreTypeIndexes": true }` option:
111
111
  type Foo = Bar[0];
112
112
  type Baz = Parameters<Foo>[2];
113
113
  ```
114
+
115
+ ## When Not To Use It
116
+
117
+ If your project frequently deals with constant numbers and you don't wish to take up extra space to declare them, this rule might not be for you.
118
+ We recommend at least using descriptive comments and/or names to describe constants.
119
+ You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) instead of completely disabling this rule.
@@ -45,3 +45,7 @@ void bar(); // discarding a number
45
45
  ## Options
46
46
 
47
47
  `checkNever: true` will suggest removing `void` when the argument has type `never`.
48
+
49
+ ## When Not To Use It
50
+
51
+ If you don't mind extra `void`s in your project, you can avoid this rule.
@@ -43,4 +43,5 @@ interface I {
43
43
 
44
44
  ## When Not To Use It
45
45
 
46
- If you intentionally want a class with a `new` method, and you're confident nobody working in your code will mistake it with a constructor.
46
+ If you intentionally want a class with a `new` method, and you're confident nobody working in your code will mistake it with a constructor, you might not want this rule.
47
+ You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
@@ -233,8 +233,9 @@ return { foo: 42, ...(await getData2()) };
233
233
 
234
234
  ## When Not To Use It
235
235
 
236
- If you do not use Promises in your codebase or are not concerned with possible
237
- misuses of them outside of what the TypeScript compiler will check.
236
+ This rule can be difficult to enable on large existing projects that set up many misused Promises.
237
+ Alternately, if you're not worried about crashes from floating or misused Promises -such as if you have global unhandled Promise handlers registered- then in some cases it may be safe to not use this rule.
238
+ You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
238
239
 
239
240
  ## Further Reading
240
241
 
@@ -120,7 +120,9 @@ declare module 'foo' {}
120
120
 
121
121
  ## When Not To Use It
122
122
 
123
- If you are using the ES2015 module syntax, then you will not need this rule.
123
+ If your project was architected before modern modules and namespaces, it may be difficult to migrate off of namespaces.
124
+ In that case you may not be able to use this rule for parts of your project.
125
+ You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
124
126
 
125
127
  ## Further Reading
126
128
 
@@ -43,6 +43,11 @@ let x: string;
43
43
  x! ?? '';
44
44
  ```
45
45
 
46
+ ## When Not To Use It
47
+
48
+ If your project's types don't yet fully describe whether certain values may be nullable, such as if you're transitioning to `strictNullChecks`, this rule might create many false reports.
49
+ You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
50
+
46
51
  ## Further Reading
47
52
 
48
53
  - [TypeScript 3.7 Release Notes](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html)
@@ -29,6 +29,11 @@ foo?.bar;
29
29
  foo?.bar();
30
30
  ```
31
31
 
32
+ ## When Not To Use It
33
+
34
+ If your project's types don't yet fully describe whether certain values may be nullable, such as if you're transitioning to `strictNullChecks`, this rule might create many false reports.
35
+ You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
36
+
32
37
  ## Further Reading
33
38
 
34
39
  - [TypeScript 3.7 Release Notes](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html)
@@ -38,5 +38,5 @@ const includesBaz = example.property?.includes('baz') ?? false;
38
38
 
39
39
  ## When Not To Use It
40
40
 
41
- If your project does not use the `strictNullChecks` compiler option, this rule is likely useless to you.
42
- If your code is often wildly incorrect with respect to strict null-checking, your code may not yet be ready for this rule.
41
+ If your project's types don't yet fully describe whether certain values may be nullable, such as if you're transitioning to `strictNullChecks`, this rule might create many false reports.
42
+ You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
@@ -70,6 +70,20 @@ type IntersectionStringLiteral = 'foo';
70
70
 
71
71
  This rule plays it safe and only works with bottom types, top types, and comparing literal types to primitive types.
72
72
 
73
+ ## When Not To Use It
74
+
75
+ Some projects choose to occasionally intentionally include a redundant type constituent for documentation purposes.
76
+ For example, the following code includes `string` in a union even though the `unknown` makes it redundant:
77
+
78
+ ```ts
79
+ /**
80
+ * Normally a string name, but sometimes arbitrary unknown data.
81
+ */
82
+ type NameOrOther = string | unknown;
83
+ ```
84
+
85
+ If you strongly feel a preference for these unnecessary type constituents, this rule might not be for you.
86
+
73
87
  ## Further Reading
74
88
 
75
89
  - [Union Types](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#union-types)
@@ -30,7 +30,8 @@ import * as lib3 from 'lib3';
30
30
 
31
31
  ## When Not To Use It
32
32
 
33
- If you don't care about using newer module syntax, then you will not need this rule.
33
+ If your project frequently uses older CommonJS `require`s, then this rule might not be applicable to you.
34
+ If only a subset of your project uses `require`s then you might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
34
35
 
35
36
  ## Related To
36
37
 
@@ -35,4 +35,5 @@ setTimeout(() => {
35
35
 
36
36
  ## When Not To Use It
37
37
 
38
- If you need to assign `this` to variables, you shouldn’t use this rule.
38
+ If your project is structured in a way that it needs to assign `this` to variables, this rule is likely not for you.
39
+ If only a subset of your project assigns `this` to variables then you might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
@@ -109,3 +109,5 @@ const defaultOptions: Options = {
109
109
  allowThrowingUnknown: false,
110
110
  };
111
111
  ```
112
+
113
+ <!-- Intentionally omitted: When Not To Use It -->
@@ -606,10 +606,7 @@ type Foo = Partial<Bar>;
606
606
  type Foo = Omit<Bar, 'a' | 'b'>;
607
607
  ```
608
608
 
609
- ## When Not To Use It
610
-
611
- When you can't express some shape with an interface or you need to use a union, tuple type,
612
- callback, etc. that would cause the code to be unreadable or impractical.
609
+ <!-- Intentionally Omitted: When Not To Use It -->
613
610
 
614
611
  ## Further Reading
615
612
 
@@ -126,7 +126,7 @@ if (!(someNullCondition ?? true)) {
126
126
  | `!(nullableBooleanVar === false)` | `nullableBooleanVar ?? true` | Only checked/fixed if the `allowComparingNullableBooleansToFalse` option is `false` |
127
127
  | `!(nullableBooleanVar !== false)` | `!(nullableBooleanVar ?? true)` | Only checked/fixed if the `allowComparingNullableBooleansToFalse` option is `false` |
128
128
 
129
- ## Not To Use It
129
+ ## When Not To Use It
130
130
 
131
131
  Do not use this rule when `strictNullChecks` is disabled.
132
132
  ESLint is not able to distinguish between `false` and `undefined` or `null` values.
@@ -95,7 +95,8 @@ If for some reason you cannot turn on `strictNullChecks`, but still want to use
95
95
 
96
96
  ## When Not To Use It
97
97
 
98
- The main downside to using this rule is the need for type information.
98
+ If your project is not accurately typed, such as if it's in the process of being converted to TypeScript or is susceptible to [trade-offs in control flow analysis](https://github.com/Microsoft/TypeScript/issues/9998), it may be difficult to enable this rule for particularly non-type-safe areas of code.
99
+ You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
99
100
 
100
101
  This rule has a known edge case of triggering on conditions that were modified within function calls (as side effects).
101
102
  It is due to limitations of TypeScript's type narrowing.
@@ -48,4 +48,4 @@ namespace A {
48
48
 
49
49
  ## When Not To Use It
50
50
 
51
- If you don't care about having unneeded enum or namespace qualifiers, then you don't need to use this rule.
51
+ If you explicitly prefer to use fully qualified names, such as for explicitness, then you don't need to use this rule.
@@ -71,3 +71,7 @@ class D extends C<string> {}
71
71
  interface I<T = number> {}
72
72
  class Impl implements I<string> {}
73
73
  ```
74
+
75
+ ## When Not To Use It
76
+
77
+ If you prefer explicitly specifying type parameters even when they are equal to the default, you can skip this rule.
@@ -78,6 +78,16 @@ declare function foo(arg1: unknown, arg2: Set<unknown>, arg3: unknown[]): void;
78
78
  foo(1 as any, new Set<any>(), [] as any[]);
79
79
  ```
80
80
 
81
+ ## When Not To Use It
82
+
83
+ If your codebase has many existing `any`s or areas of unsafe code, it may be difficult to enable this rule.
84
+ It may be easier to skip the `no-unsafe-*` rules pending increasing type safety in unsafe areas of your project.
85
+ You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
86
+
81
87
  ## Related To
82
88
 
83
89
  - [`no-explicit-any`](./no-explicit-any.md)
90
+ - [`no-unsafe-assignment`](./no-unsafe-assignment.md)
91
+ - [`no-unsafe-call`](./no-unsafe-call.md)
92
+ - [`no-unsafe-member-access`](./no-unsafe-member-access.md)
93
+ - [`no-unsafe-return`](./no-unsafe-return.md)
@@ -81,6 +81,16 @@ const x: unknown[] = y as any[];
81
81
  const x: Set<unknown> = y as Set<any>;
82
82
  ```
83
83
 
84
+ ## When Not To Use It
85
+
86
+ If your codebase has many existing `any`s or areas of unsafe code, it may be difficult to enable this rule.
87
+ It may be easier to skip the `no-unsafe-*` rules pending increasing type safety in unsafe areas of your project.
88
+ You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
89
+
84
90
  ## Related To
85
91
 
86
92
  - [`no-explicit-any`](./no-explicit-any.md)
93
+ - [`no-unsafe-argument`](./no-unsafe-argument.md)
94
+ - [`no-unsafe-call`](./no-unsafe-call.md)
95
+ - [`no-unsafe-member-access`](./no-unsafe-member-access.md)
96
+ - [`no-unsafe-return`](./no-unsafe-return.md)
@@ -53,6 +53,16 @@ new Map();
53
53
  String.raw`foo`;
54
54
  ```
55
55
 
56
+ ## When Not To Use It
57
+
58
+ If your codebase has many existing `any`s or areas of unsafe code, it may be difficult to enable this rule.
59
+ It may be easier to skip the `no-unsafe-*` rules pending increasing type safety in unsafe areas of your project.
60
+ You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
61
+
56
62
  ## Related To
57
63
 
58
64
  - [`no-explicit-any`](./no-explicit-any.md)
65
+ - [`no-unsafe-argument`](./no-unsafe-argument.md)
66
+ - [`no-unsafe-assignment`](./no-unsafe-assignment.md)
67
+ - [`no-unsafe-member-access`](./no-unsafe-member-access.md)
68
+ - [`no-unsafe-return`](./no-unsafe-return.md)
@@ -49,6 +49,11 @@ namespace Qux {}
49
49
  function Qux() {}
50
50
  ```
51
51
 
52
+ ## When Not To Use It
53
+
54
+ If your project intentionally defines classes and interfaces with unsafe declaration merging patterns, this rule might not be for you.
55
+ You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
56
+
52
57
  ## Further Reading
53
58
 
54
59
  - [Declaration Merging](https://www.typescriptlang.org/docs/handbook/declaration-merging.html)
@@ -77,3 +77,6 @@ vegetable === Vegetable.Asparagus;
77
77
  ## When Not To Use It
78
78
 
79
79
  If you don't mind number and/or literal string constants being compared against enums, you likely don't need this rule.
80
+
81
+ Separately, in the rare case of relying on an third party enums that are only imported as `type`s, it may be difficult to adhere to this rule.
82
+ You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
@@ -59,6 +59,16 @@ arr[idx];
59
59
  arr[idx++];
60
60
  ```
61
61
 
62
+ ## When Not To Use It
63
+
64
+ If your codebase has many existing `any`s or areas of unsafe code, it may be difficult to enable this rule.
65
+ It may be easier to skip the `no-unsafe-*` rules pending increasing type safety in unsafe areas of your project.
66
+ You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
67
+
62
68
  ## Related To
63
69
 
64
70
  - [`no-explicit-any`](./no-explicit-any.md)
71
+ - [`no-unsafe-argument`](./no-unsafe-argument.md)
72
+ - [`no-unsafe-assignment`](./no-unsafe-assignment.md)
73
+ - [`no-unsafe-call`](./no-unsafe-call.md)
74
+ - [`no-unsafe-return`](./no-unsafe-return.md)
@@ -98,6 +98,16 @@ function foo2(): unknown[] {
98
98
  }
99
99
  ```
100
100
 
101
+ ## When Not To Use It
102
+
103
+ If your codebase has many existing `any`s or areas of unsafe code, it may be difficult to enable this rule.
104
+ It may be easier to skip the `no-unsafe-*` rules pending increasing type safety in unsafe areas of your project.
105
+ You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
106
+
101
107
  ## Related To
102
108
 
103
109
  - [`no-explicit-any`](./no-explicit-any.md)
110
+ - [`no-unsafe-argument`](./no-unsafe-argument.md)
111
+ - [`no-unsafe-assignment`](./no-unsafe-assignment.md)
112
+ - [`no-unsafe-call`](./no-unsafe-call.md)
113
+ - [`no-unsafe-member-access`](./no-unsafe-member-access.md)
@@ -48,3 +48,5 @@ declare const d: any;
48
48
  declare const e: 1 | 2;
49
49
  -e;
50
50
  ```
51
+
52
+ <!-- Intentionally Omitted: When Not To Use It -->
@@ -41,3 +41,7 @@ export const value = 'Hello, world!';
41
41
  ```ts
42
42
  import 'some-other-module';
43
43
  ```
44
+
45
+ ## When Not To Use It
46
+
47
+ If you don't mind an empty `export {}` at the bottom of files, you likely don't need this rule.
@@ -30,7 +30,8 @@ import foo from 'foo';
30
30
 
31
31
  ## When Not To Use It
32
32
 
33
- If you don't care about using newer module syntax, then you will not need this rule.
33
+ If your project frequently uses older CommonJS `require`s, then this rule might not be applicable to you.
34
+ If only a subset of your project uses `require`s then you might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
34
35
 
35
36
  ## Related To
36
37
 
@@ -38,4 +38,4 @@ const alsoDefinitely = maybe!;
38
38
 
39
39
  ## When Not To Use It
40
40
 
41
- If you don't mind having unnecessarily verbose type casts, you can avoid this rule.
41
+ If you don't mind having unnecessarily verbose type assertions, you can avoid this rule.
@@ -482,4 +482,7 @@ class Foo {
482
482
 
483
483
  ## When Not To Use It
484
484
 
485
- If you don't care about the using parameter properties in constructors, then you will not need this rule.
485
+ If you don't care about which style of parameter properties in constructors is used in your classes, then you will not need this rule.
486
+
487
+ However, keep in mind that inconsistent style can harm readability in a project.
488
+ We recommend picking a single option for this rule that works best for your project.
@@ -41,4 +41,7 @@ let foo = { bar: 'baz' };
41
41
 
42
42
  ## When Not To Use It
43
43
 
44
- If you are using TypeScript < 3.4
44
+ If you don't care about which style of literals assertions is used in your code, then you will not need this rule.
45
+
46
+ However, keep in mind that inconsistent style can harm readability in a project.
47
+ We recommend picking a single option for this rule that works best for your project.
@@ -41,6 +41,4 @@ for (let i = 0; i < array.length; i++) {
41
41
  }
42
42
  ```
43
43
 
44
- ## When Not To Use It
45
-
46
- If you transpile for browsers that do not support for-of loops, you may wish to use traditional for loops that produce more compact code.
44
+ <!-- Intentionally Omitted: When Not To Use It -->