@depup/typescript-eslint__eslint-plugin 8.58.1-depup.0 → 8.66.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 (61) hide show
  1. package/README.md +9 -3
  2. package/changes.json +8 -3
  3. package/dist/configs/eslintrc/all.d.ts +0 -4
  4. package/dist/configs/eslintrc/all.js +0 -4
  5. package/dist/configs/flat/all.js +0 -4
  6. package/dist/index.d.ts +5 -9
  7. package/dist/index.js +47 -0
  8. package/dist/raw-plugin.d.ts +5 -9
  9. package/dist/rules/ban-ts-comment.js +5 -5
  10. package/dist/rules/class-literal-property-style.js +11 -4
  11. package/dist/rules/consistent-indexed-object-style.d.ts +1 -1
  12. package/dist/rules/consistent-indexed-object-style.js +59 -30
  13. package/dist/rules/index.d.ts +5 -5
  14. package/dist/rules/method-signature-style.d.ts +1 -1
  15. package/dist/rules/method-signature-style.js +23 -10
  16. package/dist/rules/no-base-to-string.js +3 -3
  17. package/dist/rules/no-confusing-void-expression.js +5 -5
  18. package/dist/rules/no-deprecated.js +7 -5
  19. package/dist/rules/no-duplicate-type-constituents.js +14 -6
  20. package/dist/rules/no-empty-function.d.ts +2 -2
  21. package/dist/rules/no-floating-promises.js +13 -1
  22. package/dist/rules/no-loop-func.js +16 -2
  23. package/dist/rules/no-magic-numbers.js +14 -13
  24. package/dist/rules/no-misused-promises.js +41 -3
  25. package/dist/rules/no-non-null-asserted-optional-chain.d.ts +1 -1
  26. package/dist/rules/no-redundant-type-constituents.d.ts +1 -1
  27. package/dist/rules/no-restricted-imports.d.ts +2 -2
  28. package/dist/rules/no-restricted-imports.js +12 -0
  29. package/dist/rules/no-shadow.d.ts +1 -1
  30. package/dist/rules/no-shadow.js +51 -20
  31. package/dist/rules/no-this-alias.js +1 -1
  32. package/dist/rules/no-unnecessary-boolean-literal-compare.js +51 -29
  33. package/dist/rules/no-unnecessary-condition.js +16 -2
  34. package/dist/rules/no-unnecessary-parameter-property-assignment.js +1 -1
  35. package/dist/rules/no-unnecessary-template-expression.js +3 -3
  36. package/dist/rules/no-unnecessary-type-arguments.js +5 -0
  37. package/dist/rules/no-unnecessary-type-assertion.d.ts +2 -1
  38. package/dist/rules/no-unnecessary-type-assertion.js +498 -37
  39. package/dist/rules/no-unnecessary-type-conversion.js +1 -1
  40. package/dist/rules/no-unnecessary-type-parameters.js +5 -0
  41. package/dist/rules/no-unsafe-assignment.d.ts +1 -1
  42. package/dist/rules/no-unsafe-return.js +3 -3
  43. package/dist/rules/no-unsafe-type-assertion.js +8 -1
  44. package/dist/rules/no-unused-vars.js +1 -1
  45. package/dist/rules/no-useless-default-assignment.js +16 -11
  46. package/dist/rules/prefer-nullish-coalescing.js +6 -36
  47. package/dist/rules/prefer-optional-chain-utils/analyzeChain.js +4 -2
  48. package/dist/rules/prefer-string-starts-ends-with.js +2 -1
  49. package/dist/rules/prefer-ts-expect-error.js +1 -1
  50. package/dist/rules/require-array-sort-compare.js +1 -1
  51. package/dist/rules/restrict-template-expressions.d.ts +3 -3
  52. package/dist/rules/strict-void-return.js +3 -0
  53. package/dist/rules/unbound-method.js +36 -9
  54. package/dist/rules/unified-signatures.js +2 -2
  55. package/dist/util/getWrappingFixer.d.ts +4 -0
  56. package/dist/util/getWrappingFixer.js +1 -0
  57. package/dist/util/index.d.ts +1 -0
  58. package/dist/util/index.js +1 -0
  59. package/dist/util/isConditionalTest.d.ts +2 -0
  60. package/dist/util/isConditionalTest.js +34 -0
  61. package/package.json +35 -19
package/README.md CHANGED
@@ -13,10 +13,16 @@ 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.58.1 |
17
- | Processed | 2026-04-08 |
16
+ | Original | [@typescript-eslint/eslint-plugin](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin) @ 8.66.0 |
17
+ | Processed | 2026-08-04 |
18
18
  | Smoke test | passed |
19
- | Deps updated | 0 |
19
+ | Deps updated | 1 |
20
+
21
+ ## Dependency Changes
22
+
23
+ | Dependency | From | To |
24
+ |------------|------|-----|
25
+ | ignore | ^7.0.5 | ^7.0.6 |
20
26
 
21
27
  ---
22
28
 
