@depup/typescript-eslint__eslint-plugin 8.70.0-depup.0 → 8.71.0-depup.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 (56) hide show
  1. package/README.md +3 -3
  2. package/changes.json +2 -2
  3. package/dist/configs/eslintrc/all.d.ts +1 -0
  4. package/dist/configs/eslintrc/all.js +1 -0
  5. package/dist/configs/eslintrc/disable-type-checked.d.ts +1 -0
  6. package/dist/configs/eslintrc/disable-type-checked.js +1 -0
  7. package/dist/configs/eslintrc/strict-type-checked-only.d.ts +1 -0
  8. package/dist/configs/eslintrc/strict-type-checked-only.js +1 -0
  9. package/dist/configs/eslintrc/strict-type-checked.d.ts +1 -0
  10. package/dist/configs/eslintrc/strict-type-checked.js +1 -0
  11. package/dist/configs/flat/all.js +1 -0
  12. package/dist/configs/flat/disable-type-checked.js +1 -0
  13. package/dist/configs/flat/strict-type-checked-only.js +1 -0
  14. package/dist/configs/flat/strict-type-checked.js +1 -0
  15. package/dist/index.d.ts +8 -1
  16. package/dist/raw-plugin.d.ts +8 -1
  17. package/dist/rules/await-thenable.js +14 -3
  18. package/dist/rules/enum-utils/shared.d.ts +4 -0
  19. package/dist/rules/enum-utils/shared.js +1 -0
  20. package/dist/rules/index.d.ts +4 -1
  21. package/dist/rules/index.js +2 -0
  22. package/dist/rules/no-explicit-any.js +10 -2
  23. package/dist/rules/no-generated-empty-object-type.js +6 -2
  24. package/dist/rules/no-meaningless-void-operator.js +5 -0
  25. package/dist/rules/no-misused-promises.js +20 -11
  26. package/dist/rules/no-misused-spread.js +4 -1
  27. package/dist/rules/no-redundant-type-constituents.js +3 -1
  28. package/dist/rules/no-unnecessary-condition.js +53 -5
  29. package/dist/rules/no-unnecessary-parameter-property-assignment.js +12 -4
  30. package/dist/rules/no-unnecessary-type-assertion.d.ts +1 -1
  31. package/dist/rules/no-unnecessary-type-assertion.js +38 -11
  32. package/dist/rules/no-unnecessary-type-constraint.js +1 -0
  33. package/dist/rules/no-unnecessary-type-parameters.js +16 -18
  34. package/dist/rules/no-unsafe-enum-assignment.d.ts +5 -0
  35. package/dist/rules/no-unsafe-enum-assignment.js +473 -0
  36. package/dist/rules/no-useless-default-assignment.d.ts +1 -1
  37. package/dist/rules/no-useless-default-assignment.js +27 -7
  38. package/dist/rules/prefer-nullish-coalescing.js +2 -3
  39. package/dist/rules/prefer-optional-chain-utils/analyzeChain.js +13 -4
  40. package/dist/rules/prefer-optional-chain-utils/gatherLogicalOperands.js +1 -0
  41. package/dist/rules/return-await.js +3 -13
  42. package/dist/rules/strict-void-return.js +2 -0
  43. package/dist/rules/switch-exhaustiveness-check.js +1 -1
  44. package/dist/rules/unbound-method.js +37 -12
  45. package/dist/util/getAwaitTokenRemovalRange.d.ts +4 -0
  46. package/dist/util/getAwaitTokenRemovalRange.js +15 -0
  47. package/dist/util/getOperatorPrecedence.js +1 -0
  48. package/dist/util/getWrappingFixer.js +0 -1
  49. package/dist/util/index.d.ts +3 -1
  50. package/dist/util/index.js +3 -1
  51. package/dist/util/isStartOfArrowFunctionBodyNeedingParentheses.d.ts +2 -0
  52. package/dist/util/{isStartOfArrowFunctionBody.js → isStartOfArrowFunctionBodyNeedingParentheses.js} +6 -2
  53. package/dist/util/isStartOfExpressionStatementNeedingParentheses.d.ts +2 -0
  54. package/dist/util/isStartOfExpressionStatementNeedingParentheses.js +9 -0
  55. package/package.json +12 -12
  56. package/dist/util/isStartOfArrowFunctionBody.d.ts +0 -2
package/README.md CHANGED
@@ -13,8 +13,8 @@ npm install @depup/typescript-eslint__eslint-plugin
13
13
 
14
14
  | Field | Value |
15
15
  |-------|-------|
16
- | Original | [@typescript-eslint/eslint-plugin](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin) @ 8.70.0 |
17
- | Processed | 2026-09-08 |
16
+ | Original | [@typescript-eslint/eslint-plugin](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin) @ 8.71.0 |
17
+ | Processed | 2026-09-29 |
18
18
  | Smoke test | passed |
19
19
  | Deps updated | 1 |
20
20
 
@@ -22,7 +22,7 @@ npm install @depup/typescript-eslint__eslint-plugin
22
22
 
23
23
  | Dependency | From | To |
24
24
  |------------|------|-----|
25
- | ignore | ^7.0.5 | ^7.0.8 |
25
+ | ignore | ^7.0.5 | ^7.0.10 |
26
26
 
27
27
  ---
28
28
 
