@depup/typescript-eslint__eslint-plugin 8.69.0-depup.0 → 8.70.1-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 (46) 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/index.d.ts +4 -1
  19. package/dist/rules/index.js +2 -0
  20. package/dist/rules/member-ordering.js +57 -1
  21. package/dist/rules/no-deprecated.js +1 -1
  22. package/dist/rules/no-explicit-any.js +10 -2
  23. package/dist/rules/no-generated-empty-object-type.d.ts +4 -0
  24. package/dist/rules/no-generated-empty-object-type.js +96 -0
  25. package/dist/rules/no-meaningless-void-operator.js +5 -0
  26. package/dist/rules/no-misused-promises.js +14 -10
  27. package/dist/rules/no-misused-spread.js +4 -1
  28. package/dist/rules/no-unnecessary-condition.js +80 -10
  29. package/dist/rules/no-unnecessary-parameter-property-assignment.js +12 -4
  30. package/dist/rules/no-unnecessary-type-assertion.js +3 -6
  31. package/dist/rules/no-unnecessary-type-parameters.js +16 -18
  32. package/dist/rules/no-useless-default-assignment.d.ts +1 -1
  33. package/dist/rules/no-useless-default-assignment.js +27 -7
  34. package/dist/rules/return-await.js +3 -13
  35. package/dist/rules/unbound-method.js +31 -0
  36. package/dist/util/getAwaitTokenRemovalRange.d.ts +4 -0
  37. package/dist/util/getAwaitTokenRemovalRange.js +15 -0
  38. package/dist/util/getWrappingFixer.js +0 -1
  39. package/dist/util/index.d.ts +3 -1
  40. package/dist/util/index.js +3 -1
  41. package/dist/util/isStartOfArrowFunctionBodyNeedingParentheses.d.ts +2 -0
  42. package/dist/util/{isStartOfArrowFunctionBody.js → isStartOfArrowFunctionBodyNeedingParentheses.js} +6 -2
  43. package/dist/util/isStartOfExpressionStatementNeedingParentheses.d.ts +2 -0
  44. package/dist/util/isStartOfExpressionStatementNeedingParentheses.js +9 -0
  45. package/package.json +18 -18
  46. 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.69.0 |
17
- | Processed | 2026-09-01 |
16
+ | Original | [@typescript-eslint/eslint-plugin](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin) @ 8.70.1 |
17
+ | Processed | 2026-09-22 |
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.9 |
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.9"
6
6
  }
7
7
  },
8
- "timestamp": "2026-09-01T00:39:42.146Z",
8
+ "timestamp": "2026-09-22T00:32:40.856Z",
9
9
  "totalUpdated": 1
10
10
  }