package/changes.json CHANGED
@@ -1,5 +1,10 @@
1
1
  {
2
- "bumped": {},
3
- "timestamp": "2026-04-08T04:54:21.935Z",
4
- "totalUpdated": 0
2
+ "bumped": {
3
+ "ignore": {
4
+ "from": "^7.0.5",
5
+ "to": "^7.0.6"
6
+ }
7
+ },
8
+ "timestamp": "2026-08-04T00:39:44.077Z",
9
+ "totalUpdated": 1
5
10
  }
@@ -58,8 +58,6 @@ declare const _default: {
58
58
  'no-invalid-this': "off";
59
59
  '@typescript-eslint/no-invalid-this': "error";
60
60
  '@typescript-eslint/no-invalid-void-type': "error";
61
- 'no-loop-func': "off";
62
- '@typescript-eslint/no-loop-func': "error";
63
61
  'no-magic-numbers': "off";
64
62
  '@typescript-eslint/no-magic-numbers': "error";
65
63
  '@typescript-eslint/no-meaningless-void-operator': "error";
@@ -75,8 +73,6 @@ declare const _default: {
75
73
  '@typescript-eslint/no-redeclare': "error";
76
74
  '@typescript-eslint/no-redundant-type-constituents': "error";
77
75
  '@typescript-eslint/no-require-imports': "error";
78
- 'no-restricted-imports': "off";
79
- '@typescript-eslint/no-restricted-imports': "error";
80
76
  '@typescript-eslint/no-restricted-types': "error";
81
77
  'no-shadow': "off";
82
78
  '@typescript-eslint/no-shadow': "error";
@@ -65,8 +65,6 @@ module.exports = {
65
65
  'no-invalid-this': 'off',
66
66
  '@typescript-eslint/no-invalid-this': 'error',
67
67
  '@typescript-eslint/no-invalid-void-type': 'error',
68
- 'no-loop-func': 'off',
69
- '@typescript-eslint/no-loop-func': 'error',
70
68
  'no-magic-numbers': 'off',
71
69
  '@typescript-eslint/no-magic-numbers': 'error',
72
70
  '@typescript-eslint/no-meaningless-void-operator': 'error',
@@ -82,8 +80,6 @@ module.exports = {
82
80
  '@typescript-eslint/no-redeclare': 'error',
83
81
  '@typescript-eslint/no-redundant-type-constituents': 'error',
84
82
  '@typescript-eslint/no-require-imports': 'error',
85
- 'no-restricted-imports': 'off',
86
- '@typescript-eslint/no-restricted-imports': 'error',
87
83
  '@typescript-eslint/no-restricted-types': 'error',
88
84
  'no-shadow': 'off',
89
85
  '@typescript-eslint/no-shadow': 'error',
@@ -78,8 +78,6 @@ exports.default = (plugin, parser) => [
78
78
  'no-invalid-this': 'off',
79
79
  '@typescript-eslint/no-invalid-this': 'error',
80
80
  '@typescript-eslint/no-invalid-void-type': 'error',
81
- 'no-loop-func': 'off',
82
- '@typescript-eslint/no-loop-func': 'error',
83
81
  'no-magic-numbers': 'off',
84
82
  '@typescript-eslint/no-magic-numbers': 'error',
85
83
  '@typescript-eslint/no-meaningless-void-operator': 'error',
@@ -95,8 +93,6 @@ exports.default = (plugin, parser) => [
95
93
  '@typescript-eslint/no-redeclare': 'error',
96
94
  '@typescript-eslint/no-redundant-type-constituents': 'error',
97
95
  '@typescript-eslint/no-require-imports': 'error',
98
- 'no-restricted-imports': 'off',
99
- '@typescript-eslint/no-restricted-imports': 'error',
100
96
  '@typescript-eslint/no-restricted-types': 'error',
101
97
  'no-shadow': 'off',
102
98
  '@typescript-eslint/no-shadow': 'error',
package/dist/index.d.ts CHANGED
@@ -60,8 +60,6 @@ declare const _default: {
60
60
  'no-invalid-this': "off";
61
61
  '@typescript-eslint/no-invalid-this': "error";
62
62
  '@typescript-eslint/no-invalid-void-type': "error";
63
- 'no-loop-func': "off";
64
- '@typescript-eslint/no-loop-func': "error";
65
63
  'no-magic-numbers': "off";
66
64
  '@typescript-eslint/no-magic-numbers': "error";
67
65
  '@typescript-eslint/no-meaningless-void-operator': "error";
@@ -77,8 +75,6 @@ declare const _default: {
77
75
  '@typescript-eslint/no-redeclare': "error";
78
76
  '@typescript-eslint/no-redundant-type-constituents': "error";
79
77
  '@typescript-eslint/no-require-imports': "error";
80
- 'no-restricted-imports': "off";
81
- '@typescript-eslint/no-restricted-imports': "error";
82
78
  '@typescript-eslint/no-restricted-types': "error";
83
79
  'no-shadow': "off";
84
80
  '@typescript-eslint/no-shadow': "error";
@@ -798,7 +794,7 @@ declare const _default: {
798
794
  'no-dynamic-delete': import("@typescript-eslint/utils/ts-eslint").RuleModule<"dynamicDelete", [], import("../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
799
795
  name: string;
800
796
  };
801
- 'no-empty-function': import("@typescript-eslint/utils/ts-eslint").RuleModule<"unexpected" | "suggestComment", [{
797
+ 'no-empty-function': import("@typescript-eslint/utils/ts-eslint").RuleModule<"suggestComment" | "unexpected", [{
802
798
  allow?: string[];
803
799
  }], import("../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
804
800
  name: string;
@@ -882,7 +878,7 @@ declare const _default: {
882
878
  'no-non-null-asserted-nullish-coalescing': import("@typescript-eslint/utils/ts-eslint").RuleModule<"noNonNullAssertedNullishCoalescing" | "suggestRemovingNonNull", [], import("../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
883
879
  name: string;
884
880
  };
885
- 'no-non-null-asserted-optional-chain': import("@typescript-eslint/utils/ts-eslint").RuleModule<"suggestRemovingNonNull" | "noNonNullOptionalChain", [], import("../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
881
+ 'no-non-null-asserted-optional-chain': import("@typescript-eslint/utils/ts-eslint").RuleModule<"noNonNullOptionalChain" | "suggestRemovingNonNull", [], import("../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
886
882
  name: string;
887
883
  };
888
884
  'no-non-null-assertion': import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./rules/no-non-null-assertion").MessageIds, [], import("../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
@@ -891,13 +887,13 @@ declare const _default: {
891
887
  'no-redeclare': import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./rules/no-redeclare").MessageIds, import("./rules/no-redeclare").Options, import("../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
892
888
  name: string;
893
889
  };
894
- 'no-redundant-type-constituents': import("@typescript-eslint/utils/ts-eslint").RuleModule<"overrides" | "errorTypeOverrides" | "literalOverridden" | "overridden" | "primitiveOverridden", [], import("../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
890
+ 'no-redundant-type-constituents': import("@typescript-eslint/utils/ts-eslint").RuleModule<"errorTypeOverrides" | "literalOverridden" | "overridden" | "overrides" | "primitiveOverridden", [], import("../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
895
891
  name: string;
896
892
  };
897
893
  'no-require-imports': import("@typescript-eslint/utils/ts-eslint").RuleModule<"noRequireImports", import("./rules/no-require-imports").Options, import("../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
898
894
  name: string;
899
895
  };
900
- 'no-restricted-imports': import("@typescript-eslint/utils/ts-eslint").RuleModule<"everything" | "everythingWithCustomMessage" | "importName" | "importNameWithCustomMessage" | "path" | "pathWithCustomMessage" | "patterns" | "patternWithCustomMessage", [import("eslint/lib/rules/no-restricted-imports").ObjectOfPathsAndPatterns] | import("eslint/lib/rules/no-restricted-imports").ArrayOfStringOrObject, import("../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
896
+ 'no-restricted-imports': import("@typescript-eslint/utils/ts-eslint").RuleModule<"everything" | "everythingWithCustomMessage" | "importName" | "importNameWithCustomMessage" | "path" | "pathWithCustomMessage" | "patternWithCustomMessage" | "patterns", import("eslint/lib/rules/no-restricted-imports").ArrayOfStringOrObject | [import("eslint/lib/rules/no-restricted-imports").ObjectOfPathsAndPatterns], import("../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
901
897
  name: string;
902
898
  };
903
899
  'no-restricted-types': import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./rules/no-restricted-types").MessageIds, import("./rules/no-restricted-types").Options, import("../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
@@ -945,7 +941,7 @@ declare const _default: {
945
941
  'no-unsafe-argument': import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./rules/no-unsafe-argument").MessageIds, [], import("../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
946
942
  name: string;
947
943
  };
948
- 'no-unsafe-assignment': import("@typescript-eslint/utils/ts-eslint").RuleModule<"unsafeArraySpread" | "anyAssignment" | "anyAssignmentThis" | "unsafeArrayPattern" | "unsafeArrayPatternFromTuple" | "unsafeAssignment" | "unsafeObjectPattern", [], import("../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
944
+ 'no-unsafe-assignment': import("@typescript-eslint/utils/ts-eslint").RuleModule<"anyAssignment" | "anyAssignmentThis" | "unsafeArrayPattern" | "unsafeArrayPatternFromTuple" | "unsafeArraySpread" | "unsafeAssignment" | "unsafeObjectPattern", [], import("../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
949
945
  name: string;
950
946
  };
951
947
  'no-unsafe-call': import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./rules/no-unsafe-call").MessageIds, [], import("../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
package/dist/index.js CHANGED
@@ -1,6 +1,53 @@
1
1
  "use strict";
2
+ /* eslint-disable import/first -- intentionally executing code before rest of the require()s. This will not work with ESM. */
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
2
36
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
37
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
38
  };
39
+ const ts = __importStar(require("typescript"));
40
+ const [versionMajor, _versionMinor] = ts.versionMajorMinor
41
+ .split('.')
42
+ .map(Number);
43
+ if (versionMajor >= 7) {
44
+ // eslint-disable-next-line no-console
45
+ console.error([
46
+ 'typescript-eslint does not support TS 7.0.',
47
+ 'Please see https://devblogs.microsoft.com/typescript/announcing-typescript-7-0/#running-side-by-side-with-typescript-6.0 to run typescript-eslint using the TS 6 API.',
48
+ "See also https://github.com/typescript-eslint/typescript-eslint/issues/10940 for tracking typescript-eslint's support for TS >=7.1",
49
+ ].join('\n'));
50
+ throw new Error('typescript-eslint does not support TS 7.0.');
51
+ }
5
52
  const raw_plugin_1 = __importDefault(require("./raw-plugin"));
6
53
  module.exports = raw_plugin_1.default.plugin;
@@ -82,8 +82,6 @@ declare const _default: {
82
82
  'no-invalid-this': "off";
83
83
  '@typescript-eslint/no-invalid-this': "error";
84
84
  '@typescript-eslint/no-invalid-void-type': "error";
85
- 'no-loop-func': "off";
86
- '@typescript-eslint/no-loop-func': "error";
87
85
  'no-magic-numbers': "off";
88
86
  '@typescript-eslint/no-magic-numbers': "error";
89
87
  '@typescript-eslint/no-meaningless-void-operator': "error";
@@ -99,8 +97,6 @@ declare const _default: {
99
97
  '@typescript-eslint/no-redeclare': "error";
100
98
  '@typescript-eslint/no-redundant-type-constituents': "error";
101
99
  '@typescript-eslint/no-require-imports': "error";
102
- 'no-restricted-imports': "off";
103
- '@typescript-eslint/no-restricted-imports': "error";
104
100
  '@typescript-eslint/no-restricted-types': "error";
105
101
  'no-shadow': "off";
106
102
  '@typescript-eslint/no-shadow': "error";
@@ -821,7 +817,7 @@ declare const _default: {
821
817
  'no-dynamic-delete': TSESLint.RuleModule<"dynamicDelete", [], import("../rules").ESLintPluginDocs, TSESLint.RuleListener> & {
822
818
  name: string;
823
819
  };
824
- 'no-empty-function': TSESLint.RuleModule<"unexpected" | "suggestComment", [{
820
+ 'no-empty-function': TSESLint.RuleModule<"suggestComment" | "unexpected", [{
825
821
  allow?: string[];
826
822
  }], import("../rules").ESLintPluginDocs, TSESLint.RuleListener> & {
827
823
  name: string;
@@ -905,7 +901,7 @@ declare const _default: {
905
901
  'no-non-null-asserted-nullish-coalescing': TSESLint.RuleModule<"noNonNullAssertedNullishCoalescing" | "suggestRemovingNonNull", [], import("../rules").ESLintPluginDocs, TSESLint.RuleListener> & {
906
902
  name: string;
907
903
  };
908
- 'no-non-null-asserted-optional-chain': TSESLint.RuleModule<"suggestRemovingNonNull" | "noNonNullOptionalChain", [], import("../rules").ESLintPluginDocs, TSESLint.RuleListener> & {
904
+ 'no-non-null-asserted-optional-chain': TSESLint.RuleModule<"noNonNullOptionalChain" | "suggestRemovingNonNull", [], import("../rules").ESLintPluginDocs, TSESLint.RuleListener> & {
909
905
  name: string;
910
906
  };
911
907
  'no-non-null-assertion': TSESLint.RuleModule<import("./rules/no-non-null-assertion").MessageIds, [], import("../rules").ESLintPluginDocs, TSESLint.RuleListener> & {
@@ -914,13 +910,13 @@ declare const _default: {
914
910
  'no-redeclare': TSESLint.RuleModule<import("./rules/no-redeclare").MessageIds, import("./rules/no-redeclare").Options, import("../rules").ESLintPluginDocs, TSESLint.RuleListener> & {
915
911
  name: string;
916
912
  };
917
- 'no-redundant-type-constituents': TSESLint.RuleModule<"overrides" | "errorTypeOverrides" | "literalOverridden" | "overridden" | "primitiveOverridden", [], import("../rules").ESLintPluginDocs, TSESLint.RuleListener> & {
913
+ 'no-redundant-type-constituents': TSESLint.RuleModule<"errorTypeOverrides" | "literalOverridden" | "overridden" | "overrides" | "primitiveOverridden", [], import("../rules").ESLintPluginDocs, TSESLint.RuleListener> & {
918
914
  name: string;
919
915
  };
920
916
  'no-require-imports': TSESLint.RuleModule<"noRequireImports", import("./rules/no-require-imports").Options, import("../rules").ESLintPluginDocs, TSESLint.RuleListener> & {
921
917
  name: string;
922
918
  };
923
- 'no-restricted-imports': TSESLint.RuleModule<"everything" | "everythingWithCustomMessage" | "importName" | "importNameWithCustomMessage" | "path" | "pathWithCustomMessage" | "patterns" | "patternWithCustomMessage", [import("eslint/lib/rules/no-restricted-imports").ObjectOfPathsAndPatterns] | import("eslint/lib/rules/no-restricted-imports").ArrayOfStringOrObject, import("../rules").ESLintPluginDocs, TSESLint.RuleListener> & {
919
+ 'no-restricted-imports': TSESLint.RuleModule<"everything" | "everythingWithCustomMessage" | "importName" | "importNameWithCustomMessage" | "path" | "pathWithCustomMessage" | "patternWithCustomMessage" | "patterns", import("eslint/lib/rules/no-restricted-imports").ArrayOfStringOrObject | [import("eslint/lib/rules/no-restricted-imports").ObjectOfPathsAndPatterns], import("../rules").ESLintPluginDocs, TSESLint.RuleListener> & {
924
920
  name: string;
925
921
  };
926
922
  'no-restricted-types': TSESLint.RuleModule<import("./rules/no-restricted-types").MessageIds, import("./rules/no-restricted-types").Options, import("../rules").ESLintPluginDocs, TSESLint.RuleListener> & {
@@ -968,7 +964,7 @@ declare const _default: {
968
964
  'no-unsafe-argument': TSESLint.RuleModule<import("./rules/no-unsafe-argument").MessageIds, [], import("../rules").ESLintPluginDocs, TSESLint.RuleListener> & {
969
965
  name: string;
970
966
  };
971
- 'no-unsafe-assignment': TSESLint.RuleModule<"unsafeArraySpread" | "anyAssignment" | "anyAssignmentThis" | "unsafeArrayPattern" | "unsafeArrayPatternFromTuple" | "unsafeAssignment" | "unsafeObjectPattern", [], import("../rules").ESLintPluginDocs, TSESLint.RuleListener> & {
967
+ 'no-unsafe-assignment': TSESLint.RuleModule<"anyAssignment" | "anyAssignmentThis" | "unsafeArrayPattern" | "unsafeArrayPatternFromTuple" | "unsafeArraySpread" | "unsafeAssignment" | "unsafeObjectPattern", [], import("../rules").ESLintPluginDocs, TSESLint.RuleListener> & {
972
968
  name: string;
973
969
  };
974
970
  'no-unsafe-call': TSESLint.RuleModule<import("./rules/no-unsafe-call").MessageIds, [], import("../rules").ESLintPluginDocs, TSESLint.RuleListener> & {
@@ -54,19 +54,19 @@ exports.default = (0, util_1.createRule)({
54
54
  },
55
55
  'ts-check': {
56
56
  $ref: '#/items/0/$defs/directiveConfigSchema',
57
- description: 'Whether allow ts-check directives, and with which restrictions.',
57
+ description: 'Whether to allow ts-check directives, and with which restrictions.',
58
58
  },
59
59
  'ts-expect-error': {
60
60
  $ref: '#/items/0/$defs/directiveConfigSchema',
61
- description: 'Whether and when expect-error directives, and with which restrictions.',
61
+ description: 'Whether to allow ts-expect-error directives, and with which restrictions.',
62
62
  },
63
63
  'ts-ignore': {
64
64
  $ref: '#/items/0/$defs/directiveConfigSchema',
65
- description: 'Whether allow ts-ignore directives, and with which restrictions.',
65
+ description: 'Whether to allow ts-ignore directives, and with which restrictions.',
66
66
  },
67
67
  'ts-nocheck': {
68
68
  $ref: '#/items/0/$defs/directiveConfigSchema',
69
- description: 'Whether allow ts-nocheck directives, and with which restrictions.',
69
+ description: 'Whether to allow ts-nocheck directives, and with which restrictions.',
70
70
  },
71
71
  },
72
72
  },
@@ -121,7 +121,7 @@ exports.default = (0, util_1.createRule)({
121
121
  }
122
122
  return execDirectiveRegEx(commentDirectiveRegExSingleLine, comment.value);
123
123
  }
124
- const commentLines = comment.value.split('\n');
124
+ const commentLines = comment.value.split(utils_1.ASTUtils.LINEBREAK_MATCHER);
125
125
  return execDirectiveRegEx(commentDirectiveRegExMultiLine, commentLines[commentLines.length - 1]);
126
126
  }
127
127
  return {
@@ -113,22 +113,29 @@ exports.default = (0, util_1.createRule)({
113
113
  if (hasDuplicateKeySetter) {
114
114
  return;
115
115
  }
116
+ const getterBody = node.value.body;
116
117
  context.report({
117
118
  node: node.key,
118
119
  messageId: 'preferFieldStyle',
119
- suggest: [
120
- {
120
+ ...(0, util_1.getFixOrSuggest)({
121
+ fixOrSuggest: node.decorators.length === 0 ? 'suggest' : 'none',
122
+ suggestion: {
121
123
  messageId: 'preferFieldStyleSuggestion',
122
124
  fix(fixer) {
123
125
  const name = context.sourceCode.getText(node.key);
126
+ const closingParen = (0, util_1.nullThrows)(context.sourceCode.getTokenBefore(node.value.returnType ?? getterBody), 'Getter should have a closing parenthesis.');
127
+ const betweenParensAndBody = context.sourceCode
128
+ .getText()
129
+ .slice(closingParen.range[1], getterBody.range[0]);
124
130
  let text = '';
125
131
  text += printNodeModifiers(node, 'readonly');
126
132
  text += node.computed ? `[${name}]` : name;
127
- text += ` = ${context.sourceCode.getText(argument)};`;
133
+ text += betweenParensAndBody;
134
+ text += `= ${context.sourceCode.getText(argument)};`;
128
135
  return fixer.replaceText(node, text);
129
136
  },
130
137
  },
131
- ],
138
+ }),
132
139
  });
133
140
  },
134
141
  }),
@@ -1,5 +1,5 @@
1
1
  import type { TSESLint } from '@typescript-eslint/utils';
2
- export type MessageIds = 'preferIndexSignature' | 'preferIndexSignatureSuggestion' | 'preferRecord';
2
+ export type MessageIds = 'preferIndexSignature' | 'preferIndexSignatureSuggestion' | 'preferRecord' | 'preferRecordSuggestion';
3
3
  export type Options = ['index-signature' | 'record'];
4
4
  declare const _default: TSESLint.RuleModule<MessageIds, Options, import("../../rules").ESLintPluginDocs, TSESLint.RuleListener> & {
5
5
  name: string;
@@ -17,6 +17,7 @@ exports.default = (0, util_1.createRule)({
17
17
  preferIndexSignature: 'An index signature is preferred over a record.',
18
18
  preferIndexSignatureSuggestion: 'Change into an index signature instead of a record.',
19
19
  preferRecord: 'A record is preferred over an index signature.',
20
+ preferRecordSuggestion: 'Change into a record instead of an index signature.',
20
21
  },
21
22
  schema: [
22
23
  {
@@ -28,6 +29,16 @@ exports.default = (0, util_1.createRule)({
28
29
  },
29
30
  defaultOptions: ['record'],
30
31
  create(context, [mode]) {
32
+ // The fixers rebuild the type from the text of a few sub-nodes, so a
33
+ // comment inside `node` but outside all of those preserved sub-nodes would
34
+ // be dropped by the fix. Returns true when at least one such comment exists.
35
+ function hasUnpreservedComments(node, ...preserved) {
36
+ return context.sourceCode
37
+ .getCommentsInside(node)
38
+ .some(comment => preserved.every(target => target == null ||
39
+ comment.range[0] < target.range[0] ||
40
+ comment.range[1] > target.range[1]));
41
+ }
31
42
  function checkMembers(members, node, parentId, prefix, postfix, safeFix = true) {
32
43
  if (members.length !== 1) {
33
44
  return;
@@ -59,16 +70,24 @@ exports.default = (0, util_1.createRule)({
59
70
  context.report({
60
71
  node,
61
72
  messageId: 'preferRecord',
62
- fix: safeFix
63
- ? (fixer) => {
64
- const key = context.sourceCode.getText(keyType.typeAnnotation);
65
- const value = context.sourceCode.getText(valueType.typeAnnotation);
66
- const record = member.readonly
67
- ? `Readonly<Record<${key}, ${value}>>`
68
- : `Record<${key}, ${value}>`;
69
- return fixer.replaceText(node, `${prefix}${record}${postfix}`);
70
- }
71
- : null,
73
+ ...(0, util_1.getFixOrSuggest)({
74
+ fixOrSuggest: !safeFix
75
+ ? 'none'
76
+ : hasUnpreservedComments(node, keyType.typeAnnotation, valueType.typeAnnotation)
77
+ ? 'suggest'
78
+ : 'fix',
79
+ suggestion: {
80
+ messageId: 'preferRecordSuggestion',
81
+ fix: (fixer) => {
82
+ const key = context.sourceCode.getText(keyType.typeAnnotation);
83
+ const value = context.sourceCode.getText(valueType.typeAnnotation);
84
+ const record = member.readonly
85
+ ? `Readonly<Record<${key}, ${value}>>`
86
+ : `Record<${key}, ${value}>`;
87
+ return fixer.replaceText(node, `${prefix}${record}${postfix}`);
88
+ },
89
+ },
90
+ }),
72
91
  });
73
92
  }
74
93
  return {
@@ -93,7 +112,9 @@ exports.default = (0, util_1.createRule)({
93
112
  node,
94
113
  messageId: 'preferIndexSignature',
95
114
  ...(0, util_1.getFixOrSuggest)({
96
- fixOrSuggest: shouldFix ? 'fix' : 'suggest',
115
+ fixOrSuggest: shouldFix && !hasUnpreservedComments(node, params[0], params[1])
116
+ ? 'fix'
117
+ : 'suggest',
97
118
  suggestion: {
98
119
  messageId: 'preferIndexSignatureSuggestion',
99
120
  fix: fixer => {
@@ -146,28 +167,36 @@ exports.default = (0, util_1.createRule)({
146
167
  }
147
168
  }
148
169
  }
149
- // There's no builtin Mutable<T> type, so we can't autofix it really.
150
- const canFix = node.readonly !== '-';
151
170
  context.report({
152
171
  node,
153
172
  messageId: 'preferRecord',
154
- ...(canFix && {
155
- fix: (fixer) => {
156
- const keyType = context.sourceCode.getText(constraint);
157
- const valueType = node.typeAnnotation
158
- ? context.sourceCode.getText(node.typeAnnotation)
159
- : 'any';
160
- let recordText = `Record<${keyType}, ${valueType}>`;
161
- if (node.optional === '+' || node.optional === true) {
162
- recordText = `Partial<${recordText}>`;
163
- }
164
- else if (node.optional === '-') {
165
- recordText = `Required<${recordText}>`;
166
- }
167
- if (node.readonly === '+' || node.readonly === true) {
168
- recordText = `Readonly<${recordText}>`;
169
- }
170
- return fixer.replaceText(node, recordText);
173
+ ...(0, util_1.getFixOrSuggest)({
174
+ // There's no builtin Mutable<T> type, so a `-readonly` mapped
175
+ // type can't be represented as a Record and is left untouched.
176
+ fixOrSuggest: node.readonly === '-'
177
+ ? 'none'
178
+ : hasUnpreservedComments(node, constraint, node.typeAnnotation)
179
+ ? 'suggest'
180
+ : 'fix',
181
+ suggestion: {
182
+ messageId: 'preferRecordSuggestion',
183
+ fix: (fixer) => {
184
+ const keyType = context.sourceCode.getText(constraint);
185
+ const valueType = node.typeAnnotation
186
+ ? context.sourceCode.getText(node.typeAnnotation)
187
+ : 'any';
188
+ let recordText = `Record<${keyType}, ${valueType}>`;
189
+ if (node.optional === '+' || node.optional === true) {
190
+ recordText = `Partial<${recordText}>`;
191
+ }
192
+ else if (node.optional === '-') {
193
+ recordText = `Required<${recordText}>`;
194
+ }
195
+ if (node.readonly === '+' || node.readonly === true) {
196
+ recordText = `Readonly<${recordText}>`;
197
+ }
198
+ return fixer.replaceText(node, recordText);
199
+ },
171
200
  },
172
201
  }),
173
202
  });
@@ -119,7 +119,7 @@ declare const rules: {
119
119
  'no-dynamic-delete': import("@typescript-eslint/utils/ts-eslint").RuleModule<"dynamicDelete", [], import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
120
120
  name: string;
121
121
  };
122
- 'no-empty-function': import("@typescript-eslint/utils/ts-eslint").RuleModule<"unexpected" | "suggestComment", [{
122
+ 'no-empty-function': import("@typescript-eslint/utils/ts-eslint").RuleModule<"suggestComment" | "unexpected", [{
123
123
  allow?: string[];
124
124
  }], import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
125
125
  name: string;
@@ -203,7 +203,7 @@ declare const rules: {
203
203
  'no-non-null-asserted-nullish-coalescing': import("@typescript-eslint/utils/ts-eslint").RuleModule<"noNonNullAssertedNullishCoalescing" | "suggestRemovingNonNull", [], import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
204
204
  name: string;
205
205
  };
206
- 'no-non-null-asserted-optional-chain': import("@typescript-eslint/utils/ts-eslint").RuleModule<"suggestRemovingNonNull" | "noNonNullOptionalChain", [], import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
206
+ 'no-non-null-asserted-optional-chain': import("@typescript-eslint/utils/ts-eslint").RuleModule<"noNonNullOptionalChain" | "suggestRemovingNonNull", [], import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
207
207
  name: string;
208
208
  };
209
209
  'no-non-null-assertion': import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./no-non-null-assertion").MessageIds, [], import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
@@ -212,13 +212,13 @@ declare const rules: {
212
212
  'no-redeclare': import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./no-redeclare").MessageIds, import("./no-redeclare").Options, import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
213
213
  name: string;
214
214
  };
215
- 'no-redundant-type-constituents': import("@typescript-eslint/utils/ts-eslint").RuleModule<"overrides" | "errorTypeOverrides" | "literalOverridden" | "overridden" | "primitiveOverridden", [], import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
215
+ 'no-redundant-type-constituents': import("@typescript-eslint/utils/ts-eslint").RuleModule<"errorTypeOverrides" | "literalOverridden" | "overridden" | "overrides" | "primitiveOverridden", [], import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
216
216
  name: string;
217
217
  };
218
218
  'no-require-imports': import("@typescript-eslint/utils/ts-eslint").RuleModule<"noRequireImports", import("./no-require-imports").Options, import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
219
219
  name: string;
220
220
  };
221
- 'no-restricted-imports': import("@typescript-eslint/utils/ts-eslint").RuleModule<"everything" | "everythingWithCustomMessage" | "importName" | "importNameWithCustomMessage" | "path" | "pathWithCustomMessage" | "patterns" | "patternWithCustomMessage", [import("eslint/lib/rules/no-restricted-imports").ObjectOfPathsAndPatterns] | import("eslint/lib/rules/no-restricted-imports").ArrayOfStringOrObject, import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
221
+ 'no-restricted-imports': import("@typescript-eslint/utils/ts-eslint").RuleModule<"everything" | "everythingWithCustomMessage" | "importName" | "importNameWithCustomMessage" | "path" | "pathWithCustomMessage" | "patternWithCustomMessage" | "patterns", import("eslint/lib/rules/no-restricted-imports").ArrayOfStringOrObject | [import("eslint/lib/rules/no-restricted-imports").ObjectOfPathsAndPatterns], import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
222
222
  name: string;
223
223
  };
224
224
  'no-restricted-types': import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./no-restricted-types").MessageIds, import("./no-restricted-types").Options, import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
@@ -266,7 +266,7 @@ declare const rules: {
266
266
  'no-unsafe-argument': import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./no-unsafe-argument").MessageIds, [], import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
267
267
  name: string;
268
268
  };
269
- 'no-unsafe-assignment': import("@typescript-eslint/utils/ts-eslint").RuleModule<"unsafeArraySpread" | "anyAssignment" | "anyAssignmentThis" | "unsafeArrayPattern" | "unsafeArrayPatternFromTuple" | "unsafeAssignment" | "unsafeObjectPattern", [], import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
269
+ 'no-unsafe-assignment': import("@typescript-eslint/utils/ts-eslint").RuleModule<"anyAssignment" | "anyAssignmentThis" | "unsafeArrayPattern" | "unsafeArrayPatternFromTuple" | "unsafeArraySpread" | "unsafeAssignment" | "unsafeObjectPattern", [], import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
270
270
  name: string;
271
271
  };
272
272
  'no-unsafe-call': import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./no-unsafe-call").MessageIds, [], import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
@@ -1,5 +1,5 @@
1
1
  export type Options = [('method' | 'property')?];
2
- export type MessageIds = 'errorMethod' | 'errorProperty';
2
+ export type MessageIds = 'convertToMethodSignature' | 'errorMethod' | 'errorProperty';
3
3
  declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<MessageIds, Options, import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
4
4
  name: string;
5
5
  };
@@ -10,7 +10,9 @@ exports.default = (0, util_1.createRule)({
10
10
  description: 'Enforce using a particular method signature syntax',
11
11
  },
12
12
  fixable: 'code',
13
+ hasSuggestions: true,
13
14
  messages: {
15
+ convertToMethodSignature: 'Convert to a method signature. This removes the `readonly` modifier, allowing the member to be reassigned.',
14
16
  errorMethod: 'Shorthand method signature is forbidden. Use a function property instead.',
15
17
  errorProperty: 'Function property signature is forbidden. Use a method shorthand instead.',
16
18
  },
@@ -32,9 +34,6 @@ exports.default = (0, util_1.createRule)({
32
34
  if (node.optional) {
33
35
  key = `${key}?`;
34
36
  }
35
- if (node.readonly) {
36
- key = `readonly ${key}`;
37
- }
38
37
  return key;
39
38
  }
40
39
  function getMethodParams(node) {
@@ -164,16 +163,30 @@ exports.default = (0, util_1.createRule)({
164
163
  if (typeNode?.type !== utils_1.AST_NODE_TYPES.TSFunctionType) {
165
164
  return;
166
165
  }
166
+ const fix = fixer => {
167
+ const key = getMethodKey(propertyNode);
168
+ const params = getMethodParams(typeNode);
169
+ const returnType = getMethodReturnType(typeNode);
170
+ const delimiter = getDelimiter(propertyNode);
171
+ return fixer.replaceText(propertyNode, `${key}${params}: ${returnType}${delimiter}`);
172
+ };
173
+ // There is no syntax for a `readonly` method signature, so converting
174
+ // a `readonly` function-typed property drops the `readonly` modifier.
175
+ // That is a behavioral change (a method may be reassigned, a
176
+ // `readonly` property may not), so it is offered as a suggestion
177
+ // rather than applied as an autofix.
178
+ if (propertyNode.readonly) {
179
+ context.report({
180
+ node: propertyNode,
181
+ messageId: 'errorProperty',
182
+ suggest: [{ messageId: 'convertToMethodSignature', fix }],
183
+ });
184
+ return;
185
+ }
167
186
  context.report({
168
187
  node: propertyNode,
169
188
  messageId: 'errorProperty',
170
- fix: fixer => {
171
- const key = getMethodKey(propertyNode);
172
- const params = getMethodParams(typeNode);
173
- const returnType = getMethodReturnType(typeNode);
174
- const delimiter = getDelimiter(propertyNode);
175
- return fixer.replaceText(propertyNode, `${key}${params}: ${returnType}${delimiter}`);
176
- },
189
+ fix,
177
190
  });
178
191
  },
179
192
  }),
@@ -234,7 +234,7 @@ exports.default = (0, util_1.createRule)({
234
234
  node.arguments[0]) {
235
235
  const scope = context.sourceCode.getScope(node);
236
236
  // eslint-disable-next-line @typescript-eslint/internal/prefer-ast-types-enum
237
- const variable = scope.set.get('String');
237
+ const variable = utils_1.ASTUtils.findVariable(scope, 'String');
238
238
  return !variable?.defs.length;
239
239
  }
240
240
  return false;
@@ -289,8 +289,8 @@ exports.default = (0, util_1.createRule)({
289
289
  if ((0, util_1.getTypeName)(checker, leftType) === 'string') {
290
290
  checkExpression(node.right, rightType);
291
291
  }
292
- else if ((0, util_1.getTypeName)(checker, rightType) === 'string' &&
293
- node.left.type !== utils_1.AST_NODE_TYPES.PrivateIdentifier) {
292
+ else if (node.left.type !== utils_1.AST_NODE_TYPES.PrivateIdentifier &&
293
+ (0, util_1.getTypeName)(checker, rightType) === 'string') {
294
294
  checkExpression(node.left, leftType);
295
295
  }
296
296
  },