@typescript-eslint/eslint-plugin 6.14.0 → 6.16.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 (79) hide show
  1. package/dist/configs/all.js +1 -40
  2. package/dist/configs/all.js.map +1 -1
  3. package/dist/configs/disable-type-checked.js +1 -0
  4. package/dist/configs/disable-type-checked.js.map +1 -1
  5. package/dist/configs/strict-type-checked.js +1 -0
  6. package/dist/configs/strict-type-checked.js.map +1 -1
  7. package/dist/rules/block-spacing.js +2 -0
  8. package/dist/rules/block-spacing.js.map +1 -1
  9. package/dist/rules/brace-style.js +2 -0
  10. package/dist/rules/brace-style.js.map +1 -1
  11. package/dist/rules/comma-dangle.js +2 -0
  12. package/dist/rules/comma-dangle.js.map +1 -1
  13. package/dist/rules/comma-spacing.js +2 -0
  14. package/dist/rules/comma-spacing.js.map +1 -1
  15. package/dist/rules/consistent-type-exports.js +1 -1
  16. package/dist/rules/consistent-type-exports.js.map +1 -1
  17. package/dist/rules/func-call-spacing.js +2 -0
  18. package/dist/rules/func-call-spacing.js.map +1 -1
  19. package/dist/rules/indent.js +2 -0
  20. package/dist/rules/indent.js.map +1 -1
  21. package/dist/rules/index.js +2 -0
  22. package/dist/rules/index.js.map +1 -1
  23. package/dist/rules/key-spacing.js +2 -0
  24. package/dist/rules/key-spacing.js.map +1 -1
  25. package/dist/rules/keyword-spacing.js +2 -0
  26. package/dist/rules/keyword-spacing.js.map +1 -1
  27. package/dist/rules/lines-around-comment.js +2 -0
  28. package/dist/rules/lines-around-comment.js.map +1 -1
  29. package/dist/rules/lines-between-class-members.js +2 -0
  30. package/dist/rules/lines-between-class-members.js.map +1 -1
  31. package/dist/rules/member-delimiter-style.js +2 -0
  32. package/dist/rules/member-delimiter-style.js.map +1 -1
  33. package/dist/rules/no-extra-parens.js +2 -0
  34. package/dist/rules/no-extra-parens.js.map +1 -1
  35. package/dist/rules/no-extra-semi.js +2 -0
  36. package/dist/rules/no-extra-semi.js.map +1 -1
  37. package/dist/rules/no-for-in-array.js +1 -1
  38. package/dist/rules/no-for-in-array.js.map +1 -1
  39. package/dist/rules/no-useless-template-literals.js +88 -0
  40. package/dist/rules/no-useless-template-literals.js.map +1 -0
  41. package/dist/rules/object-curly-spacing.js +2 -0
  42. package/dist/rules/object-curly-spacing.js.map +1 -1
  43. package/dist/rules/padding-line-between-statements.js +2 -0
  44. package/dist/rules/padding-line-between-statements.js.map +1 -1
  45. package/dist/rules/quotes.js +2 -0
  46. package/dist/rules/quotes.js.map +1 -1
  47. package/dist/rules/require-array-sort-compare.js +12 -10
  48. package/dist/rules/require-array-sort-compare.js.map +1 -1
  49. package/dist/rules/semi.js +2 -0
  50. package/dist/rules/semi.js.map +1 -1
  51. package/dist/rules/space-before-blocks.js +2 -0
  52. package/dist/rules/space-before-blocks.js.map +1 -1
  53. package/dist/rules/space-before-function-paren.js +2 -0
  54. package/dist/rules/space-before-function-paren.js.map +1 -1
  55. package/dist/rules/space-infix-ops.js +2 -0
  56. package/dist/rules/space-infix-ops.js.map +1 -1
  57. package/dist/rules/type-annotation-spacing.js +2 -0
  58. package/dist/rules/type-annotation-spacing.js.map +1 -1
  59. package/dist/rules/unbound-method.js +13 -51
  60. package/dist/rules/unbound-method.js.map +1 -1
  61. package/docs/rules/explicit-member-accessibility.md +2 -2
  62. package/docs/rules/no-empty-interface.md +2 -13
  63. package/docs/rules/no-explicit-any.md +7 -0
  64. package/docs/rules/no-for-in-array.md +8 -4
  65. package/docs/rules/no-meaningless-void-operator.md +2 -0
  66. package/docs/rules/no-misused-promises.md +5 -5
  67. package/docs/rules/no-parameter-properties.md +12 -0
  68. package/docs/rules/no-shadow.md +13 -7
  69. package/docs/rules/no-this-alias.md +69 -0
  70. package/docs/rules/no-unnecessary-condition.md +1 -2
  71. package/docs/rules/no-useless-template-literals.md +57 -0
  72. package/docs/rules/parameter-properties.md +2 -2
  73. package/docs/rules/prefer-literal-enum-member.md +3 -1
  74. package/docs/rules/prefer-nullish-coalescing.md +10 -0
  75. package/docs/rules/promise-function-async.md +68 -0
  76. package/docs/rules/require-array-sort-compare.md +4 -4
  77. package/docs/rules/sort-type-constituents.md +56 -0
  78. package/docs/rules/triple-slash-reference.md +71 -23
  79. package/package.json +8 -8