@@ -51,6 +51,7 @@ declare const _default: {
51
51
  '@typescript-eslint/no-extraneous-class': "error";
52
52
  '@typescript-eslint/no-floating-promises': "error";
53
53
  '@typescript-eslint/no-for-in-array': "error";
54
+ '@typescript-eslint/no-generated-empty-object-type': "error";
54
55
  'no-implied-eval': "off";
55
56
  '@typescript-eslint/no-implied-eval': "error";
56
57
  '@typescript-eslint/no-import-type-side-effects': "error";
@@ -58,6 +58,7 @@ module.exports = {
58
58
  '@typescript-eslint/no-extraneous-class': 'error',
59
59
  '@typescript-eslint/no-floating-promises': 'error',
60
60
  '@typescript-eslint/no-for-in-array': 'error',
61
+ '@typescript-eslint/no-generated-empty-object-type': 'error',
61
62
  'no-implied-eval': 'off',
62
63
  '@typescript-eslint/no-implied-eval': 'error',
63
64
  '@typescript-eslint/no-import-type-side-effects': 'error',
@@ -17,6 +17,7 @@ declare const _default: {
17
17
  '@typescript-eslint/no-duplicate-type-constituents': "off";
18
18
  '@typescript-eslint/no-floating-promises': "off";
19
19
  '@typescript-eslint/no-for-in-array': "off";
20
+ '@typescript-eslint/no-generated-empty-object-type': "off";
20
21
  '@typescript-eslint/no-implied-eval': "off";
21
22
  '@typescript-eslint/no-meaningless-void-operator': "off";
22
23
  '@typescript-eslint/no-misused-promises': "off";
@@ -20,6 +20,7 @@ module.exports = {
20
20
  '@typescript-eslint/no-duplicate-type-constituents': 'off',
21
21
  '@typescript-eslint/no-floating-promises': 'off',
22
22
  '@typescript-eslint/no-for-in-array': 'off',
23
+ '@typescript-eslint/no-generated-empty-object-type': 'off',
23
24
  '@typescript-eslint/no-implied-eval': 'off',
24
25
  '@typescript-eslint/no-meaningless-void-operator': 'off',
25
26
  '@typescript-eslint/no-misused-promises': 'off',
@@ -9,6 +9,7 @@ declare const _default: {
9
9
  '@typescript-eslint/no-duplicate-type-constituents': "error";
10
10
  '@typescript-eslint/no-floating-promises': "error";
11
11
  '@typescript-eslint/no-for-in-array': "error";
12
+ '@typescript-eslint/no-generated-empty-object-type': "error";
12
13
  'no-implied-eval': "off";
13
14
  '@typescript-eslint/no-implied-eval': "error";
14
15
  '@typescript-eslint/no-meaningless-void-operator': "error";
@@ -16,6 +16,7 @@ module.exports = {
16
16
  '@typescript-eslint/no-duplicate-type-constituents': 'error',
17
17
  '@typescript-eslint/no-floating-promises': 'error',
18
18
  '@typescript-eslint/no-for-in-array': 'error',
19
+ '@typescript-eslint/no-generated-empty-object-type': 'error',
19
20
  'no-implied-eval': 'off',
20
21
  '@typescript-eslint/no-implied-eval': 'error',
21
22
  '@typescript-eslint/no-meaningless-void-operator': 'error',
@@ -20,6 +20,7 @@ declare const _default: {
20
20
  '@typescript-eslint/no-extraneous-class': "error";
21
21
  '@typescript-eslint/no-floating-promises': "error";
22
22
  '@typescript-eslint/no-for-in-array': "error";
23
+ '@typescript-eslint/no-generated-empty-object-type': "error";
23
24
  'no-implied-eval': "off";
24
25
  '@typescript-eslint/no-implied-eval': "error";
25
26
  '@typescript-eslint/no-invalid-void-type': "error";
@@ -28,6 +28,7 @@ module.exports = {
28
28
  '@typescript-eslint/no-extraneous-class': 'error',
29
29
  '@typescript-eslint/no-floating-promises': 'error',
30
30
  '@typescript-eslint/no-for-in-array': 'error',
31
+ '@typescript-eslint/no-generated-empty-object-type': 'error',
31
32
  'no-implied-eval': 'off',
32
33
  '@typescript-eslint/no-implied-eval': 'error',
33
34
  '@typescript-eslint/no-invalid-void-type': 'error',
@@ -71,6 +71,7 @@ exports.default = (plugin, parser) => [
71
71
  '@typescript-eslint/no-extraneous-class': 'error',
72
72
  '@typescript-eslint/no-floating-promises': 'error',
73
73
  '@typescript-eslint/no-for-in-array': 'error',
74
+ '@typescript-eslint/no-generated-empty-object-type': 'error',
74
75
  'no-implied-eval': 'off',
75
76
  '@typescript-eslint/no-implied-eval': 'error',
76
77
  '@typescript-eslint/no-import-type-side-effects': 'error',
@@ -25,6 +25,7 @@ exports.default = (_plugin, _parser) => ({
25
25
  '@typescript-eslint/no-duplicate-type-constituents': 'off',
26
26
  '@typescript-eslint/no-floating-promises': 'off',
27
27
  '@typescript-eslint/no-for-in-array': 'off',
28
+ '@typescript-eslint/no-generated-empty-object-type': 'off',
28
29
  '@typescript-eslint/no-implied-eval': 'off',
29
30
  '@typescript-eslint/no-meaningless-void-operator': 'off',
30
31
  '@typescript-eslint/no-misused-promises': 'off',
@@ -29,6 +29,7 @@ exports.default = (plugin, parser) => [
29
29
  '@typescript-eslint/no-duplicate-type-constituents': 'error',
30
30
  '@typescript-eslint/no-floating-promises': 'error',
31
31
  '@typescript-eslint/no-for-in-array': 'error',
32
+ '@typescript-eslint/no-generated-empty-object-type': 'error',
32
33
  'no-implied-eval': 'off',
33
34
  '@typescript-eslint/no-implied-eval': 'error',
34
35
  '@typescript-eslint/no-meaningless-void-operator': 'error',
@@ -41,6 +41,7 @@ exports.default = (plugin, parser) => [
41
41
  '@typescript-eslint/no-extraneous-class': 'error',
42
42
  '@typescript-eslint/no-floating-promises': 'error',
43
43
  '@typescript-eslint/no-for-in-array': 'error',
44
+ '@typescript-eslint/no-generated-empty-object-type': 'error',
44
45
  'no-implied-eval': 'off',
45
46
  '@typescript-eslint/no-implied-eval': 'error',
46
47
  '@typescript-eslint/no-invalid-void-type': 'error',
package/dist/index.d.ts CHANGED
@@ -53,6 +53,7 @@ declare const _default: {
53
53
  '@typescript-eslint/no-extraneous-class': "error";
54
54
  '@typescript-eslint/no-floating-promises': "error";
55
55
  '@typescript-eslint/no-for-in-array': "error";
56
+ '@typescript-eslint/no-generated-empty-object-type': "error";
56
57
  'no-implied-eval': "off";
57
58
  '@typescript-eslint/no-implied-eval': "error";
58
59
  '@typescript-eslint/no-import-type-side-effects': "error";
@@ -180,6 +181,7 @@ declare const _default: {
180
181
  '@typescript-eslint/no-duplicate-type-constituents': "off";
181
182
  '@typescript-eslint/no-floating-promises': "off";
182
183
  '@typescript-eslint/no-for-in-array': "off";
184
+ '@typescript-eslint/no-generated-empty-object-type': "off";
183
185
  '@typescript-eslint/no-implied-eval': "off";
184
186
  '@typescript-eslint/no-meaningless-void-operator': "off";
185
187
  '@typescript-eslint/no-misused-promises': "off";
@@ -468,6 +470,7 @@ declare const _default: {
468
470
  '@typescript-eslint/no-extraneous-class': "error";
469
471
  '@typescript-eslint/no-floating-promises': "error";
470
472
  '@typescript-eslint/no-for-in-array': "error";
473
+ '@typescript-eslint/no-generated-empty-object-type': "error";
471
474
  'no-implied-eval': "off";
472
475
  '@typescript-eslint/no-implied-eval': "error";
473
476
  '@typescript-eslint/no-invalid-void-type': "error";
@@ -554,6 +557,7 @@ declare const _default: {
554
557
  '@typescript-eslint/no-duplicate-type-constituents': "error";
555
558
  '@typescript-eslint/no-floating-promises': "error";
556
559
  '@typescript-eslint/no-for-in-array': "error";
560
+ '@typescript-eslint/no-generated-empty-object-type': "error";
557
561
  'no-implied-eval': "off";
558
562
  '@typescript-eslint/no-implied-eval': "error";
559
563
  '@typescript-eslint/no-meaningless-void-operator': "error";
@@ -820,6 +824,9 @@ declare const _default: {
820
824
  'no-for-in-array': import("@typescript-eslint/utils/ts-eslint").RuleModule<"forInViolation", [], import("../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
821
825
  name: string;
822
826
  };
827
+ 'no-generated-empty-object-type': import("@typescript-eslint/utils/ts-eslint").RuleModule<"noGeneratedEmptyObjectType", [], import("../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
828
+ name: string;
829
+ };
823
830
  'no-implied-eval': import("@typescript-eslint/utils/ts-eslint").RuleModule<"noFunctionConstructor" | "noImpliedEvalError", [], import("../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
824
831
  name: string;
825
832
  };
@@ -987,7 +994,7 @@ declare const _default: {
987
994
  'no-useless-constructor': import("@typescript-eslint/utils/ts-eslint").RuleModule<"noUselessConstructor" | "removeConstructor", [], import("../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
988
995
  name: string;
989
996
  };
990
- 'no-useless-default-assignment': import("@typescript-eslint/utils/ts-eslint").RuleModule<"noStrictNullCheck" | "preferOptionalSyntax" | "uselessDefaultAssignment" | "uselessUndefined", [{
997
+ 'no-useless-default-assignment': import("@typescript-eslint/utils/ts-eslint").RuleModule<"noStrictNullCheck" | "preferOptionalSyntax" | "removeDefaultAssignment" | "useOptionalSyntax" | "uselessDefaultAssignment" | "uselessUndefined", [{
991
998
  allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing?: boolean;
992
999
  }], import("../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
993
1000
  name: string;
@@ -75,6 +75,7 @@ declare const _default: {
75
75
  '@typescript-eslint/no-extraneous-class': "error";
76
76
  '@typescript-eslint/no-floating-promises': "error";
77
77
  '@typescript-eslint/no-for-in-array': "error";
78
+ '@typescript-eslint/no-generated-empty-object-type': "error";
78
79
  'no-implied-eval': "off";
79
80
  '@typescript-eslint/no-implied-eval': "error";
80
81
  '@typescript-eslint/no-import-type-side-effects': "error";
@@ -202,6 +203,7 @@ declare const _default: {
202
203
  '@typescript-eslint/no-duplicate-type-constituents': "off";
203
204
  '@typescript-eslint/no-floating-promises': "off";
204
205
  '@typescript-eslint/no-for-in-array': "off";
206
+ '@typescript-eslint/no-generated-empty-object-type': "off";
205
207
  '@typescript-eslint/no-implied-eval': "off";
206
208
  '@typescript-eslint/no-meaningless-void-operator': "off";
207
209
  '@typescript-eslint/no-misused-promises': "off";
@@ -491,6 +493,7 @@ declare const _default: {
491
493
  '@typescript-eslint/no-extraneous-class': "error";
492
494
  '@typescript-eslint/no-floating-promises': "error";
493
495
  '@typescript-eslint/no-for-in-array': "error";
496
+ '@typescript-eslint/no-generated-empty-object-type': "error";
494
497
  'no-implied-eval': "off";
495
498
  '@typescript-eslint/no-implied-eval': "error";
496
499
  '@typescript-eslint/no-invalid-void-type': "error";
@@ -577,6 +580,7 @@ declare const _default: {
577
580
  '@typescript-eslint/no-duplicate-type-constituents': "error";
578
581
  '@typescript-eslint/no-floating-promises': "error";
579
582
  '@typescript-eslint/no-for-in-array': "error";
583
+ '@typescript-eslint/no-generated-empty-object-type': "error";
580
584
  'no-implied-eval': "off";
581
585
  '@typescript-eslint/no-implied-eval': "error";
582
586
  '@typescript-eslint/no-meaningless-void-operator': "error";
@@ -843,6 +847,9 @@ declare const _default: {
843
847
  'no-for-in-array': TSESLint.RuleModule<"forInViolation", [], import("../rules").ESLintPluginDocs, TSESLint.RuleListener> & {
844
848
  name: string;
845
849
  };
850
+ 'no-generated-empty-object-type': TSESLint.RuleModule<"noGeneratedEmptyObjectType", [], import("../rules").ESLintPluginDocs, TSESLint.RuleListener> & {
851
+ name: string;
852
+ };
846
853
  'no-implied-eval': TSESLint.RuleModule<"noFunctionConstructor" | "noImpliedEvalError", [], import("../rules").ESLintPluginDocs, TSESLint.RuleListener> & {
847
854
  name: string;
848
855
  };
@@ -1010,7 +1017,7 @@ declare const _default: {
1010
1017
  'no-useless-constructor': TSESLint.RuleModule<"noUselessConstructor" | "removeConstructor", [], import("../rules").ESLintPluginDocs, TSESLint.RuleListener> & {
1011
1018
  name: string;
1012
1019
  };
1013
- 'no-useless-default-assignment': TSESLint.RuleModule<"noStrictNullCheck" | "preferOptionalSyntax" | "uselessDefaultAssignment" | "uselessUndefined", [{
1020
+ 'no-useless-default-assignment': TSESLint.RuleModule<"noStrictNullCheck" | "preferOptionalSyntax" | "removeDefaultAssignment" | "useOptionalSyntax" | "uselessDefaultAssignment" | "uselessUndefined", [{
1014
1021
  allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing?: boolean;
1015
1022
  }], import("../rules").ESLintPluginDocs, TSESLint.RuleListener> & {
1016
1023
  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
  }),
@@ -145,6 +145,9 @@ declare const rules: {
145
145
  'no-for-in-array': import("@typescript-eslint/utils/ts-eslint").RuleModule<"forInViolation", [], import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
146
146
  name: string;
147
147
  };
148
+ 'no-generated-empty-object-type': import("@typescript-eslint/utils/ts-eslint").RuleModule<"noGeneratedEmptyObjectType", [], import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
149
+ name: string;
150
+ };
148
151
  'no-implied-eval': import("@typescript-eslint/utils/ts-eslint").RuleModule<"noFunctionConstructor" | "noImpliedEvalError", [], import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
149
152
  name: string;
150
153
  };
@@ -312,7 +315,7 @@ declare const rules: {
312
315
  'no-useless-constructor': import("@typescript-eslint/utils/ts-eslint").RuleModule<"noUselessConstructor" | "removeConstructor", [], import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
313
316
  name: string;
314
317
  };
315
- 'no-useless-default-assignment': import("@typescript-eslint/utils/ts-eslint").RuleModule<"noStrictNullCheck" | "preferOptionalSyntax" | "uselessDefaultAssignment" | "uselessUndefined", [{
318
+ 'no-useless-default-assignment': import("@typescript-eslint/utils/ts-eslint").RuleModule<"noStrictNullCheck" | "preferOptionalSyntax" | "removeDefaultAssignment" | "useOptionalSyntax" | "uselessDefaultAssignment" | "uselessUndefined", [{
316
319
  allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing?: boolean;
317
320
  }], import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
318
321
  name: string;
@@ -44,6 +44,7 @@ const no_extra_non_null_assertion_1 = __importDefault(require("./no-extra-non-nu
44
44
  const no_extraneous_class_1 = __importDefault(require("./no-extraneous-class"));
45
45
  const no_floating_promises_1 = __importDefault(require("./no-floating-promises"));
46
46
  const no_for_in_array_1 = __importDefault(require("./no-for-in-array"));
47
+ const no_generated_empty_object_type_1 = __importDefault(require("./no-generated-empty-object-type"));
47
48
  const no_implied_eval_1 = __importDefault(require("./no-implied-eval"));
48
49
  const no_import_type_side_effects_1 = __importDefault(require("./no-import-type-side-effects"));
49
50
  const no_inferrable_types_1 = __importDefault(require("./no-inferrable-types"));
@@ -179,6 +180,7 @@ const rules = {
179
180
  'no-extraneous-class': no_extraneous_class_1.default,
180
181
  'no-floating-promises': no_floating_promises_1.default,
181
182
  'no-for-in-array': no_for_in_array_1.default,
183
+ 'no-generated-empty-object-type': no_generated_empty_object_type_1.default,
182
184
  'no-implied-eval': no_implied_eval_1.default,
183
185
  'no-import-type-side-effects': no_import_type_side_effects_1.default,
184
186
  'no-inferrable-types': no_inferrable_types_1.default,
@@ -330,6 +330,57 @@ function isMemberOptional(node) {
330
330
  }
331
331
  return false;
332
332
  }
333
+ function getMemberInitializer(node) {
334
+ switch (node.type) {
335
+ case utils_1.AST_NODE_TYPES.AccessorProperty:
336
+ case utils_1.AST_NODE_TYPES.PropertyDefinition:
337
+ return node.value;
338
+ }
339
+ return undefined;
340
+ }
341
+ function getThisPropertyName(node) {
342
+ return node.computed
343
+ ? (0, util_1.getStaticStringValue)(node.property)
344
+ : node.property.name;
345
+ }
346
+ function isEvaluatedLater(node, initializer) {
347
+ for (let current = node; current !== initializer.parent; current = (0, util_1.nullThrows)(current.parent, util_1.NullThrowsReasons.MissingParent)) {
348
+ if (current.type === utils_1.AST_NODE_TYPES.ArrowFunctionExpression ||
349
+ current.type === utils_1.AST_NODE_TYPES.ClassBody ||
350
+ current.type === utils_1.AST_NODE_TYPES.FunctionExpression) {
351
+ return true;
352
+ }
353
+ }
354
+ return false;
355
+ }
356
+ function collectImmediateThisPropertyNames(initializer) {
357
+ const names = new Set();
358
+ (0, util_1.forEachChildESTree)(initializer, node => {
359
+ if (node.type === utils_1.AST_NODE_TYPES.MemberExpression &&
360
+ node.object.type === utils_1.AST_NODE_TYPES.ThisExpression &&
361
+ !isEvaluatedLater(node, initializer)) {
362
+ const name = getThisPropertyName(node);
363
+ if (name != null) {
364
+ names.add(name);
365
+ }
366
+ }
367
+ return null;
368
+ });
369
+ return names;
370
+ }
371
+ function isBlockedByEarlierMemberReferences(member, members, fromIndex, toIndex, sourceCode) {
372
+ const initializer = getMemberInitializer(member);
373
+ if (!initializer) {
374
+ return false;
375
+ }
376
+ const referencedNames = collectImmediateThisPropertyNames(initializer);
377
+ return members.slice(fromIndex, toIndex).some(other => {
378
+ const otherName = getMemberName(other, sourceCode);
379
+ return (otherName != null &&
380
+ getMemberInitializer(other) != null &&
381
+ referencedNames.has(otherName));
382
+ });
383
+ }
333
384
  /**
334
385
  * Gets the calculated rank using the provided method definition.
335
386
  * The algorithm is as follows:
@@ -664,13 +715,17 @@ exports.default = (0, util_1.createRule)({
664
715
  */
665
716
  function checkAlphaSort(members, order) {
666
717
  let previousName = '';
718
+ let previousIndex = 0;
667
719
  let isCorrectlySorted = true;
668
720
  // Find first member which isn't correctly sorted
669
- members.forEach(member => {
721
+ members.forEach((member, index) => {
670
722
  const name = getMemberName(member, context.sourceCode);
671
723
  // Note: Not all members have names
672
724
  if (name) {
673
725
  if (naturalOutOfOrder(name, previousName, order)) {
726
+ if (isBlockedByEarlierMemberReferences(member, members, previousIndex, index, context.sourceCode)) {
727
+ return;
728
+ }
674
729
  context.report({
675
730
  node: member,
676
731
  messageId: 'incorrectOrder',
@@ -682,6 +737,7 @@ exports.default = (0, util_1.createRule)({
682
737
  isCorrectlySorted = false;
683
738
  }
684
739
  previousName = name;
740
+ previousIndex = index;
685
741
  }
686
742
  });
687
743
  return isCorrectlySorted;
@@ -291,7 +291,7 @@ exports.default = (0, util_1.createRule)({
291
291
  return (searchForDeprecationInAliasesChain(propertySymbol, true) ??
292
292
  getJsDocDeprecation(property) ??
293
293
  getJsDocDeprecation(propertySymbol) ??
294
- getJsDocDeprecation(valueSymbol));
294
+ searchForDeprecationInAliasesChain(valueSymbol, true));
295
295
  }
296
296
  return searchForDeprecationInAliasesChain(services.getSymbolAtLocation(node), true);
297
297
  }
@@ -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,
@@ -0,0 +1,4 @@
1
+ declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<"noGeneratedEmptyObjectType", [], import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
2
+ name: string;
3
+ };
4
+ export default _default;
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ const utils_1 = require("@typescript-eslint/utils");
37
+ const tsutils = __importStar(require("ts-api-utils"));
38
+ const ts = __importStar(require("typescript"));
39
+ const util_1 = require("../util");
40
+ exports.default = (0, util_1.createRule)({
41
+ name: 'no-generated-empty-object-type',
42
+ meta: {
43
+ type: 'problem',
44
+ docs: {
45
+ description: 'Disallow type operations that resolve to the "empty object" type',
46
+ recommended: 'strict',
47
+ requiresTypeChecking: true,
48
+ },
49
+ messages: {
50
+ noGeneratedEmptyObjectType: 'This type resolves to `{}`, the empty object type. This was likely not intentional.',
51
+ },
52
+ schema: [],
53
+ },
54
+ defaultOptions: [],
55
+ create(context) {
56
+ const services = (0, util_1.getParserServices)(context);
57
+ const checker = services.program.getTypeChecker();
58
+ function isEmptyObjectType(type) {
59
+ return (tsutils.isObjectType(type) &&
60
+ !tsutils.isObjectFlagSet(type, ts.ObjectFlags.Class | ts.ObjectFlags.Interface) &&
61
+ checker.getPropertiesOfType(type).length === 0 &&
62
+ checker.getIndexInfosOfType(type).length === 0 &&
63
+ type.getCallSignatures().length === 0 &&
64
+ type.getConstructSignatures().length === 0 &&
65
+ // Types still awaiting type arguments, such as `Record<T, unknown>`
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));
72
+ }
73
+ function containsEmptyObjectType(type) {
74
+ return (isEmptyObjectType(type) ||
75
+ (type.isUnion() && type.types.some(isEmptyObjectType)));
76
+ }
77
+ function checkNode(node) {
78
+ if (containsEmptyObjectType(services.getTypeAtLocation(node))) {
79
+ context.report({
80
+ node,
81
+ messageId: 'noGeneratedEmptyObjectType',
82
+ });
83
+ }
84
+ }
85
+ return {
86
+ TSIntersectionType: checkNode,
87
+ TSTypeReference(node) {
88
+ if (node.typeArguments &&
89
+ node.parent.type !== utils_1.AST_NODE_TYPES.TSIntersectionType) {
90
+ checkNode(node);
91
+ }
92
+ },
93
+ };
94
+ },
95
+ });
96
+ //# sourceMappingURL=no-generated-empty-object-type.js.map
@@ -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.
@@ -841,19 +841,23 @@ function hasWellKnownSymbolWithVoidReturn(checker, node, type, symbolName) {
841
841
  function hasMatchingPromiseTypeArgument(checker, node) {
842
842
  const type = checker.getTypeAtLocation(node);
843
843
  const unionConstituents = tsutils.unionConstituents(checker.getApparentType(type));
844
- const promiseType = unionConstituents.find(type => tsutils.isThenableType(checker, node, type));
845
- if (!promiseType) {
844
+ const promiseTypes = unionConstituents.filter(type => tsutils.isThenableType(checker, node, type));
845
+ if (promiseTypes.length === 0) {
846
846
  return false;
847
847
  }
848
- const nonPromiseUnionConstituents = unionConstituents.filter(type => type !== promiseType);
849
- const awaitedType = checker.getAwaitedType(promiseType);
850
- if (!awaitedType) {
851
- return false;
848
+ const nonPromiseUnionConstituents = unionConstituents.filter(type => !promiseTypes.includes(type));
849
+ const awaitedTypeConstituents = [];
850
+ for (const promiseType of promiseTypes) {
851
+ const awaitedType = checker.getAwaitedType(promiseType);
852
+ if (!awaitedType) {
853
+ return false;
854
+ }
855
+ awaitedTypeConstituents.push(...tsutils.unionConstituents(awaitedType));
852
856
  }
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))));
857
+ const typesAreEquivalent = (left, right) => checker.isTypeAssignableTo(left, right) &&
858
+ checker.isTypeAssignableTo(right, left);
859
+ return (nonPromiseUnionConstituents.every(type => awaitedTypeConstituents.some(awaited => typesAreEquivalent(type, awaited))) &&
860
+ awaitedTypeConstituents.every(awaited => nonPromiseUnionConstituents.some(type => typesAreEquivalent(type, awaited))));
857
861
  }
858
862
  function normalizeFlagUnionsOption(checksConditionals) {
859
863
  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));