package/changes.json CHANGED
@@ -2,9 +2,9 @@
2
2
  "bumped": {
3
3
  "ignore": {
4
4
  "from": "^7.0.5",
5
- "to": "^7.0.8"
5
+ "to": "^7.0.10"
6
6
  }
7
7
  },
8
- "timestamp": "2026-09-08T00:33:07.330Z",
8
+ "timestamp": "2026-09-29T00:34:06.060Z",
9
9
  "totalUpdated": 1
10
10
  }
@@ -92,6 +92,7 @@ declare const _default: {
92
92
  '@typescript-eslint/no-unsafe-assignment': "error";
93
93
  '@typescript-eslint/no-unsafe-call': "error";
94
94
  '@typescript-eslint/no-unsafe-declaration-merging': "error";
95
+ '@typescript-eslint/no-unsafe-enum-assignment': "error";
95
96
  '@typescript-eslint/no-unsafe-enum-comparison': "error";
96
97
  '@typescript-eslint/no-unsafe-function-type': "error";
97
98
  '@typescript-eslint/no-unsafe-member-access': "error";
@@ -99,6 +99,7 @@ module.exports = {
99
99
  '@typescript-eslint/no-unsafe-assignment': 'error',
100
100
  '@typescript-eslint/no-unsafe-call': 'error',
101
101
  '@typescript-eslint/no-unsafe-declaration-merging': 'error',
102
+ '@typescript-eslint/no-unsafe-enum-assignment': 'error',
102
103
  '@typescript-eslint/no-unsafe-enum-comparison': 'error',
103
104
  '@typescript-eslint/no-unsafe-function-type': 'error',
104
105
  '@typescript-eslint/no-unsafe-member-access': 'error',
@@ -35,6 +35,7 @@ declare const _default: {
35
35
  '@typescript-eslint/no-unsafe-argument': "off";
36
36
  '@typescript-eslint/no-unsafe-assignment': "off";
37
37
  '@typescript-eslint/no-unsafe-call': "off";
38
+ '@typescript-eslint/no-unsafe-enum-assignment': "off";
38
39
  '@typescript-eslint/no-unsafe-enum-comparison': "off";
39
40
  '@typescript-eslint/no-unsafe-member-access': "off";
40
41
  '@typescript-eslint/no-unsafe-return': "off";
@@ -38,6 +38,7 @@ module.exports = {
38
38
  '@typescript-eslint/no-unsafe-argument': 'off',
39
39
  '@typescript-eslint/no-unsafe-assignment': 'off',
40
40
  '@typescript-eslint/no-unsafe-call': 'off',
41
+ '@typescript-eslint/no-unsafe-enum-assignment': 'off',
41
42
  '@typescript-eslint/no-unsafe-enum-comparison': 'off',
42
43
  '@typescript-eslint/no-unsafe-member-access': 'off',
43
44
  '@typescript-eslint/no-unsafe-return': 'off',
@@ -27,6 +27,7 @@ declare const _default: {
27
27
  '@typescript-eslint/no-unsafe-argument': "error";
28
28
  '@typescript-eslint/no-unsafe-assignment': "error";
29
29
  '@typescript-eslint/no-unsafe-call': "error";
30
+ '@typescript-eslint/no-unsafe-enum-assignment': "error";
30
31
  '@typescript-eslint/no-unsafe-enum-comparison': "error";
31
32
  '@typescript-eslint/no-unsafe-member-access': "error";
32
33
  '@typescript-eslint/no-unsafe-return': "error";
@@ -34,6 +34,7 @@ module.exports = {
34
34
  '@typescript-eslint/no-unsafe-argument': 'error',
35
35
  '@typescript-eslint/no-unsafe-assignment': 'error',
36
36
  '@typescript-eslint/no-unsafe-call': 'error',
37
+ '@typescript-eslint/no-unsafe-enum-assignment': 'error',
37
38
  '@typescript-eslint/no-unsafe-enum-comparison': 'error',
38
39
  '@typescript-eslint/no-unsafe-member-access': 'error',
39
40
  '@typescript-eslint/no-unsafe-return': 'error',
@@ -48,6 +48,7 @@ declare const _default: {
48
48
  '@typescript-eslint/no-unsafe-assignment': "error";
49
49
  '@typescript-eslint/no-unsafe-call': "error";
50
50
  '@typescript-eslint/no-unsafe-declaration-merging': "error";
51
+ '@typescript-eslint/no-unsafe-enum-assignment': "error";
51
52
  '@typescript-eslint/no-unsafe-enum-comparison': "error";
52
53
  '@typescript-eslint/no-unsafe-function-type': "error";
53
54
  '@typescript-eslint/no-unsafe-member-access': "error";
@@ -56,6 +56,7 @@ module.exports = {
56
56
  '@typescript-eslint/no-unsafe-assignment': 'error',
57
57
  '@typescript-eslint/no-unsafe-call': 'error',
58
58
  '@typescript-eslint/no-unsafe-declaration-merging': 'error',
59
+ '@typescript-eslint/no-unsafe-enum-assignment': 'error',
59
60
  '@typescript-eslint/no-unsafe-enum-comparison': 'error',
60
61
  '@typescript-eslint/no-unsafe-function-type': 'error',
61
62
  '@typescript-eslint/no-unsafe-member-access': 'error',
@@ -112,6 +112,7 @@ exports.default = (plugin, parser) => [
112
112
  '@typescript-eslint/no-unsafe-assignment': 'error',
113
113
  '@typescript-eslint/no-unsafe-call': 'error',
114
114
  '@typescript-eslint/no-unsafe-declaration-merging': 'error',
115
+ '@typescript-eslint/no-unsafe-enum-assignment': 'error',
115
116
  '@typescript-eslint/no-unsafe-enum-comparison': 'error',
116
117
  '@typescript-eslint/no-unsafe-function-type': 'error',
117
118
  '@typescript-eslint/no-unsafe-member-access': 'error',
@@ -43,6 +43,7 @@ exports.default = (_plugin, _parser) => ({
43
43
  '@typescript-eslint/no-unsafe-argument': 'off',
44
44
  '@typescript-eslint/no-unsafe-assignment': 'off',
45
45
  '@typescript-eslint/no-unsafe-call': 'off',
46
+ '@typescript-eslint/no-unsafe-enum-assignment': 'off',
46
47
  '@typescript-eslint/no-unsafe-enum-comparison': 'off',
47
48
  '@typescript-eslint/no-unsafe-member-access': 'off',
48
49
  '@typescript-eslint/no-unsafe-return': 'off',
@@ -47,6 +47,7 @@ exports.default = (plugin, parser) => [
47
47
  '@typescript-eslint/no-unsafe-argument': 'error',
48
48
  '@typescript-eslint/no-unsafe-assignment': 'error',
49
49
  '@typescript-eslint/no-unsafe-call': 'error',
50
+ '@typescript-eslint/no-unsafe-enum-assignment': 'error',
50
51
  '@typescript-eslint/no-unsafe-enum-comparison': 'error',
51
52
  '@typescript-eslint/no-unsafe-member-access': 'error',
52
53
  '@typescript-eslint/no-unsafe-return': 'error',
@@ -69,6 +69,7 @@ exports.default = (plugin, parser) => [
69
69
  '@typescript-eslint/no-unsafe-assignment': 'error',
70
70
  '@typescript-eslint/no-unsafe-call': 'error',
71
71
  '@typescript-eslint/no-unsafe-declaration-merging': 'error',
72
+ '@typescript-eslint/no-unsafe-enum-assignment': 'error',
72
73
  '@typescript-eslint/no-unsafe-enum-comparison': 'error',
73
74
  '@typescript-eslint/no-unsafe-function-type': 'error',
74
75
  '@typescript-eslint/no-unsafe-member-access': 'error',
package/dist/index.d.ts CHANGED
@@ -94,6 +94,7 @@ declare const _default: {
94
94
  '@typescript-eslint/no-unsafe-assignment': "error";
95
95
  '@typescript-eslint/no-unsafe-call': "error";
96
96
  '@typescript-eslint/no-unsafe-declaration-merging': "error";
97
+ '@typescript-eslint/no-unsafe-enum-assignment': "error";
97
98
  '@typescript-eslint/no-unsafe-enum-comparison': "error";
98
99
  '@typescript-eslint/no-unsafe-function-type': "error";
99
100
  '@typescript-eslint/no-unsafe-member-access': "error";
@@ -199,6 +200,7 @@ declare const _default: {
199
200
  '@typescript-eslint/no-unsafe-argument': "off";
200
201
  '@typescript-eslint/no-unsafe-assignment': "off";
201
202
  '@typescript-eslint/no-unsafe-call': "off";
203
+ '@typescript-eslint/no-unsafe-enum-assignment': "off";
202
204
  '@typescript-eslint/no-unsafe-enum-comparison': "off";
203
205
  '@typescript-eslint/no-unsafe-member-access': "off";
204
206
  '@typescript-eslint/no-unsafe-return': "off";
@@ -498,6 +500,7 @@ declare const _default: {
498
500
  '@typescript-eslint/no-unsafe-assignment': "error";
499
501
  '@typescript-eslint/no-unsafe-call': "error";
500
502
  '@typescript-eslint/no-unsafe-declaration-merging': "error";
503
+ '@typescript-eslint/no-unsafe-enum-assignment': "error";
501
504
  '@typescript-eslint/no-unsafe-enum-comparison': "error";
502
505
  '@typescript-eslint/no-unsafe-function-type': "error";
503
506
  '@typescript-eslint/no-unsafe-member-access': "error";
@@ -575,6 +578,7 @@ declare const _default: {
575
578
  '@typescript-eslint/no-unsafe-argument': "error";
576
579
  '@typescript-eslint/no-unsafe-assignment': "error";
577
580
  '@typescript-eslint/no-unsafe-call': "error";
581
+ '@typescript-eslint/no-unsafe-enum-assignment': "error";
578
582
  '@typescript-eslint/no-unsafe-enum-comparison': "error";
579
583
  '@typescript-eslint/no-unsafe-member-access': "error";
580
584
  '@typescript-eslint/no-unsafe-return': "error";
@@ -957,6 +961,9 @@ declare const _default: {
957
961
  'no-unsafe-declaration-merging': import("@typescript-eslint/utils/ts-eslint").RuleModule<"unsafeMerging", [], import("../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
958
962
  name: string;
959
963
  };
964
+ 'no-unsafe-enum-assignment': import("@typescript-eslint/utils/ts-eslint").RuleModule<"unsafeEnumAccess" | "unsafeEnumArgument" | "unsafeEnumAssertion" | "unsafeEnumAssignment" | "unsafeEnumMutation" | "unsafeEnumReturn", [], import("../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
965
+ name: string;
966
+ };
960
967
  'no-unsafe-enum-comparison': import("@typescript-eslint/utils/ts-eslint").RuleModule<"mismatchedCase" | "mismatchedCondition" | "replaceValueWithEnum", [], import("../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
961
968
  name: string;
962
969
  };
@@ -994,7 +1001,7 @@ declare const _default: {
994
1001
  'no-useless-constructor': import("@typescript-eslint/utils/ts-eslint").RuleModule<"noUselessConstructor" | "removeConstructor", [], import("../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
995
1002
  name: string;
996
1003
  };
997
- 'no-useless-default-assignment': import("@typescript-eslint/utils/ts-eslint").RuleModule<"noStrictNullCheck" | "preferOptionalSyntax" | "uselessDefaultAssignment" | "uselessUndefined", [{
1004
+ 'no-useless-default-assignment': import("@typescript-eslint/utils/ts-eslint").RuleModule<"noStrictNullCheck" | "preferOptionalSyntax" | "removeDefaultAssignment" | "useOptionalSyntax" | "uselessDefaultAssignment" | "uselessUndefined", [{
998
1005
  allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing?: boolean;
999
1006
  }], import("../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
1000
1007
  name: string;
@@ -116,6 +116,7 @@ declare const _default: {
116
116
  '@typescript-eslint/no-unsafe-assignment': "error";
117
117
  '@typescript-eslint/no-unsafe-call': "error";
118
118
  '@typescript-eslint/no-unsafe-declaration-merging': "error";
119
+ '@typescript-eslint/no-unsafe-enum-assignment': "error";
119
120
  '@typescript-eslint/no-unsafe-enum-comparison': "error";
120
121
  '@typescript-eslint/no-unsafe-function-type': "error";
121
122
  '@typescript-eslint/no-unsafe-member-access': "error";
@@ -221,6 +222,7 @@ declare const _default: {
221
222
  '@typescript-eslint/no-unsafe-argument': "off";
222
223
  '@typescript-eslint/no-unsafe-assignment': "off";
223
224
  '@typescript-eslint/no-unsafe-call': "off";
225
+ '@typescript-eslint/no-unsafe-enum-assignment': "off";
224
226
  '@typescript-eslint/no-unsafe-enum-comparison': "off";
225
227
  '@typescript-eslint/no-unsafe-member-access': "off";
226
228
  '@typescript-eslint/no-unsafe-return': "off";
@@ -521,6 +523,7 @@ declare const _default: {
521
523
  '@typescript-eslint/no-unsafe-assignment': "error";
522
524
  '@typescript-eslint/no-unsafe-call': "error";
523
525
  '@typescript-eslint/no-unsafe-declaration-merging': "error";
526
+ '@typescript-eslint/no-unsafe-enum-assignment': "error";
524
527
  '@typescript-eslint/no-unsafe-enum-comparison': "error";
525
528
  '@typescript-eslint/no-unsafe-function-type': "error";
526
529
  '@typescript-eslint/no-unsafe-member-access': "error";
@@ -598,6 +601,7 @@ declare const _default: {
598
601
  '@typescript-eslint/no-unsafe-argument': "error";
599
602
  '@typescript-eslint/no-unsafe-assignment': "error";
600
603
  '@typescript-eslint/no-unsafe-call': "error";
604
+ '@typescript-eslint/no-unsafe-enum-assignment': "error";
601
605
  '@typescript-eslint/no-unsafe-enum-comparison': "error";
602
606
  '@typescript-eslint/no-unsafe-member-access': "error";
603
607
  '@typescript-eslint/no-unsafe-return': "error";
@@ -980,6 +984,9 @@ declare const _default: {
980
984
  'no-unsafe-declaration-merging': TSESLint.RuleModule<"unsafeMerging", [], import("../rules").ESLintPluginDocs, TSESLint.RuleListener> & {
981
985
  name: string;
982
986
  };
987
+ 'no-unsafe-enum-assignment': TSESLint.RuleModule<"unsafeEnumAccess" | "unsafeEnumArgument" | "unsafeEnumAssertion" | "unsafeEnumAssignment" | "unsafeEnumMutation" | "unsafeEnumReturn", [], import("../rules").ESLintPluginDocs, TSESLint.RuleListener> & {
988
+ name: string;
989
+ };
983
990
  'no-unsafe-enum-comparison': TSESLint.RuleModule<"mismatchedCase" | "mismatchedCondition" | "replaceValueWithEnum", [], import("../rules").ESLintPluginDocs, TSESLint.RuleListener> & {
984
991
  name: string;
985
992
  };
@@ -1017,7 +1024,7 @@ declare const _default: {
1017
1024
  'no-useless-constructor': TSESLint.RuleModule<"noUselessConstructor" | "removeConstructor", [], import("../rules").ESLintPluginDocs, TSESLint.RuleListener> & {
1018
1025
  name: string;
1019
1026
  };
1020
- 'no-useless-default-assignment': TSESLint.RuleModule<"noStrictNullCheck" | "preferOptionalSyntax" | "uselessDefaultAssignment" | "uselessUndefined", [{
1027
+ 'no-useless-default-assignment': TSESLint.RuleModule<"noStrictNullCheck" | "preferOptionalSyntax" | "removeDefaultAssignment" | "useOptionalSyntax" | "uselessDefaultAssignment" | "uselessUndefined", [{
1021
1028
  allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing?: boolean;
1022
1029
  }], import("../rules").ESLintPluginDocs, TSESLint.RuleListener> & {
1023
1030
  name: string;
@@ -77,7 +77,18 @@ exports.default = (0, util_1.createRule)({
77
77
  messageId: 'removeAwait',
78
78
  fix(fixer) {
79
79
  const awaitKeyword = (0, util_1.nullThrows)(context.sourceCode.getFirstToken(node, util_1.isAwaitKeyword), util_1.NullThrowsReasons.MissingToken('await', 'await expression'));
80
- return fixer.remove(awaitKeyword);
80
+ const awaitTokenRemovalRange = (0, util_1.getAwaitTokenRemovalRange)(context.sourceCode, awaitKeyword);
81
+ const awaitRemovalFix = fixer.removeRange(awaitTokenRemovalRange);
82
+ const firstOperandToken = (0, util_1.nullThrows)(context.sourceCode.getTokenAfter(awaitKeyword), util_1.NullThrowsReasons.MissingToken('operand', 'await expression'));
83
+ if ((0, util_1.isStartOfArrowFunctionBodyNeedingParentheses)(node, firstOperandToken, context.sourceCode) ||
84
+ (0, util_1.isStartOfExpressionStatementNeedingParentheses)(node, firstOperandToken)) {
85
+ return [
86
+ awaitRemovalFix,
87
+ fixer.insertTextBefore(awaitArgumentEsNode, '('),
88
+ fixer.insertTextAfter(awaitArgumentEsNode, ')'),
89
+ ];
90
+ }
91
+ return awaitRemovalFix;
81
92
  },
82
93
  },
83
94
  ],
@@ -135,7 +146,7 @@ exports.default = (0, util_1.createRule)({
135
146
  messageId: 'convertToOrdinaryFor',
136
147
  fix(fixer) {
137
148
  const awaitToken = (0, util_1.nullThrows)(context.sourceCode.getFirstToken(node, util_1.isAwaitKeyword), util_1.NullThrowsReasons.MissingToken('await', 'for await loop'));
138
- return fixer.remove(awaitToken);
149
+ return fixer.removeRange((0, util_1.getAwaitTokenRemovalRange)(context.sourceCode, awaitToken));
139
150
  },
140
151
  },
141
152
  ],
@@ -168,7 +179,7 @@ exports.default = (0, util_1.createRule)({
168
179
  messageId: 'removeAwait',
169
180
  fix(fixer) {
170
181
  const awaitToken = (0, util_1.nullThrows)(context.sourceCode.getFirstToken(node, util_1.isAwaitKeyword), util_1.NullThrowsReasons.MissingToken('await', 'await using'));
171
- return fixer.remove(awaitToken);
182
+ return fixer.removeRange((0, util_1.getAwaitTokenRemovalRange)(context.sourceCode, awaitToken));
172
183
  },
173
184
  },
174
185
  }),
@@ -24,6 +24,10 @@ export declare function getEnumTypes(typeChecker: ts.TypeChecker, type: ts.Type)
24
24
  * compared against a non-enum value of the same primitive kind.
25
25
  */
26
26
  export declare function isMismatchedEnumComparisonTypes(typeChecker: ts.TypeChecker, leftType: ts.Type, rightType: ts.Type): boolean;
27
+ /**
28
+ * @returns What type a type's enum value is (number or string), if either.
29
+ */
30
+ export declare function getEnumValueType(type: ts.Type): ts.TypeFlags | undefined;
27
31
  /**
28
32
  * Returns the enum key that matches the given literal node, or null if none
29
33
  * match. For example:
@@ -36,6 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.getEnumLiterals = getEnumLiterals;
37
37
  exports.getEnumTypes = getEnumTypes;
38
38
  exports.isMismatchedEnumComparisonTypes = isMismatchedEnumComparisonTypes;
39
+ exports.getEnumValueType = getEnumValueType;
39
40
  exports.getEnumKeyForLiteral = getEnumKeyForLiteral;
40
41
  const tsutils = __importStar(require("ts-api-utils"));
41
42
  const ts = __importStar(require("typescript"));
@@ -278,6 +278,9 @@ declare const rules: {
278
278
  'no-unsafe-declaration-merging': import("@typescript-eslint/utils/ts-eslint").RuleModule<"unsafeMerging", [], import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
279
279
  name: string;
280
280
  };
281
+ 'no-unsafe-enum-assignment': import("@typescript-eslint/utils/ts-eslint").RuleModule<"unsafeEnumAccess" | "unsafeEnumArgument" | "unsafeEnumAssertion" | "unsafeEnumAssignment" | "unsafeEnumMutation" | "unsafeEnumReturn", [], import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
282
+ name: string;
283
+ };
281
284
  'no-unsafe-enum-comparison': import("@typescript-eslint/utils/ts-eslint").RuleModule<"mismatchedCase" | "mismatchedCondition" | "replaceValueWithEnum", [], import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
282
285
  name: string;
283
286
  };
@@ -315,7 +318,7 @@ declare const rules: {
315
318
  'no-useless-constructor': import("@typescript-eslint/utils/ts-eslint").RuleModule<"noUselessConstructor" | "removeConstructor", [], import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
316
319
  name: string;
317
320
  };
318
- 'no-useless-default-assignment': import("@typescript-eslint/utils/ts-eslint").RuleModule<"noStrictNullCheck" | "preferOptionalSyntax" | "uselessDefaultAssignment" | "uselessUndefined", [{
321
+ 'no-useless-default-assignment': import("@typescript-eslint/utils/ts-eslint").RuleModule<"noStrictNullCheck" | "preferOptionalSyntax" | "removeDefaultAssignment" | "useOptionalSyntax" | "uselessDefaultAssignment" | "uselessUndefined", [{
319
322
  allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing?: boolean;
320
323
  }], import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
321
324
  name: string;
@@ -84,6 +84,7 @@ const no_unsafe_argument_1 = __importDefault(require("./no-unsafe-argument"));
84
84
  const no_unsafe_assignment_1 = __importDefault(require("./no-unsafe-assignment"));
85
85
  const no_unsafe_call_1 = __importDefault(require("./no-unsafe-call"));
86
86
  const no_unsafe_declaration_merging_1 = __importDefault(require("./no-unsafe-declaration-merging"));
87
+ const no_unsafe_enum_assignment_1 = __importDefault(require("./no-unsafe-enum-assignment"));
87
88
  const no_unsafe_enum_comparison_1 = __importDefault(require("./no-unsafe-enum-comparison"));
88
89
  const no_unsafe_function_type_1 = __importDefault(require("./no-unsafe-function-type"));
89
90
  const no_unsafe_member_access_1 = __importDefault(require("./no-unsafe-member-access"));
@@ -220,6 +221,7 @@ const rules = {
220
221
  'no-unsafe-assignment': no_unsafe_assignment_1.default,
221
222
  'no-unsafe-call': no_unsafe_call_1.default,
222
223
  'no-unsafe-declaration-merging': no_unsafe_declaration_merging_1.default,
224
+ 'no-unsafe-enum-assignment': no_unsafe_enum_assignment_1.default,
223
225
  'no-unsafe-enum-comparison': no_unsafe_enum_comparison_1.default,
224
226
  'no-unsafe-function-type': no_unsafe_function_type_1.default,
225
227
  'no-unsafe-member-access': no_unsafe_member_access_1.default,
@@ -155,6 +155,14 @@ exports.default = (0, util_1.createRule)({
155
155
  return fixer.replaceText(node.parent, 'PropertyKey');
156
156
  };
157
157
  }
158
+ function createUnknownFixer(node) {
159
+ return (fixer) => {
160
+ return fixer.replaceText(node, node.parent.type === utils_1.AST_NODE_TYPES.TSTypeAnnotation &&
161
+ isNodeRestElementInFunction(node.parent.parent)
162
+ ? 'unknown[]'
163
+ : 'unknown');
164
+ };
165
+ }
158
166
  return {
159
167
  TSAnyKeyword(node) {
160
168
  const isKeyofAny = isNodeWithinKeyofAny(node);
@@ -173,7 +181,7 @@ exports.default = (0, util_1.createRule)({
173
181
  : [
174
182
  {
175
183
  messageId: 'suggestUnknown',
176
- fix: fixer => fixer.replaceText(node, 'unknown'),
184
+ fix: createUnknownFixer(node),
177
185
  },
178
186
  {
179
187
  messageId: 'suggestNever',
@@ -184,7 +192,7 @@ exports.default = (0, util_1.createRule)({
184
192
  if (fixToUnknown) {
185
193
  fixOrSuggest.fix = isKeyofAny
186
194
  ? createPropertyKeyFixer(node)
187
- : fixer => fixer.replaceText(node, 'unknown');
195
+ : createUnknownFixer(node);
188
196
  }
189
197
  context.report({
190
198
  node,
@@ -63,8 +63,12 @@ exports.default = (0, util_1.createRule)({
63
63
  type.getCallSignatures().length === 0 &&
64
64
  type.getConstructSignatures().length === 0 &&
65
65
  // Types still awaiting type arguments, such as `Record<T, unknown>`
66
- // inside a generic declaration, also have no members yet.
67
- checker.isTypeAssignableTo(checker.getNumberType(), type));
66
+ // inside a generic declaration, also have no members yet. Every
67
+ // primitive is assignable to `{}`, so probing with more than one of
68
+ // them rules those out: a mapped type whose keys are not resolved yet,
69
+ // such as `{ [K in Keys<T>]: K }`, accepts `number` but not `string`.
70
+ checker.isTypeAssignableTo(checker.getNumberType(), type) &&
71
+ checker.isTypeAssignableTo(checker.getStringType(), type));
68
72
  }
69
73
  function containsEmptyObjectType(type) {
70
74
  return (isEmptyObjectType(type) ||
@@ -84,6 +84,11 @@ exports.default = (0, util_1.createRule)({
84
84
  if (inner.type === utils_1.AST_NODE_TYPES.Literal && inner.value === 0) {
85
85
  return;
86
86
  }
87
+ // `void (x = value)` discards the assignment result so the
88
+ // expression evaluates to undefined (e.g. `() => void (x = 1)`).
89
+ if (inner.type === utils_1.AST_NODE_TYPES.AssignmentExpression) {
90
+ return;
91
+ }
87
92
  const tsArgument = services.esTreeNodeToTSNodeMap.get(node.argument);
88
93
  const argType = services.getTypeAtLocation(node.argument);
89
94
  // Allow `void promiseValue` so this rule does not fight no-floating-promises.
@@ -509,8 +509,13 @@ exports.default = (0, util_1.createRule)({
509
509
  while (current && !(0, util_1.isFunction)(current)) {
510
510
  current = current.parent;
511
511
  }
512
- return (0, util_1.nullThrows)(current, util_1.NullThrowsReasons.MissingParent);
512
+ return current;
513
513
  })();
514
+ // A `return` with no enclosing function is legal in a CommonJS module, and
515
+ // there is no function signature for the returned value to be misused against.
516
+ if (!functionNode) {
517
+ return;
518
+ }
514
519
  if (functionNode.returnType &&
515
520
  !isPossiblyFunctionType(functionNode.returnType)) {
516
521
  return;
@@ -841,19 +846,23 @@ function hasWellKnownSymbolWithVoidReturn(checker, node, type, symbolName) {
841
846
  function hasMatchingPromiseTypeArgument(checker, node) {
842
847
  const type = checker.getTypeAtLocation(node);
843
848
  const unionConstituents = tsutils.unionConstituents(checker.getApparentType(type));
844
- const promiseType = unionConstituents.find(type => tsutils.isThenableType(checker, node, type));
845
- if (!promiseType) {
849
+ const promiseTypes = unionConstituents.filter(type => tsutils.isThenableType(checker, node, type));
850
+ if (promiseTypes.length === 0) {
846
851
  return false;
847
852
  }
848
- const nonPromiseUnionConstituents = unionConstituents.filter(type => type !== promiseType);
849
- const awaitedType = checker.getAwaitedType(promiseType);
850
- if (!awaitedType) {
851
- return false;
853
+ const nonPromiseUnionConstituents = unionConstituents.filter(type => !promiseTypes.includes(type));
854
+ const awaitedTypeConstituents = [];
855
+ for (const promiseType of promiseTypes) {
856
+ const awaitedType = checker.getAwaitedType(promiseType);
857
+ if (!awaitedType) {
858
+ return false;
859
+ }
860
+ awaitedTypeConstituents.push(...tsutils.unionConstituents(awaitedType));
852
861
  }
853
- const awaitedTypeConstituents = tsutils.unionConstituents(awaitedType);
854
- return (nonPromiseUnionConstituents.length === awaitedTypeConstituents.length &&
855
- nonPromiseUnionConstituents.every(type => awaitedTypeConstituents.some(awaited => checker.isTypeAssignableTo(type, awaited) &&
856
- checker.isTypeAssignableTo(awaited, type))));
862
+ const typesAreEquivalent = (left, right) => checker.isTypeAssignableTo(left, right) &&
863
+ checker.isTypeAssignableTo(right, left);
864
+ return (nonPromiseUnionConstituents.every(type => awaitedTypeConstituents.some(awaited => typesAreEquivalent(type, awaited))) &&
865
+ awaitedTypeConstituents.every(awaited => nonPromiseUnionConstituents.some(type => typesAreEquivalent(type, awaited))));
857
866
  }
858
867
  function normalizeFlagUnionsOption(checksConditionals) {
859
868
  if (!checksConditionals || checksConditionals === true) {
@@ -98,7 +98,7 @@ exports.default = (0, util_1.createRule)({
98
98
  }
99
99
  function getMapSpreadSuggestions(node, type) {
100
100
  const types = tsutils.unionConstituents(type);
101
- if (types.some(t => !isMap(services.program, t))) {
101
+ if (types.some(t => !isIterableMap(services.program, t))) {
102
102
  return null;
103
103
  }
104
104
  if (node.parent.type === utils_1.AST_NODE_TYPES.ObjectExpression &&
@@ -252,6 +252,9 @@ function isClassDeclaration(type) {
252
252
  function isMap(program, type) {
253
253
  return isTypeRecurser(type, t => (0, util_1.isBuiltinSymbolLike)(program, t, ['Map', 'ReadonlyMap', 'WeakMap']));
254
254
  }
255
+ function isIterableMap(program, type) {
256
+ return isTypeRecurser(type, t => (0, util_1.isBuiltinSymbolLike)(program, t, ['Map', 'ReadonlyMap']));
257
+ }
255
258
  function isTypeRecurser(type, predicate) {
256
259
  if (type.isUnionOrIntersection()) {
257
260
  return type.types.some(t => isTypeRecurser(t, predicate));
@@ -308,7 +308,9 @@ exports.default = (0, util_1.createRule)({
308
308
  messageId: 'primitiveOverridden',
309
309
  data: {
310
310
  literal: typeValues.map(name => name.typeName).join(' | '),
311
- primitive: primitiveTypeFlagNames[primitive],
311
+ primitive: primitiveTypeFlagNames[
312
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-assignment
313
+ primitive],
312
314
  },
313
315
  });
314
316
  }
@@ -41,6 +41,7 @@ const assertionFunctionUtils_1 = require("../util/assertionFunctionUtils");
41
41
  // #region
42
42
  const nullishFlag = ts.TypeFlags.Undefined | ts.TypeFlags.Null;
43
43
  function isNullishType(type) {
44
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-assignment
44
45
  return tsutils.isTypeFlagSet(type, nullishFlag);
45
46
  }
46
47
  function isAlwaysNullish(type) {
@@ -55,6 +56,15 @@ function isPossiblyNullish(type) {
55
56
  .unionConstituents(type)
56
57
  .some(t => isNullishType(t) || (0, util_1.isTypeFlagSet)(t, ts.TypeFlags.Void));
57
58
  }
59
+ /**
60
+ * Note that this differs from {@link isNullableType} in that it doesn't consider
61
+ * `any` or `unknown` to be nullable.
62
+ */
63
+ function isPossiblyNonNullish(type) {
64
+ return tsutils
65
+ .unionConstituents(type)
66
+ .some(t => !isNullishType(t) && !(0, util_1.isTypeFlagSet)(t, ts.TypeFlags.Void));
67
+ }
58
68
  function toStaticValue(type) {
59
69
  // type.isLiteral() only covers numbers/bigints and strings, hence the rest of the branches.
60
70
  if (tsutils.isBooleanLiteralType(type)) {
@@ -262,11 +272,48 @@ exports.default = (0, util_1.createRule)({
262
272
  const propertyType = objectType
263
273
  .getProperties()
264
274
  .find(prop => prop.name === propertyName);
265
- if (propertyType &&
266
- tsutils.isSymbolFlagSet(propertyType, ts.SymbolFlags.Optional)) {
267
- return true;
275
+ return (propertyType != null &&
276
+ tsutils.isSymbolFlagSet(propertyType, ts.SymbolFlags.Optional));
277
+ }
278
+ /**
279
+ * Obtains the property types of the computed member expression
280
+ * @param node The member expression
281
+ * @returns The property types, unless the node isn't computed.
282
+ */
283
+ function getComputedMemberPropertyTypes(node) {
284
+ if (!node.computed) {
285
+ return undefined;
286
+ }
287
+ const objectType = (0, util_1.getConstrainedTypeAtLocation)(services, node.object);
288
+ const propertyType = (0, util_1.getConstrainedTypeAtLocation)(services, node.property);
289
+ const propertyTypes = [];
290
+ for (const keyType of tsutils.unionConstituents(propertyType)) {
291
+ if (!keyType.isStringLiteral() && !keyType.isNumberLiteral()) {
292
+ return undefined;
293
+ }
294
+ const selectedType = (0, util_1.getTypeOfPropertyOfName)(checker, objectType, String(keyType.value));
295
+ if (!selectedType) {
296
+ return undefined;
297
+ }
298
+ propertyTypes.push(selectedType);
268
299
  }
269
- return false;
300
+ return propertyTypes;
301
+ }
302
+ /**
303
+ * Verify if the node may have non-nullish properties
304
+ * @param node The node to verify
305
+ * @returns If it may have non-nullish properties, unless the node isn't a
306
+ * MemberExpression
307
+ */
308
+ function hasPossiblyNonNullishComputedMemberProperty(node) {
309
+ if (node.type !== utils_1.AST_NODE_TYPES.MemberExpression) {
310
+ return false;
311
+ }
312
+ const propertyTypes = getComputedMemberPropertyTypes(node);
313
+ if (propertyTypes == null) {
314
+ return false;
315
+ }
316
+ return propertyTypes.some(isPossiblyNonNullish);
270
317
  }
271
318
  /**
272
319
  * Checks if a conditional node is necessary:
@@ -344,7 +391,8 @@ exports.default = (0, util_1.createRule)({
344
391
  messageId = 'neverNullish';
345
392
  }
346
393
  }
347
- else if (isAlwaysNullish(type)) {
394
+ else if (isAlwaysNullish(type) &&
395
+ !hasPossiblyNonNullishComputedMemberProperty(node)) {
348
396
  messageId = 'alwaysNullish';
349
397
  }
350
398
  if (messageId) {
@@ -101,10 +101,6 @@ exports.default = (0, util_1.createRule)({
101
101
  });
102
102
  },
103
103
  "MethodDefinition[kind='constructor'] > FunctionExpression AssignmentExpression"(node) {
104
- const leftName = getPropertyName(node.left);
105
- if (!leftName) {
106
- return;
107
- }
108
104
  let functionNode = findParentFunction(node);
109
105
  if (functionNode && isArrowIIFE(functionNode)) {
110
106
  functionNode = findParentFunction(functionNode.parent);
@@ -113,6 +109,18 @@ exports.default = (0, util_1.createRule)({
113
109
  return;
114
110
  }
115
111
  const { assignedBeforeUnnecessary, unnecessaryAssignments } = (0, util_1.nullThrows)(reportInfoStack.at(reportInfoStack.length - 1), 'The top of stack should exist');
112
+ // A prior write to the parameter binding means a later `this.x = x`
113
+ // may copy a different value than the parameter property initialized.
114
+ if (node.left.type === utils_1.AST_NODE_TYPES.Identifier) {
115
+ if (isReferenceFromParameter(node.left)) {
116
+ assignedBeforeUnnecessary.add(node.left.name);
117
+ }
118
+ return;
119
+ }
120
+ const leftName = getPropertyName(node.left);
121
+ if (!leftName) {
122
+ return;
123
+ }
116
124
  if (!UNNECESSARY_OPERATORS.has(node.operator)) {
117
125
  assignedBeforeUnnecessary.add(leftName);
118
126
  return;
@@ -4,7 +4,7 @@ export type Options = [
4
4
  typesToIgnore?: string[];
5
5
  }
6
6
  ];
7
- export type MessageIds = 'contextuallyUnnecessary' | 'unnecessaryAssertion';
7
+ export type MessageIds = 'contextuallyInferredTypeArguments' | 'contextuallyUnnecessary' | 'unnecessaryAssertion';
8
8
  declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<MessageIds, Options, import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
9
9
  name: string;
10
10
  };