@@ -56,6 +56,8 @@ function getRules(rules, node) {
56
56
  exports.default = (0, util_1.createRule)({
57
57
  name: 'type-annotation-spacing',
58
58
  meta: {
59
+ deprecated: true,
60
+ replacedBy: ['@stylistic/ts/type-annotation-spacing'],
59
61
  type: 'layout',
60
62
  docs: {
61
63
  description: 'Require consistent spacing around type annotations',
@@ -1 +1 @@
1
- {"version":3,"file":"type-annotation-spacing.js","sourceRoot":"","sources":["../../src/rules/type-annotation-spacing.ts"],"names":[],"mappings":";;AACA,wEAAsE;AAEtE,kCASiB;AA8BjB,SAAS,WAAW,CAAC,OAAgB;IACnC,MAAM,OAAO,GAAG;QACd,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACpE,GAAG,CAAC,OAAO,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAClE,CAAC;IACF,MAAM,QAAQ,GAAG,OAAO,EAAE,SAAS,IAAI,EAAE,CAAC;IAC1C,MAAM,KAAK,GAAG;QACZ,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE;QACjC,GAAG,OAAO;QACV,GAAG,QAAQ,CAAC,KAAK;KAClB,CAAC;IACF,MAAM,KAAK,GAAG;QACZ,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE;QAChC,GAAG,OAAO;QACV,GAAG,QAAQ,CAAC,KAAK;KAClB,CAAC;IAEF,OAAO;QACL,KAAK,E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KAAK,CAAC,CAAC,CAAC;yBACnB,CAAC,CAAC;oBACL,CAAC;iBACF,CAAC,CAAC;YACL,CAAC;YAED,IAAI,MAAM,IAAI,aAAa,KAAK,CAAC,EAAE,CAAC;gBAClC,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI,EAAE,oBAAoB;oBAC1B,SAAS,EAAE,qBAAqB;oBAChC,IAAI,EAAE;wBACJ,IAAI;qBACL;oBACD,GAAG,CAAC,KAAK;wBACP,OAAO,KAAK,CAAC,eAAe,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;oBACnD,CAAC;iBACF,CAAC,CAAC;YACL,CAAC;iBAAM,IAAI,CAAC,MAAM,IAAI,aAAa,GAAG,CAAC,EAAE,CAAC;gBACxC,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI,EAAE,oBAAoB;oBAC1B,SAAS,EAAE,uBAAuB;oBAClC,IAAI,EAAE;wBACJ,IAAI;qBACL;oBACD,GAAG,CAAC,KAAK;wBACP,OAAO,KAAK,CAAC,WAAW,CAAC;4BACvB,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;4BACtB,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC;yBAC9B,CAAC,CAAC;oBACL,CAAC;iBACF,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,OAAO;YACL,YAAY,CAAC,IAAI;gBACf,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;oBACxB,0BAA0B,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;gBAClD,CAAC;YACH,CAAC;YACD,gBAAgB,CAAC,IAAI;gBACnB,0BAA0B,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YAClD,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -29,51 +29,16 @@ const tsutils = __importStar(require("ts-api-utils"));
29
29
  const ts = __importStar(require("typescript"));
30
30
  const util_1 = require("../util");
31
31
  /**
32
- * The following is a list of exceptions to the rule
33
- * Generated via the following script.
34
- * This is statically defined to save making purposely invalid calls every lint run
35
- * ```
36
- SUPPORTED_GLOBALS.flatMap(namespace => {
37
- const object = window[namespace];
38
- return Object.getOwnPropertyNames(object)
39
- .filter(
40
- name =>
41
- !name.startsWith('_') &&
42
- typeof object[name] === 'function',
43
- )
44
- .map(name => {
45
- try {
46
- const x = object[name];
47
- x();
48
- } catch (e) {
49
- if (e.message.includes("called on non-object")) {
50
- return `${namespace}.${name}`;
51
- }
52
- }
53
- });
54
- }).filter(Boolean);
55
- * ```
32
+ * Static methods on these globals are either not `this`-aware or supported being
33
+ * called without `this`.
34
+ *
35
+ * - `Promise` is not in the list because it supports subclassing by using `this`
36
+ * - `Array` is in the list because although it supports subclassing, the `this`
37
+ * value defaults to `Array` when unbound
38
+ *
39
+ * This is now a language-design invariant: static methods are never `this`-aware
40
+ * because TC39 wants to make `array.map(Class.method)` work!
56
41
  */
57
- const nativelyNotBoundMembers = new Set([
58
- 'Promise.all',
59
- 'Promise.race',
60
- 'Promise.resolve',
61
- 'Promise.reject',
62
- 'Promise.allSettled',
63
- 'Object.defineProperties',
64
- 'Object.defineProperty',
65
- 'Reflect.defineProperty',
66
- 'Reflect.deleteProperty',
67
- 'Reflect.get',
68
- 'Reflect.getOwnPropertyDescriptor',
69
- 'Reflect.getPrototypeOf',
70
- 'Reflect.has',
71
- 'Reflect.isExtensible',
72
- 'Reflect.ownKeys',
73
- 'Reflect.preventExtensions',
74
- 'Reflect.set',
75
- 'Reflect.setPrototypeOf',
76
- ]);
77
42
  const SUPPORTED_GLOBALS = [
78
43
  'Number',
79
44
  'Object',
@@ -83,7 +48,6 @@ const SUPPORTED_GLOBALS = [
83
48
  'Array',
84
49
  'Proxy',
85
50
  'Date',
86
- 'Infinity',
87
51
  'Atomics',
88
52
  'Reflect',
89
53
  'console',
@@ -91,7 +55,7 @@ const SUPPORTED_GLOBALS = [
91
55
  'JSON',
92
56
  'Intl',
93
57
  ];
94
- const nativelyBoundMembers = SUPPORTED_GLOBALS.map(namespace => {
58
+ const nativelyBoundMembers = new Set(SUPPORTED_GLOBALS.flatMap(namespace => {
95
59
  if (!(namespace in global)) {
96
60
  // node.js might not have namespaces like Intl depending on compilation options
97
61
  // https://nodejs.org/api/intl.html#intl_options_for_building_node_js
@@ -102,9 +66,7 @@ const nativelyBoundMembers = SUPPORTED_GLOBALS.map(namespace => {
102
66
  .filter(name => !name.startsWith('_') &&
103
67
  typeof object[name] === 'function')
104
68
  .map(name => `${namespace}.${name}`);
105
- })
106
- .reduce((arr, names) => arr.concat(names), [])
107
- .filter(name => !nativelyNotBoundMembers.has(name));
69
+ }));
108
70
  const isNotImported = (symbol, currentSourceFile) => {
109
71
  const { valueDeclaration } = symbol;
110
72
  if (!valueDeclaration) {
@@ -174,7 +136,7 @@ exports.default = (0, util_1.createRule)({
174
136
  }
175
137
  const objectSymbol = services.getSymbolAtLocation(node.object);
176
138
  if (objectSymbol &&
177
- nativelyBoundMembers.includes(getMemberFullName(node)) &&
139
+ nativelyBoundMembers.has(getMemberFullName(node)) &&
178
140
  isNotImported(objectSymbol, currentSourceFile)) {
179
141
  return;
180
142
  }
@@ -193,7 +155,7 @@ exports.default = (0, util_1.createRule)({
193
155
  property.key.type === utils_1.AST_NODE_TYPES.Identifier) {
194
156
  if (notImported &&
195
157
  (0, util_1.isIdentifier)(initNode) &&
196
- nativelyBoundMembers.includes(`${initNode.name}.${property.key.name}`)) {
158
+ nativelyBoundMembers.has(`${initNode.name}.${property.key.name}`)) {
197
159
  return;
198
160
  }
199
161
  checkMethodAndReport(property.key, initTypes.getProperty(property.key.name));
@@ -1 +1 @@
1
- {"version":3,"file":"unbound-method.js","sourceRoot":"","sources":["../../src/rules/unbound-method.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,oDAA0D;AAC1D,wEAAoE;AACpE,sDAAwC;AACxC,+CAAiC;AAEjC,kCAKiB;AAcjB;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,uBAAuB,GAAG,IA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AI,KAAK,sBAAc,CAAC,KAAK;wBACzC,MAAM,CAAC,IAAI,CAAC,IAAI,KAAK,sBAAc,CAAC,gBAAgB;wBACpD,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,sBAAc,CAAC,cAAc,CAAC,CAAC,CAChE,CAAC;QAEJ,KAAK,sBAAc,CAAC,eAAe,CAAC;QACpC,KAAK,sBAAc,CAAC,mBAAmB,CAAC;QACxC,KAAK,sBAAc,CAAC,cAAc,CAAC;QACnC,KAAK,sBAAc,CAAC,eAAe;YACjC,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC;QAE3B,KAAK,sBAAc,CAAC,iBAAiB;YACnC,IAAI,MAAM,CAAC,QAAQ,KAAK,IAAI,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;gBACrD,qEAAqE;gBACrE,OAAO,IAAI,CAAC;YACd,CAAC;YAED,oFAAoF;YACpF,0CAA0C;YAC1C,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -164,7 +164,7 @@ class Animal {
164
164
  }
165
165
  ```
166
166
 
167
- ### Overrides
167
+ ### `overrides`
168
168
 
169
169
  There are three ways in which an override can be used.
170
170
 
@@ -312,7 +312,7 @@ class Animal {
312
312
  }
313
313
  ```
314
314
 
315
- ### Except specific methods
315
+ ### `ignoredMethodNames`
316
316
 
317
317
  If you want to ignore some specific methods, you can do it by specifying method names. Note that this option does not care for the context, and will ignore every method with these names, which could lead to it missing some cases. You should use this sparingly.
318
318
  e.g. `[ { ignoredMethodNames: ['specificMethod', 'whateverMethod'] } ]`
@@ -50,20 +50,9 @@ interface Baz extends Foo, Bar {}
50
50
 
51
51
  ## Options
52
52
 
53
- This rule accepts a single object option with the following default configuration:
54
-
55
- ```json
56
- {
57
- "@typescript-eslint/no-empty-interface": [
58
- "error",
59
- {
60
- "allowSingleExtends": false
61
- }
62
- ]
63
- }
64
- ```
53
+ ### `allowSingleExtends`
65
54
 
66
- - `allowSingleExtends: true` will silence warnings about extending a single interface without adding additional members
55
+ `allowSingleExtends: true` will silence warnings about extending a single interface without adding additional members
67
56
 
68
57
  ## When Not To Use It
69
58
 
@@ -94,6 +94,13 @@ function greet(param: Array<string>): Array<string> {}
94
94
 
95
95
  ## Options
96
96
 
97
+ ### `fixToUnknown`
98
+
99
+ By default, this rule will not provide automatic ESLint _fixes_: only opt-in _suggestions_.
100
+ Switching types to `unknown` is safer but is likely to cause additional type errors.
101
+
102
+ Enabling `{ "fixToUnknown": true }` gives the rule an auto-fixer to replace `: any` with `: unknown`.
103
+
97
104
  ### `ignoreRestArgs`
98
105
 
99
106
  A boolean to specify if arrays from the rest operator are considered okay. `false` by default.
@@ -6,10 +6,14 @@ description: 'Disallow iterating over an array with a for-in loop.'
6
6
  >
7
7
  > See **https://typescript-eslint.io/rules/no-for-in-array** for documentation.
8
8
 
9
- A for-in loop (`for (var i in o)`) iterates over the properties of an Object.
10
- While it is legal to use for-in loops with array types, it is not common.
11
- for-in will iterate over the indices of the array as strings, omitting any "holes" in
12
- the array.
9
+ A for-in loop (`for (const i in o)`) iterates over the properties of an Object.
10
+ While it is legal to use for-in loops with array values, it is not common. There are several potential bugs with this:
11
+
12
+ 1. It iterates over all enumerable properties, including non-index ones and the entire prototype chain. For example, [`RegExp.prototype.exec`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec) returns an array with additional properties, and `for-in` will iterate over them. Some libraries or even your own code may add additional methods to `Array.prototype` (either as polyfill or as custom methods), and if not done properly, they may be iterated over as well.
13
+ 2. It skips holes in the array. While sparse arrays are rare and advised against, they are still possible and your code should be able to handle them.
14
+ 3. The "index" is returned as a string, not a number. This can be caught by TypeScript, but can still lead to subtle bugs.
15
+
16
+ You may have confused for-in with for-of, which iterates over the elements of the array. If you actually need the index, use a regular `for` loop or the `forEach` method.
13
17
 
14
18
  ## Examples
15
19
 
@@ -44,6 +44,8 @@ void bar(); // discarding a number
44
44
 
45
45
  ## Options
46
46
 
47
+ ### `checkNever`
48
+
47
49
  `checkNever: true` will suggest removing `void` when the argument has type `never`.
48
50
 
49
51
  ## When Not To Use It
@@ -17,7 +17,7 @@ See [`no-floating-promises`](./no-floating-promises.md) for detecting unhandled
17
17
 
18
18
  ## Options
19
19
 
20
- ### `"checksConditionals"`
20
+ ### `checksConditionals`
21
21
 
22
22
  If you don't want to check conditionals, you can configure the rule with `"checksConditionals": false`:
23
23
 
@@ -73,10 +73,10 @@ while (await promise) {
73
73
 
74
74
  <!--/tabs-->
75
75
 
76
- ### `"checksVoidReturn"`
76
+ ### `checksVoidReturn`
77
77
 
78
- Likewise, if you don't want functions that return promises where a void return is
79
- expected to be checked, your configuration will look like this:
78
+ Likewise, if you don't want to check functions that return promises where a void return is
79
+ expected, your configuration will look like this:
80
80
 
81
81
  ```json
82
82
  {
@@ -182,7 +182,7 @@ eventEmitter.on('some-event', () => {
182
182
 
183
183
  <!--/tabs-->
184
184
 
185
- ### `"checksSpreads"`
185
+ ### `checksSpreads`
186
186
 
187
187
  If you don't want to check object spreads, you can add this configuration:
188
188
 
@@ -0,0 +1,12 @@
1
+ :::danger Deprecated
2
+
3
+ This rule has been deprecated in favour of the [`parameter-properties`](https://typescript-eslint.io/rules/parameter-properties/) rule.
4
+
5
+ :::
6
+
7
+ <!--
8
+ This doc file has been left on purpose to help direct people to the replacement rule.
9
+
10
+ Note that there is no actual way to get to this page in the normal navigation,
11
+ so end-users will only be able to get to this page from the search bar.
12
+ -->
@@ -28,25 +28,31 @@ const defaultOptions: Options = {
28
28
 
29
29
  ### `ignoreTypeValueShadow`
30
30
 
31
- When set to `true`, the rule will ignore the case when you name a type the same as a variable.
32
-
33
- TypeScript allows types and variables to shadow one-another. This is generally safe because you cannot use variables in type locations without a `typeof` operator, so there's little risk of confusion.
31
+ When set to `true`, the rule will ignore the case when you name a type the same as a variable. This is generally safe because you cannot use variables in type locations without a `typeof` operator, so there's little risk of confusion.
34
32
 
35
33
  Examples of **correct** code with `{ ignoreTypeValueShadow: true }`:
36
34
 
37
35
  ```ts option='{ "ignoreTypeValueShadow": true }' showPlaygroundButton
38
36
  type Foo = number;
39
- const Foo = 1;
40
-
41
37
  interface Bar {
42
38
  prop: number;
43
39
  }
44
- const Bar = 'test';
40
+
41
+ function f() {
42
+ const Foo = 1;
43
+ const Bar = 'test';
44
+ }
45
45
  ```
46
46
 
47
+ :::note
48
+
49
+ _Shadowing_ specifically refers to two identical identifiers that are in different, nested scopes. This is different from _redeclaration_, which is when two identical identifiers are in the same scope. Redeclaration is covered by the [`no-redeclare`](./no-redeclare.md) rule instead.
50
+
51
+ :::
52
+
47
53
  ### `ignoreFunctionTypeParameterNameValueShadow`
48
54
 
49
- When set to `true`, the rule will ignore the case when you name a function type argument the same as a variable.
55
+ When set to `true`, the rule will ignore the case when you name a parameter in a function type the same as a variable.
50
56
 
51
57
  Each of a function type's arguments creates a value variable within the scope of the function type. This is done so that you can reference the type later using the `typeof` operator:
52
58
 
@@ -33,6 +33,75 @@ setTimeout(() => {
33
33
 
34
34
  ## Options
35
35
 
36
+ ### `allowDestructuring`
37
+
38
+ It can sometimes be useful to destructure properties from a class instance, such as retrieving multiple properties from the instance in one of its methods.
39
+ `allowDestructuring` allows those destructures and is `true` by default.
40
+ You can explicitly disallow them by setting `allowDestructuring` to `false`.
41
+
42
+ Examples of code for the `{ "allowDestructuring": false }` option:
43
+
44
+ <!--tabs-->
45
+
46
+ #### ❌ Incorrect
47
+
48
+ ```ts option='{ "allowDestructuring": false }'
49
+ class ComponentLike {
50
+ props: unknown;
51
+ state: unknown;
52
+
53
+ render() {
54
+ const { props, state } = this;
55
+
56
+ console.log(props);
57
+ console.log(state);
58
+ }
59
+ }
60
+ ```
61
+
62
+ #### ✅ Correct
63
+
64
+ ```ts option='{ "allowDestructuring": false }'
65
+ class ComponentLike {
66
+ props: unknown;
67
+ state: unknown;
68
+
69
+ render() {
70
+ console.log(this.props);
71
+ console.log(this.state);
72
+ }
73
+ }
74
+ ```
75
+
76
+ ### `allowedNames`
77
+
78
+ `no-this-alias` can alternately be used to allow only a specific list of names as `this` aliases.
79
+ We recommend against this except as a transitory step towards fixing all rule violations.
80
+
81
+ Examples of code for the `{ "allowedNames": ["self"] }` option:
82
+
83
+ <!--tabs-->
84
+
85
+ #### ❌ Incorrect
86
+
87
+ ```ts option='{ "allowedNames": ["self"] }'
88
+ class Example {
89
+ method() {
90
+ const that = this;
91
+ }
92
+ }
93
+ ```
94
+
95
+ #### ✅ Correct
96
+
97
+ ```ts option='{ "allowedNames": ["self"] }'
98
+ class Example {
99
+ method() {
100
+ const self = this;
101
+ }
102
+ }
103
+ ```
104
+
36
105
  ## When Not To Use It
37
106
 
38
107
  If your project is structured in a way that it needs to assign `this` to variables, this rule is likely not for you.
@@ -101,8 +101,7 @@ You might consider using [ESLint disable comments](https://eslint.org/docs/lates
101
101
  This rule has a known edge case of triggering on conditions that were modified within function calls (as side effects).
102
102
  It is due to limitations of TypeScript's type narrowing.
103
103
  See [#9998](https://github.com/microsoft/TypeScript/issues/9998) for details.
104
-
105
- We recommend upcasting the variable with a [type assertion](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#type-assertions).
104
+ We recommend using a [type assertion](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#type-assertions) in those cases.
106
105
 
107
106
  ```ts
108
107
  let condition = false as boolean;
@@ -0,0 +1,57 @@
1
+ ---
2
+ description: 'Disallow unnecessary template literals.'
3
+ ---
4
+
5
+ > 🛑 This file is source code, not the primary documentation location! 🛑
6
+ >
7
+ > See **https://typescript-eslint.io/rules/no-useless-template-literals** for documentation.
8
+
9
+ This rule reports template literals that can be simplified to a normal string literal.
10
+
11
+ ## Examples
12
+
13
+ <!--tabs-->
14
+
15
+ ### ❌ Incorrect
16
+
17
+ ```ts
18
+ const ab1 = `${'a'}${'b'}`;
19
+ const ab2 = `a${'b'}`;
20
+
21
+ const stringWithNumber = `${'1 + 1 = '}${2}`;
22
+
23
+ const stringWithBoolean = `${'true is '}${true}`;
24
+
25
+ const text = 'a';
26
+ const wrappedText = `${text}`;
27
+
28
+ declare const intersectionWithString: string & { _brand: 'test-brand' };
29
+ const wrappedIntersection = `${intersectionWithString}`;
30
+ ```
31
+
32
+ ### ✅ Correct
33
+
34
+ ```ts
35
+ const ab1 = 'ab';
36
+ const ab2 = 'ab';
37
+
38
+ const stringWithNumber = `1 + 1 = 2`;
39
+
40
+ const stringWithBoolean = `true is true`;
41
+
42
+ const text = 'a';
43
+ const wrappedText = text;
44
+
45
+ declare const intersectionWithString: string & { _brand: 'test-brand' };
46
+ const wrappedIntersection = intersectionWithString;
47
+ ```
48
+
49
+ <!--/tabs-->
50
+
51
+ ## When Not To Use It
52
+
53
+ When you want to allow string expressions inside template literals.
54
+
55
+ ## Related To
56
+
57
+ - [`restrict-template-expressions`](./restrict-template-expressions.md)
@@ -19,7 +19,7 @@ It may take an options object containing either or both of:
19
19
  - `"allow"`: allowing certain kinds of properties to be ignored
20
20
  - `"prefer"`: either `"class-property"` _(default)_ or `"parameter-property"`
21
21
 
22
- ### `"allow"`
22
+ ### `allow`
23
23
 
24
24
  If you would like to ignore certain kinds of properties then you may pass an object containing `"allow"` as an array of any of the following options:
25
25
 
@@ -45,7 +45,7 @@ For example, to ignore `public` properties:
45
45
  }
46
46
  ```
47
47
 
48
- ### `"prefer"`
48
+ ### `prefer`
49
49
 
50
50
  By default, the rule prefers class property (`"class-property"`).
51
51
  You can switch it to instead preferring parameter property with (`"parameter-property"`).
@@ -61,7 +61,9 @@ enum Valid {
61
61
 
62
62
  ## Options
63
63
 
64
- - `allowBitwiseExpressions` set to `true` will allow you to use bitwise expressions in enum initializer (Default: `false`).
64
+ ### `allowBitwiseExpressions`
65
+
66
+ When set to `true` will allow you to use bitwise expressions in enum initializer (default: `false`).
65
67
 
66
68
  Examples of code for the `{ "allowBitwiseExpressions": true }` option:
67
69
 
@@ -167,6 +167,16 @@ foo ?? 'a string';
167
167
 
168
168
  Also, if you would like to ignore all primitives types, you can set `ignorePrimitives: true`. It is equivalent to `ignorePrimitives: { string: true, number: true, bigint: true, boolean: true }`.
169
169
 
170
+ ### `allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing`
171
+
172
+ If this is set to `false`, then the rule will error on every file whose `tsconfig.json` does _not_ have the `strictNullChecks` compiler option (or `strict`) set to `true`.
173
+
174
+ 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.
175
+
176
+ You should be using `strictNullChecks` to ensure complete type-safety in your codebase.
177
+
178
+ If for some reason you cannot turn on `strictNullChecks`, but still want to use this rule - you can use this option to allow it - but know that the behavior of this rule is _undefined_ with the compiler option turned off. We will not accept bug reports if you are using this option.
179
+
170
180
  ## When Not To Use It
171
181
 
172
182
  If you are not using TypeScript 3.7 (or greater), then you will not be able to use this rule, as the operator is not supported.
@@ -58,6 +58,74 @@ async function functionReturnsUnionWithPromiseImplicitly(p: boolean) {
58
58
  }
59
59
  ```
60
60
 
61
+ ## Options
62
+
63
+ ### `allowAny`
64
+
65
+ Whether to ignore functions that return `any` and `unknown`.
66
+ If you want additional safety, consider turning this option off, as it makes the rule less able to catch incorrect Promise behaviors.
67
+
68
+ Examples of code with `{ "allowAny": false }`:
69
+
70
+ <!--tabs-->
71
+
72
+ #### ❌ Incorrect
73
+
74
+ ```ts option='{ "allowAny": false }'
75
+ const returnsAny = () => ({}) as any;
76
+ ```
77
+
78
+ #### ✅ Correct
79
+
80
+ ```ts option='{ "allowAny": false }'
81
+ const returnsAny = async () => ({}) as any;
82
+ ```
83
+
84
+ ### `allowedPromiseNames`
85
+
86
+ For projects that use constructs other than the global built-in `Promise` for asynchronous code.
87
+ This option allows specifying string names of classes or interfaces that cause a function to be checked as well.
88
+
89
+ Examples of code with `{ "allowedPromiseNames": ["Bluebird"] }`:
90
+
91
+ <!--tabs-->
92
+
93
+ #### ❌ Incorrect
94
+
95
+ ```ts option='{ "allowedPromiseNames": ["Bluebird"] }'
96
+ import { Bluebird } from 'bluebird';
97
+
98
+ const returnsBluebird = () => new Bluebird(() => {});
99
+ ```
100
+
101
+ #### ✅ Correct
102
+
103
+ ```ts option='{ "allowedPromiseNames": ["Bluebird"] }'
104
+ import { Bluebird } from 'bluebird';
105
+
106
+ const returnsBluebird = async () => new Bluebird(() => {});
107
+ ```
108
+
109
+ ### `checkArrowFunctions`
110
+
111
+ Whether to check arrow functions.
112
+ `true` by default, but can be set to `false` to ignore them.
113
+
114
+ ### `checkFunctionDeclarations`
115
+
116
+ Whether to check standalone function declarations.
117
+ `true` by default, but can be set to `false` to ignore them.
118
+
119
+ ### `checkFunctionExpressions`
120
+
121
+ Whether to check inline function expressions.
122
+ `true` by default, but can be set to `false` to ignore them.
123
+
124
+ ### `checkMethodDeclarations`
125
+
126
+ Whether to check methods on classes and object literals
127
+ `true` by default, but can be set to `false` to ignore them.
128
+
61
129
  ## When Not To Use It
62
130
 
63
131
  This rule can be difficult to enable on projects that use APIs which require functions to always be `async`.
@@ -1,12 +1,12 @@
1
1
  ---
2
- description: 'Require `Array#sort` calls to always provide a `compareFunction`.'
2
+ description: 'Require `Array#sort` and `Array#toSorted` calls to always provide a `compareFunction`.'
3
3
  ---
4
4
 
5
5
  > 🛑 This file is source code, not the primary documentation location! 🛑
6
6
  >
7
7
  > See **https://typescript-eslint.io/rules/require-array-sort-compare** for documentation.
8
8
 
9
- When called without a compare function, `Array#sort()` converts all non-undefined array elements into strings and then compares said strings based off their UTF-16 code units [[ECMA specification](https://www.ecma-international.org/ecma-262/9.0/#sec-sortcompare)].
9
+ When called without a compare function, `Array#sort()` and `Array#toSorted()` converts all non-undefined array elements into strings and then compares said strings based off their UTF-16 code units [[ECMA specification](https://www.ecma-international.org/ecma-262/9.0/#sec-sortcompare)].
10
10
 
11
11
  The result is that elements are sorted alphabetically, regardless of their type.
12
12
  For example, when sorting numbers, this results in a "10 before 2" order:
@@ -15,11 +15,11 @@ For example, when sorting numbers, this results in a "10 before 2" order:
15
15
  [1, 2, 3, 10, 20, 30].sort(); //→ [1, 10, 2, 20, 3, 30]
16
16
  ```
17
17
 
18
- This rule reports on any call to the `Array#sort()` method that doesn't provide a `compare` argument.
18
+ This rule reports on any call to the sort methods that do not provide a `compare` argument.
19
19
 
20
20
  ## Examples
21
21
 
22
- This rule aims to ensure all calls of the native `Array#sort` method provide a `compareFunction`, while ignoring calls to user-defined `sort` methods.
22
+ This rule aims to ensure all calls of the native sort methods provide a `compareFunction`, while ignoring calls to user-defined methods.
23
23
 
24
24
  <!--tabs-->
25
25