@typescript-eslint/eslint-plugin 8.72.3-alpha.5 → 8.72.3-alpha.7
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.
- package/dist/configs/eslintrc/all.d.ts +1 -0
- package/dist/configs/eslintrc/all.js +1 -0
- package/dist/configs/eslintrc/disable-type-checked.d.ts +1 -0
- package/dist/configs/eslintrc/disable-type-checked.js +1 -0
- package/dist/configs/eslintrc/strict-type-checked-only.d.ts +1 -0
- package/dist/configs/eslintrc/strict-type-checked-only.js +1 -0
- package/dist/configs/eslintrc/strict-type-checked.d.ts +1 -0
- package/dist/configs/eslintrc/strict-type-checked.js +1 -0
- package/dist/configs/flat/all.js +1 -0
- package/dist/configs/flat/disable-type-checked.js +1 -0
- package/dist/configs/flat/strict-type-checked-only.js +1 -0
- package/dist/configs/flat/strict-type-checked.js +1 -0
- package/dist/index.d.ts +5 -1
- package/dist/raw-plugin.d.ts +5 -1
- package/dist/rules/consistent-type-imports.js +14 -20
- package/dist/rules/index.d.ts +1 -1
- package/dist/rules/index.js +1 -0
- package/dist/rules/no-unnecessary-type-assertion.js +5 -5
- package/dist/rules/no-unsafe-class-instance-assignment.d.ts +4 -0
- package/dist/rules/no-unsafe-class-instance-assignment.js +276 -0
- package/dist/rules/prefer-function-type.d.ts +3 -2
- package/dist/util/index.d.ts +1 -4
- package/package.json +9 -9
|
@@ -91,6 +91,7 @@ declare const _default: {
|
|
|
91
91
|
'@typescript-eslint/no-unsafe-argument': "error";
|
|
92
92
|
'@typescript-eslint/no-unsafe-assignment': "error";
|
|
93
93
|
'@typescript-eslint/no-unsafe-call': "error";
|
|
94
|
+
'@typescript-eslint/no-unsafe-class-instance-assignment': "error";
|
|
94
95
|
'@typescript-eslint/no-unsafe-declaration-merging': "error";
|
|
95
96
|
'@typescript-eslint/no-unsafe-enum-assignment': "error";
|
|
96
97
|
'@typescript-eslint/no-unsafe-enum-comparison': "error";
|
|
@@ -98,6 +98,7 @@ module.exports = {
|
|
|
98
98
|
'@typescript-eslint/no-unsafe-argument': 'error',
|
|
99
99
|
'@typescript-eslint/no-unsafe-assignment': 'error',
|
|
100
100
|
'@typescript-eslint/no-unsafe-call': 'error',
|
|
101
|
+
'@typescript-eslint/no-unsafe-class-instance-assignment': 'error',
|
|
101
102
|
'@typescript-eslint/no-unsafe-declaration-merging': 'error',
|
|
102
103
|
'@typescript-eslint/no-unsafe-enum-assignment': 'error',
|
|
103
104
|
'@typescript-eslint/no-unsafe-enum-comparison': '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-class-instance-assignment': "off";
|
|
38
39
|
'@typescript-eslint/no-unsafe-enum-assignment': "off";
|
|
39
40
|
'@typescript-eslint/no-unsafe-enum-comparison': "off";
|
|
40
41
|
'@typescript-eslint/no-unsafe-member-access': "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-class-instance-assignment': 'off',
|
|
41
42
|
'@typescript-eslint/no-unsafe-enum-assignment': 'off',
|
|
42
43
|
'@typescript-eslint/no-unsafe-enum-comparison': 'off',
|
|
43
44
|
'@typescript-eslint/no-unsafe-member-access': '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-class-instance-assignment': "error";
|
|
30
31
|
'@typescript-eslint/no-unsafe-enum-assignment': "error";
|
|
31
32
|
'@typescript-eslint/no-unsafe-enum-comparison': "error";
|
|
32
33
|
'@typescript-eslint/no-unsafe-member-access': "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-class-instance-assignment': 'error',
|
|
37
38
|
'@typescript-eslint/no-unsafe-enum-assignment': 'error',
|
|
38
39
|
'@typescript-eslint/no-unsafe-enum-comparison': 'error',
|
|
39
40
|
'@typescript-eslint/no-unsafe-member-access': 'error',
|
|
@@ -47,6 +47,7 @@ declare const _default: {
|
|
|
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-class-instance-assignment': "error";
|
|
50
51
|
'@typescript-eslint/no-unsafe-declaration-merging': "error";
|
|
51
52
|
'@typescript-eslint/no-unsafe-enum-assignment': "error";
|
|
52
53
|
'@typescript-eslint/no-unsafe-enum-comparison': "error";
|
|
@@ -55,6 +55,7 @@ module.exports = {
|
|
|
55
55
|
'@typescript-eslint/no-unsafe-argument': 'error',
|
|
56
56
|
'@typescript-eslint/no-unsafe-assignment': 'error',
|
|
57
57
|
'@typescript-eslint/no-unsafe-call': 'error',
|
|
58
|
+
'@typescript-eslint/no-unsafe-class-instance-assignment': 'error',
|
|
58
59
|
'@typescript-eslint/no-unsafe-declaration-merging': 'error',
|
|
59
60
|
'@typescript-eslint/no-unsafe-enum-assignment': 'error',
|
|
60
61
|
'@typescript-eslint/no-unsafe-enum-comparison': 'error',
|
package/dist/configs/flat/all.js
CHANGED
|
@@ -111,6 +111,7 @@ exports.default = (plugin, parser) => [
|
|
|
111
111
|
'@typescript-eslint/no-unsafe-argument': 'error',
|
|
112
112
|
'@typescript-eslint/no-unsafe-assignment': 'error',
|
|
113
113
|
'@typescript-eslint/no-unsafe-call': 'error',
|
|
114
|
+
'@typescript-eslint/no-unsafe-class-instance-assignment': 'error',
|
|
114
115
|
'@typescript-eslint/no-unsafe-declaration-merging': 'error',
|
|
115
116
|
'@typescript-eslint/no-unsafe-enum-assignment': 'error',
|
|
116
117
|
'@typescript-eslint/no-unsafe-enum-comparison': '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-class-instance-assignment': 'off',
|
|
46
47
|
'@typescript-eslint/no-unsafe-enum-assignment': 'off',
|
|
47
48
|
'@typescript-eslint/no-unsafe-enum-comparison': 'off',
|
|
48
49
|
'@typescript-eslint/no-unsafe-member-access': '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-class-instance-assignment': 'error',
|
|
50
51
|
'@typescript-eslint/no-unsafe-enum-assignment': 'error',
|
|
51
52
|
'@typescript-eslint/no-unsafe-enum-comparison': 'error',
|
|
52
53
|
'@typescript-eslint/no-unsafe-member-access': 'error',
|
|
@@ -68,6 +68,7 @@ exports.default = (plugin, parser) => [
|
|
|
68
68
|
'@typescript-eslint/no-unsafe-argument': 'error',
|
|
69
69
|
'@typescript-eslint/no-unsafe-assignment': 'error',
|
|
70
70
|
'@typescript-eslint/no-unsafe-call': 'error',
|
|
71
|
+
'@typescript-eslint/no-unsafe-class-instance-assignment': 'error',
|
|
71
72
|
'@typescript-eslint/no-unsafe-declaration-merging': 'error',
|
|
72
73
|
'@typescript-eslint/no-unsafe-enum-assignment': 'error',
|
|
73
74
|
'@typescript-eslint/no-unsafe-enum-comparison': 'error',
|
package/dist/index.d.ts
CHANGED
|
@@ -93,6 +93,7 @@ declare const _default: {
|
|
|
93
93
|
'@typescript-eslint/no-unsafe-argument': "error";
|
|
94
94
|
'@typescript-eslint/no-unsafe-assignment': "error";
|
|
95
95
|
'@typescript-eslint/no-unsafe-call': "error";
|
|
96
|
+
'@typescript-eslint/no-unsafe-class-instance-assignment': "error";
|
|
96
97
|
'@typescript-eslint/no-unsafe-declaration-merging': "error";
|
|
97
98
|
'@typescript-eslint/no-unsafe-enum-assignment': "error";
|
|
98
99
|
'@typescript-eslint/no-unsafe-enum-comparison': "error";
|
|
@@ -200,6 +201,7 @@ declare const _default: {
|
|
|
200
201
|
'@typescript-eslint/no-unsafe-argument': "off";
|
|
201
202
|
'@typescript-eslint/no-unsafe-assignment': "off";
|
|
202
203
|
'@typescript-eslint/no-unsafe-call': "off";
|
|
204
|
+
'@typescript-eslint/no-unsafe-class-instance-assignment': "off";
|
|
203
205
|
'@typescript-eslint/no-unsafe-enum-assignment': "off";
|
|
204
206
|
'@typescript-eslint/no-unsafe-enum-comparison': "off";
|
|
205
207
|
'@typescript-eslint/no-unsafe-member-access': "off";
|
|
@@ -499,6 +501,7 @@ declare const _default: {
|
|
|
499
501
|
'@typescript-eslint/no-unsafe-argument': "error";
|
|
500
502
|
'@typescript-eslint/no-unsafe-assignment': "error";
|
|
501
503
|
'@typescript-eslint/no-unsafe-call': "error";
|
|
504
|
+
'@typescript-eslint/no-unsafe-class-instance-assignment': "error";
|
|
502
505
|
'@typescript-eslint/no-unsafe-declaration-merging': "error";
|
|
503
506
|
'@typescript-eslint/no-unsafe-enum-assignment': "error";
|
|
504
507
|
'@typescript-eslint/no-unsafe-enum-comparison': "error";
|
|
@@ -578,6 +581,7 @@ declare const _default: {
|
|
|
578
581
|
'@typescript-eslint/no-unsafe-argument': "error";
|
|
579
582
|
'@typescript-eslint/no-unsafe-assignment': "error";
|
|
580
583
|
'@typescript-eslint/no-unsafe-call': "error";
|
|
584
|
+
'@typescript-eslint/no-unsafe-class-instance-assignment': "error";
|
|
581
585
|
'@typescript-eslint/no-unsafe-enum-assignment': "error";
|
|
582
586
|
'@typescript-eslint/no-unsafe-enum-comparison': "error";
|
|
583
587
|
'@typescript-eslint/no-unsafe-member-access': "error";
|
|
@@ -681,6 +685,6 @@ declare const _default: {
|
|
|
681
685
|
namespace: string;
|
|
682
686
|
version: string;
|
|
683
687
|
};
|
|
684
|
-
rules: Record<"adjacent-overload-signatures" | "array-type" | "await-thenable" | "ban-ts-comment" | "ban-tslint-comment" | "class-literal-property-style" | "class-methods-use-this" | "consistent-generic-constructors" | "consistent-indexed-object-style" | "consistent-return" | "consistent-type-assertions" | "consistent-type-definitions" | "consistent-type-exports" | "consistent-type-imports" | "default-param-last" | "dot-notation" | "explicit-function-return-type" | "explicit-member-accessibility" | "explicit-module-boundary-types" | "init-declarations" | "max-params" | "member-ordering" | "method-signature-style" | "naming-convention" | "no-array-constructor" | "no-array-delete" | "no-base-to-string" | "no-confusing-non-null-assertion" | "no-confusing-void-expression" | "no-deprecated" | "no-dupe-class-members" | "no-duplicate-enum-values" | "no-duplicate-type-constituents" | "no-dynamic-delete" | "no-empty-function" | "no-empty-interface" | "no-empty-object-type" | "no-explicit-any" | "no-extra-non-null-assertion" | "no-extraneous-class" | "no-floating-promises" | "no-for-in-array" | "no-generated-empty-object-type" | "no-implied-eval" | "no-import-type-side-effects" | "no-inferrable-types" | "no-invalid-this" | "no-invalid-void-type" | "no-loop-func" | "no-loss-of-precision" | "no-magic-numbers" | "no-meaningless-void-operator" | "no-misused-new" | "no-misused-promises" | "no-misused-spread" | "no-mixed-enums" | "no-namespace" | "no-non-null-asserted-nullish-coalescing" | "no-non-null-asserted-optional-chain" | "no-non-null-assertion" | "no-redeclare" | "no-redundant-type-constituents" | "no-require-imports" | "no-restricted-imports" | "no-restricted-types" | "no-shadow" | "no-this-alias" | "no-type-alias" | "no-unnecessary-boolean-literal-compare" | "no-unnecessary-condition" | "no-unnecessary-parameter-property-assignment" | "no-unnecessary-qualifier" | "no-unnecessary-template-expression" | "no-unnecessary-type-arguments" | "no-unnecessary-type-assertion" | "no-unnecessary-type-constraint" | "no-unnecessary-type-conversion" | "no-unnecessary-type-parameters" | "no-unsafe-argument" | "no-unsafe-assignment" | "no-unsafe-call" | "no-unsafe-declaration-merging" | "no-unsafe-enum-assignment" | "no-unsafe-enum-comparison" | "no-unsafe-function-type" | "no-unsafe-member-access" | "no-unsafe-return" | "no-unsafe-type-assertion" | "no-unsafe-unary-minus" | "no-unused-expressions" | "no-unused-private-class-members" | "no-unused-vars" | "no-use-before-define" | "no-useless-constructor" | "no-useless-default-assignment" | "no-useless-empty-export" | "no-var-requires" | "no-wrapper-object-types" | "non-nullable-type-assertion-style" | "only-throw-error" | "parameter-properties" | "prefer-as-const" | "prefer-destructuring" | "prefer-enum-initializers" | "prefer-find" | "prefer-for-of" | "prefer-function-type" | "prefer-includes" | "prefer-literal-enum-member" | "prefer-namespace-keyword" | "prefer-nullish-coalescing" | "prefer-optional-chain" | "prefer-promise-reject-errors" | "prefer-readonly" | "prefer-readonly-parameter-types" | "prefer-reduce-type-parameter" | "prefer-regexp-exec" | "prefer-return-this-type" | "prefer-string-starts-ends-with" | "prefer-ts-expect-error" | "promise-function-async" | "related-getter-setter-pairs" | "require-array-sort-compare" | "require-await" | "restrict-plus-operands" | "restrict-template-expressions" | "return-await" | "sort-type-constituents" | "strict-boolean-expressions" | "strict-void-return" | "switch-exhaustiveness-check" | "triple-slash-reference" | "typedef" | "unbound-method" | "unified-signatures" | "use-unknown-in-catch-callback-variable", import("../rules").ESLintPluginRuleModule>;
|
|
688
|
+
rules: Record<"adjacent-overload-signatures" | "array-type" | "await-thenable" | "ban-ts-comment" | "ban-tslint-comment" | "class-literal-property-style" | "class-methods-use-this" | "consistent-generic-constructors" | "consistent-indexed-object-style" | "consistent-return" | "consistent-type-assertions" | "consistent-type-definitions" | "consistent-type-exports" | "consistent-type-imports" | "default-param-last" | "dot-notation" | "explicit-function-return-type" | "explicit-member-accessibility" | "explicit-module-boundary-types" | "init-declarations" | "max-params" | "member-ordering" | "method-signature-style" | "naming-convention" | "no-array-constructor" | "no-array-delete" | "no-base-to-string" | "no-confusing-non-null-assertion" | "no-confusing-void-expression" | "no-deprecated" | "no-dupe-class-members" | "no-duplicate-enum-values" | "no-duplicate-type-constituents" | "no-dynamic-delete" | "no-empty-function" | "no-empty-interface" | "no-empty-object-type" | "no-explicit-any" | "no-extra-non-null-assertion" | "no-extraneous-class" | "no-floating-promises" | "no-for-in-array" | "no-generated-empty-object-type" | "no-implied-eval" | "no-import-type-side-effects" | "no-inferrable-types" | "no-invalid-this" | "no-invalid-void-type" | "no-loop-func" | "no-loss-of-precision" | "no-magic-numbers" | "no-meaningless-void-operator" | "no-misused-new" | "no-misused-promises" | "no-misused-spread" | "no-mixed-enums" | "no-namespace" | "no-non-null-asserted-nullish-coalescing" | "no-non-null-asserted-optional-chain" | "no-non-null-assertion" | "no-redeclare" | "no-redundant-type-constituents" | "no-require-imports" | "no-restricted-imports" | "no-restricted-types" | "no-shadow" | "no-this-alias" | "no-type-alias" | "no-unnecessary-boolean-literal-compare" | "no-unnecessary-condition" | "no-unnecessary-parameter-property-assignment" | "no-unnecessary-qualifier" | "no-unnecessary-template-expression" | "no-unnecessary-type-arguments" | "no-unnecessary-type-assertion" | "no-unnecessary-type-constraint" | "no-unnecessary-type-conversion" | "no-unnecessary-type-parameters" | "no-unsafe-argument" | "no-unsafe-assignment" | "no-unsafe-call" | "no-unsafe-class-instance-assignment" | "no-unsafe-declaration-merging" | "no-unsafe-enum-assignment" | "no-unsafe-enum-comparison" | "no-unsafe-function-type" | "no-unsafe-member-access" | "no-unsafe-return" | "no-unsafe-type-assertion" | "no-unsafe-unary-minus" | "no-unused-expressions" | "no-unused-private-class-members" | "no-unused-vars" | "no-use-before-define" | "no-useless-constructor" | "no-useless-default-assignment" | "no-useless-empty-export" | "no-var-requires" | "no-wrapper-object-types" | "non-nullable-type-assertion-style" | "only-throw-error" | "parameter-properties" | "prefer-as-const" | "prefer-destructuring" | "prefer-enum-initializers" | "prefer-find" | "prefer-for-of" | "prefer-function-type" | "prefer-includes" | "prefer-literal-enum-member" | "prefer-namespace-keyword" | "prefer-nullish-coalescing" | "prefer-optional-chain" | "prefer-promise-reject-errors" | "prefer-readonly" | "prefer-readonly-parameter-types" | "prefer-reduce-type-parameter" | "prefer-regexp-exec" | "prefer-return-this-type" | "prefer-string-starts-ends-with" | "prefer-ts-expect-error" | "promise-function-async" | "related-getter-setter-pairs" | "require-array-sort-compare" | "require-await" | "restrict-plus-operands" | "restrict-template-expressions" | "return-await" | "sort-type-constituents" | "strict-boolean-expressions" | "strict-void-return" | "switch-exhaustiveness-check" | "triple-slash-reference" | "typedef" | "unbound-method" | "unified-signatures" | "use-unknown-in-catch-callback-variable", import("../rules").ESLintPluginRuleModule>;
|
|
685
689
|
};
|
|
686
690
|
export = _default;
|
package/dist/raw-plugin.d.ts
CHANGED
|
@@ -115,6 +115,7 @@ declare const _default: {
|
|
|
115
115
|
'@typescript-eslint/no-unsafe-argument': "error";
|
|
116
116
|
'@typescript-eslint/no-unsafe-assignment': "error";
|
|
117
117
|
'@typescript-eslint/no-unsafe-call': "error";
|
|
118
|
+
'@typescript-eslint/no-unsafe-class-instance-assignment': "error";
|
|
118
119
|
'@typescript-eslint/no-unsafe-declaration-merging': "error";
|
|
119
120
|
'@typescript-eslint/no-unsafe-enum-assignment': "error";
|
|
120
121
|
'@typescript-eslint/no-unsafe-enum-comparison': "error";
|
|
@@ -222,6 +223,7 @@ declare const _default: {
|
|
|
222
223
|
'@typescript-eslint/no-unsafe-argument': "off";
|
|
223
224
|
'@typescript-eslint/no-unsafe-assignment': "off";
|
|
224
225
|
'@typescript-eslint/no-unsafe-call': "off";
|
|
226
|
+
'@typescript-eslint/no-unsafe-class-instance-assignment': "off";
|
|
225
227
|
'@typescript-eslint/no-unsafe-enum-assignment': "off";
|
|
226
228
|
'@typescript-eslint/no-unsafe-enum-comparison': "off";
|
|
227
229
|
'@typescript-eslint/no-unsafe-member-access': "off";
|
|
@@ -522,6 +524,7 @@ declare const _default: {
|
|
|
522
524
|
'@typescript-eslint/no-unsafe-argument': "error";
|
|
523
525
|
'@typescript-eslint/no-unsafe-assignment': "error";
|
|
524
526
|
'@typescript-eslint/no-unsafe-call': "error";
|
|
527
|
+
'@typescript-eslint/no-unsafe-class-instance-assignment': "error";
|
|
525
528
|
'@typescript-eslint/no-unsafe-declaration-merging': "error";
|
|
526
529
|
'@typescript-eslint/no-unsafe-enum-assignment': "error";
|
|
527
530
|
'@typescript-eslint/no-unsafe-enum-comparison': "error";
|
|
@@ -601,6 +604,7 @@ declare const _default: {
|
|
|
601
604
|
'@typescript-eslint/no-unsafe-argument': "error";
|
|
602
605
|
'@typescript-eslint/no-unsafe-assignment': "error";
|
|
603
606
|
'@typescript-eslint/no-unsafe-call': "error";
|
|
607
|
+
'@typescript-eslint/no-unsafe-class-instance-assignment': "error";
|
|
604
608
|
'@typescript-eslint/no-unsafe-enum-assignment': "error";
|
|
605
609
|
'@typescript-eslint/no-unsafe-enum-comparison': "error";
|
|
606
610
|
'@typescript-eslint/no-unsafe-member-access': "error";
|
|
@@ -704,7 +708,7 @@ declare const _default: {
|
|
|
704
708
|
namespace: string;
|
|
705
709
|
version: string;
|
|
706
710
|
};
|
|
707
|
-
rules: Record<"adjacent-overload-signatures" | "array-type" | "await-thenable" | "ban-ts-comment" | "ban-tslint-comment" | "class-literal-property-style" | "class-methods-use-this" | "consistent-generic-constructors" | "consistent-indexed-object-style" | "consistent-return" | "consistent-type-assertions" | "consistent-type-definitions" | "consistent-type-exports" | "consistent-type-imports" | "default-param-last" | "dot-notation" | "explicit-function-return-type" | "explicit-member-accessibility" | "explicit-module-boundary-types" | "init-declarations" | "max-params" | "member-ordering" | "method-signature-style" | "naming-convention" | "no-array-constructor" | "no-array-delete" | "no-base-to-string" | "no-confusing-non-null-assertion" | "no-confusing-void-expression" | "no-deprecated" | "no-dupe-class-members" | "no-duplicate-enum-values" | "no-duplicate-type-constituents" | "no-dynamic-delete" | "no-empty-function" | "no-empty-interface" | "no-empty-object-type" | "no-explicit-any" | "no-extra-non-null-assertion" | "no-extraneous-class" | "no-floating-promises" | "no-for-in-array" | "no-generated-empty-object-type" | "no-implied-eval" | "no-import-type-side-effects" | "no-inferrable-types" | "no-invalid-this" | "no-invalid-void-type" | "no-loop-func" | "no-loss-of-precision" | "no-magic-numbers" | "no-meaningless-void-operator" | "no-misused-new" | "no-misused-promises" | "no-misused-spread" | "no-mixed-enums" | "no-namespace" | "no-non-null-asserted-nullish-coalescing" | "no-non-null-asserted-optional-chain" | "no-non-null-assertion" | "no-redeclare" | "no-redundant-type-constituents" | "no-require-imports" | "no-restricted-imports" | "no-restricted-types" | "no-shadow" | "no-this-alias" | "no-type-alias" | "no-unnecessary-boolean-literal-compare" | "no-unnecessary-condition" | "no-unnecessary-parameter-property-assignment" | "no-unnecessary-qualifier" | "no-unnecessary-template-expression" | "no-unnecessary-type-arguments" | "no-unnecessary-type-assertion" | "no-unnecessary-type-constraint" | "no-unnecessary-type-conversion" | "no-unnecessary-type-parameters" | "no-unsafe-argument" | "no-unsafe-assignment" | "no-unsafe-call" | "no-unsafe-declaration-merging" | "no-unsafe-enum-assignment" | "no-unsafe-enum-comparison" | "no-unsafe-function-type" | "no-unsafe-member-access" | "no-unsafe-return" | "no-unsafe-type-assertion" | "no-unsafe-unary-minus" | "no-unused-expressions" | "no-unused-private-class-members" | "no-unused-vars" | "no-use-before-define" | "no-useless-constructor" | "no-useless-default-assignment" | "no-useless-empty-export" | "no-var-requires" | "no-wrapper-object-types" | "non-nullable-type-assertion-style" | "only-throw-error" | "parameter-properties" | "prefer-as-const" | "prefer-destructuring" | "prefer-enum-initializers" | "prefer-find" | "prefer-for-of" | "prefer-function-type" | "prefer-includes" | "prefer-literal-enum-member" | "prefer-namespace-keyword" | "prefer-nullish-coalescing" | "prefer-optional-chain" | "prefer-promise-reject-errors" | "prefer-readonly" | "prefer-readonly-parameter-types" | "prefer-reduce-type-parameter" | "prefer-regexp-exec" | "prefer-return-this-type" | "prefer-string-starts-ends-with" | "prefer-ts-expect-error" | "promise-function-async" | "related-getter-setter-pairs" | "require-array-sort-compare" | "require-await" | "restrict-plus-operands" | "restrict-template-expressions" | "return-await" | "sort-type-constituents" | "strict-boolean-expressions" | "strict-void-return" | "switch-exhaustiveness-check" | "triple-slash-reference" | "typedef" | "unbound-method" | "unified-signatures" | "use-unknown-in-catch-callback-variable", import("../rules").ESLintPluginRuleModule>;
|
|
711
|
+
rules: Record<"adjacent-overload-signatures" | "array-type" | "await-thenable" | "ban-ts-comment" | "ban-tslint-comment" | "class-literal-property-style" | "class-methods-use-this" | "consistent-generic-constructors" | "consistent-indexed-object-style" | "consistent-return" | "consistent-type-assertions" | "consistent-type-definitions" | "consistent-type-exports" | "consistent-type-imports" | "default-param-last" | "dot-notation" | "explicit-function-return-type" | "explicit-member-accessibility" | "explicit-module-boundary-types" | "init-declarations" | "max-params" | "member-ordering" | "method-signature-style" | "naming-convention" | "no-array-constructor" | "no-array-delete" | "no-base-to-string" | "no-confusing-non-null-assertion" | "no-confusing-void-expression" | "no-deprecated" | "no-dupe-class-members" | "no-duplicate-enum-values" | "no-duplicate-type-constituents" | "no-dynamic-delete" | "no-empty-function" | "no-empty-interface" | "no-empty-object-type" | "no-explicit-any" | "no-extra-non-null-assertion" | "no-extraneous-class" | "no-floating-promises" | "no-for-in-array" | "no-generated-empty-object-type" | "no-implied-eval" | "no-import-type-side-effects" | "no-inferrable-types" | "no-invalid-this" | "no-invalid-void-type" | "no-loop-func" | "no-loss-of-precision" | "no-magic-numbers" | "no-meaningless-void-operator" | "no-misused-new" | "no-misused-promises" | "no-misused-spread" | "no-mixed-enums" | "no-namespace" | "no-non-null-asserted-nullish-coalescing" | "no-non-null-asserted-optional-chain" | "no-non-null-assertion" | "no-redeclare" | "no-redundant-type-constituents" | "no-require-imports" | "no-restricted-imports" | "no-restricted-types" | "no-shadow" | "no-this-alias" | "no-type-alias" | "no-unnecessary-boolean-literal-compare" | "no-unnecessary-condition" | "no-unnecessary-parameter-property-assignment" | "no-unnecessary-qualifier" | "no-unnecessary-template-expression" | "no-unnecessary-type-arguments" | "no-unnecessary-type-assertion" | "no-unnecessary-type-constraint" | "no-unnecessary-type-conversion" | "no-unnecessary-type-parameters" | "no-unsafe-argument" | "no-unsafe-assignment" | "no-unsafe-call" | "no-unsafe-class-instance-assignment" | "no-unsafe-declaration-merging" | "no-unsafe-enum-assignment" | "no-unsafe-enum-comparison" | "no-unsafe-function-type" | "no-unsafe-member-access" | "no-unsafe-return" | "no-unsafe-type-assertion" | "no-unsafe-unary-minus" | "no-unused-expressions" | "no-unused-private-class-members" | "no-unused-vars" | "no-use-before-define" | "no-useless-constructor" | "no-useless-default-assignment" | "no-useless-empty-export" | "no-var-requires" | "no-wrapper-object-types" | "non-nullable-type-assertion-style" | "only-throw-error" | "parameter-properties" | "prefer-as-const" | "prefer-destructuring" | "prefer-enum-initializers" | "prefer-find" | "prefer-for-of" | "prefer-function-type" | "prefer-includes" | "prefer-literal-enum-member" | "prefer-namespace-keyword" | "prefer-nullish-coalescing" | "prefer-optional-chain" | "prefer-promise-reject-errors" | "prefer-readonly" | "prefer-readonly-parameter-types" | "prefer-reduce-type-parameter" | "prefer-regexp-exec" | "prefer-return-this-type" | "prefer-string-starts-ends-with" | "prefer-ts-expect-error" | "promise-function-async" | "related-getter-setter-pairs" | "require-array-sort-compare" | "require-await" | "restrict-plus-operands" | "restrict-template-expressions" | "return-await" | "sort-type-constituents" | "strict-boolean-expressions" | "strict-void-return" | "switch-exhaustiveness-check" | "triple-slash-reference" | "typedef" | "unbound-method" | "unified-signatures" | "use-unknown-in-catch-callback-variable", import("../rules").ESLintPluginRuleModule>;
|
|
708
712
|
};
|
|
709
713
|
};
|
|
710
714
|
export = _default;
|
|
@@ -281,28 +281,22 @@ exports.default = (0, util_1.createRule)({
|
|
|
281
281
|
else {
|
|
282
282
|
// we have a mixed type/value import or just value imports, so we need to split them out into multiple imports if separate-type-imports is configured
|
|
283
283
|
const importNames = report.typeSpecifiers.map(specifier => `"${specifier.local.name}"`);
|
|
284
|
-
const
|
|
285
|
-
|
|
286
|
-
if (importNames.length === 1) {
|
|
287
|
-
return {
|
|
288
|
-
messageId: 'someImportsAreOnlyTypes',
|
|
289
|
-
data: {
|
|
290
|
-
typeImports,
|
|
291
|
-
},
|
|
292
|
-
};
|
|
293
|
-
}
|
|
294
|
-
return {
|
|
295
|
-
messageId: 'someImportsAreOnlyTypes',
|
|
296
|
-
data: {
|
|
297
|
-
typeImports,
|
|
298
|
-
},
|
|
299
|
-
};
|
|
300
|
-
})();
|
|
284
|
+
const firstTypeSpecifier = report.typeSpecifiers[0];
|
|
285
|
+
const lastTypeSpecifier = report.typeSpecifiers[report.typeSpecifiers.length - 1];
|
|
301
286
|
context.report({
|
|
302
|
-
|
|
303
|
-
|
|
287
|
+
loc: report.node.specifiers.indexOf(lastTypeSpecifier) -
|
|
288
|
+
report.node.specifiers.indexOf(firstTypeSpecifier) ===
|
|
289
|
+
report.typeSpecifiers.length - 1
|
|
290
|
+
? {
|
|
291
|
+
start: firstTypeSpecifier.loc.start,
|
|
292
|
+
end: lastTypeSpecifier.loc.end,
|
|
293
|
+
}
|
|
294
|
+
: report.node.loc,
|
|
295
|
+
messageId: 'someImportsAreOnlyTypes',
|
|
296
|
+
data: {
|
|
297
|
+
typeImports: (0, util_1.formatWordList)(importNames),
|
|
298
|
+
},
|
|
304
299
|
*fix(fixer) {
|
|
305
|
-
// take all the typeSpecifiers and put them on a new line
|
|
306
300
|
yield* fixToTypeImportDeclaration(fixer, report, sourceImports);
|
|
307
301
|
},
|
|
308
302
|
});
|
package/dist/rules/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const rules: Record<"adjacent-overload-signatures" | "array-type" | "await-thenable" | "ban-ts-comment" | "ban-tslint-comment" | "class-literal-property-style" | "class-methods-use-this" | "consistent-generic-constructors" | "consistent-indexed-object-style" | "consistent-return" | "consistent-type-assertions" | "consistent-type-definitions" | "consistent-type-exports" | "consistent-type-imports" | "default-param-last" | "dot-notation" | "explicit-function-return-type" | "explicit-member-accessibility" | "explicit-module-boundary-types" | "init-declarations" | "max-params" | "member-ordering" | "method-signature-style" | "naming-convention" | "no-array-constructor" | "no-array-delete" | "no-base-to-string" | "no-confusing-non-null-assertion" | "no-confusing-void-expression" | "no-deprecated" | "no-dupe-class-members" | "no-duplicate-enum-values" | "no-duplicate-type-constituents" | "no-dynamic-delete" | "no-empty-function" | "no-empty-interface" | "no-empty-object-type" | "no-explicit-any" | "no-extra-non-null-assertion" | "no-extraneous-class" | "no-floating-promises" | "no-for-in-array" | "no-generated-empty-object-type" | "no-implied-eval" | "no-import-type-side-effects" | "no-inferrable-types" | "no-invalid-this" | "no-invalid-void-type" | "no-loop-func" | "no-loss-of-precision" | "no-magic-numbers" | "no-meaningless-void-operator" | "no-misused-new" | "no-misused-promises" | "no-misused-spread" | "no-mixed-enums" | "no-namespace" | "no-non-null-asserted-nullish-coalescing" | "no-non-null-asserted-optional-chain" | "no-non-null-assertion" | "no-redeclare" | "no-redundant-type-constituents" | "no-require-imports" | "no-restricted-imports" | "no-restricted-types" | "no-shadow" | "no-this-alias" | "no-type-alias" | "no-unnecessary-boolean-literal-compare" | "no-unnecessary-condition" | "no-unnecessary-parameter-property-assignment" | "no-unnecessary-qualifier" | "no-unnecessary-template-expression" | "no-unnecessary-type-arguments" | "no-unnecessary-type-assertion" | "no-unnecessary-type-constraint" | "no-unnecessary-type-conversion" | "no-unnecessary-type-parameters" | "no-unsafe-argument" | "no-unsafe-assignment" | "no-unsafe-call" | "no-unsafe-declaration-merging" | "no-unsafe-enum-assignment" | "no-unsafe-enum-comparison" | "no-unsafe-function-type" | "no-unsafe-member-access" | "no-unsafe-return" | "no-unsafe-type-assertion" | "no-unsafe-unary-minus" | "no-unused-expressions" | "no-unused-private-class-members" | "no-unused-vars" | "no-use-before-define" | "no-useless-constructor" | "no-useless-default-assignment" | "no-useless-empty-export" | "no-var-requires" | "no-wrapper-object-types" | "non-nullable-type-assertion-style" | "only-throw-error" | "parameter-properties" | "prefer-as-const" | "prefer-destructuring" | "prefer-enum-initializers" | "prefer-find" | "prefer-for-of" | "prefer-function-type" | "prefer-includes" | "prefer-literal-enum-member" | "prefer-namespace-keyword" | "prefer-nullish-coalescing" | "prefer-optional-chain" | "prefer-promise-reject-errors" | "prefer-readonly" | "prefer-readonly-parameter-types" | "prefer-reduce-type-parameter" | "prefer-regexp-exec" | "prefer-return-this-type" | "prefer-string-starts-ends-with" | "prefer-ts-expect-error" | "promise-function-async" | "related-getter-setter-pairs" | "require-array-sort-compare" | "require-await" | "restrict-plus-operands" | "restrict-template-expressions" | "return-await" | "sort-type-constituents" | "strict-boolean-expressions" | "strict-void-return" | "switch-exhaustiveness-check" | "triple-slash-reference" | "typedef" | "unbound-method" | "unified-signatures" | "use-unknown-in-catch-callback-variable", import("../../rules").ESLintPluginRuleModule>;
|
|
1
|
+
declare const rules: Record<"adjacent-overload-signatures" | "array-type" | "await-thenable" | "ban-ts-comment" | "ban-tslint-comment" | "class-literal-property-style" | "class-methods-use-this" | "consistent-generic-constructors" | "consistent-indexed-object-style" | "consistent-return" | "consistent-type-assertions" | "consistent-type-definitions" | "consistent-type-exports" | "consistent-type-imports" | "default-param-last" | "dot-notation" | "explicit-function-return-type" | "explicit-member-accessibility" | "explicit-module-boundary-types" | "init-declarations" | "max-params" | "member-ordering" | "method-signature-style" | "naming-convention" | "no-array-constructor" | "no-array-delete" | "no-base-to-string" | "no-confusing-non-null-assertion" | "no-confusing-void-expression" | "no-deprecated" | "no-dupe-class-members" | "no-duplicate-enum-values" | "no-duplicate-type-constituents" | "no-dynamic-delete" | "no-empty-function" | "no-empty-interface" | "no-empty-object-type" | "no-explicit-any" | "no-extra-non-null-assertion" | "no-extraneous-class" | "no-floating-promises" | "no-for-in-array" | "no-generated-empty-object-type" | "no-implied-eval" | "no-import-type-side-effects" | "no-inferrable-types" | "no-invalid-this" | "no-invalid-void-type" | "no-loop-func" | "no-loss-of-precision" | "no-magic-numbers" | "no-meaningless-void-operator" | "no-misused-new" | "no-misused-promises" | "no-misused-spread" | "no-mixed-enums" | "no-namespace" | "no-non-null-asserted-nullish-coalescing" | "no-non-null-asserted-optional-chain" | "no-non-null-assertion" | "no-redeclare" | "no-redundant-type-constituents" | "no-require-imports" | "no-restricted-imports" | "no-restricted-types" | "no-shadow" | "no-this-alias" | "no-type-alias" | "no-unnecessary-boolean-literal-compare" | "no-unnecessary-condition" | "no-unnecessary-parameter-property-assignment" | "no-unnecessary-qualifier" | "no-unnecessary-template-expression" | "no-unnecessary-type-arguments" | "no-unnecessary-type-assertion" | "no-unnecessary-type-constraint" | "no-unnecessary-type-conversion" | "no-unnecessary-type-parameters" | "no-unsafe-argument" | "no-unsafe-assignment" | "no-unsafe-call" | "no-unsafe-class-instance-assignment" | "no-unsafe-declaration-merging" | "no-unsafe-enum-assignment" | "no-unsafe-enum-comparison" | "no-unsafe-function-type" | "no-unsafe-member-access" | "no-unsafe-return" | "no-unsafe-type-assertion" | "no-unsafe-unary-minus" | "no-unused-expressions" | "no-unused-private-class-members" | "no-unused-vars" | "no-use-before-define" | "no-useless-constructor" | "no-useless-default-assignment" | "no-useless-empty-export" | "no-var-requires" | "no-wrapper-object-types" | "non-nullable-type-assertion-style" | "only-throw-error" | "parameter-properties" | "prefer-as-const" | "prefer-destructuring" | "prefer-enum-initializers" | "prefer-find" | "prefer-for-of" | "prefer-function-type" | "prefer-includes" | "prefer-literal-enum-member" | "prefer-namespace-keyword" | "prefer-nullish-coalescing" | "prefer-optional-chain" | "prefer-promise-reject-errors" | "prefer-readonly" | "prefer-readonly-parameter-types" | "prefer-reduce-type-parameter" | "prefer-regexp-exec" | "prefer-return-this-type" | "prefer-string-starts-ends-with" | "prefer-ts-expect-error" | "promise-function-async" | "related-getter-setter-pairs" | "require-array-sort-compare" | "require-await" | "restrict-plus-operands" | "restrict-template-expressions" | "return-await" | "sort-type-constituents" | "strict-boolean-expressions" | "strict-void-return" | "switch-exhaustiveness-check" | "triple-slash-reference" | "typedef" | "unbound-method" | "unified-signatures" | "use-unknown-in-catch-callback-variable", import("../../rules").ESLintPluginRuleModule>;
|
|
2
2
|
export = rules;
|
package/dist/rules/index.js
CHANGED
|
@@ -83,6 +83,7 @@ const rules = (0, lazyRules_1.lazyRules)({
|
|
|
83
83
|
'no-unsafe-argument': () => require('./no-unsafe-argument'),
|
|
84
84
|
'no-unsafe-assignment': () => require('./no-unsafe-assignment'),
|
|
85
85
|
'no-unsafe-call': () => require('./no-unsafe-call'),
|
|
86
|
+
'no-unsafe-class-instance-assignment': () => require('./no-unsafe-class-instance-assignment'),
|
|
86
87
|
'no-unsafe-declaration-merging': () => require('./no-unsafe-declaration-merging'),
|
|
87
88
|
'no-unsafe-enum-assignment': () => require('./no-unsafe-enum-assignment'),
|
|
88
89
|
'no-unsafe-enum-comparison': () => require('./no-unsafe-enum-comparison'),
|
|
@@ -304,12 +304,12 @@ exports.default = (0, util_1.createRule)({
|
|
|
304
304
|
if (uncastProps.length !== castProps.length) {
|
|
305
305
|
return false;
|
|
306
306
|
}
|
|
307
|
-
const
|
|
307
|
+
const castPropsByName = new Map(castProps.map(p => [p.getEscapedName(), p]));
|
|
308
308
|
return uncastProps.every(prop => {
|
|
309
|
-
const
|
|
310
|
-
return (
|
|
311
|
-
|
|
312
|
-
|
|
309
|
+
const castProp = castPropsByName.get(prop.getEscapedName());
|
|
310
|
+
return (castProp != null &&
|
|
311
|
+
(0, util_1.isPropertyReadonlyInType)(uncast, prop, checker) ===
|
|
312
|
+
(0, util_1.isPropertyReadonlyInType)(cast, castProp, checker));
|
|
313
313
|
});
|
|
314
314
|
}
|
|
315
315
|
function haveSameTypeArguments(uncast, cast) {
|
|
@@ -0,0 +1,276 @@
|
|
|
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-unsafe-class-instance-assignment',
|
|
42
|
+
meta: {
|
|
43
|
+
type: 'problem',
|
|
44
|
+
docs: {
|
|
45
|
+
description: 'Disallow assigning non-instance values to class instance typed locations',
|
|
46
|
+
recommended: 'strict',
|
|
47
|
+
requiresTypeChecking: true,
|
|
48
|
+
},
|
|
49
|
+
messages: {
|
|
50
|
+
nonInstance: 'This value is used where an instance of class `{{type}}` is expected, but was not created by its constructor.',
|
|
51
|
+
objectLiteral: 'This object literal is used where an instance of class `{{type}}` is expected.',
|
|
52
|
+
},
|
|
53
|
+
schema: [],
|
|
54
|
+
},
|
|
55
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- For compatibility with ESLint 8, see #12842
|
|
56
|
+
defaultOptions: [],
|
|
57
|
+
create(context) {
|
|
58
|
+
const services = (0, util_1.getParserServices)(context);
|
|
59
|
+
const checker = services.program.getTypeChecker();
|
|
60
|
+
function getClassTarget(type) {
|
|
61
|
+
if (!tsutils.isObjectType(type)) {
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
const target = tsutils.isTypeReference(type) ? type.target : type;
|
|
65
|
+
return tsutils.isObjectFlagSet(target, ts.ObjectFlags.Class)
|
|
66
|
+
? target
|
|
67
|
+
: undefined;
|
|
68
|
+
}
|
|
69
|
+
function getNominalClass(type) {
|
|
70
|
+
let found;
|
|
71
|
+
(0, util_1.matchesTypeOrBaseType)(services, candidate => {
|
|
72
|
+
if (getClassTarget(candidate)) {
|
|
73
|
+
found = candidate;
|
|
74
|
+
}
|
|
75
|
+
return !!found;
|
|
76
|
+
}, type);
|
|
77
|
+
return found;
|
|
78
|
+
}
|
|
79
|
+
function resolveConstraint(type) {
|
|
80
|
+
return tsutils.isTypeFlagSet(type, ts.TypeFlags.Instantiable)
|
|
81
|
+
? checker.getBaseConstraintOfType(type)
|
|
82
|
+
: type;
|
|
83
|
+
}
|
|
84
|
+
function containsClass(type, seen = new Set()) {
|
|
85
|
+
if (seen.has(type)) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
seen.add(type);
|
|
89
|
+
const resolved = resolveConstraint(type);
|
|
90
|
+
if (!resolved) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
if (tsutils.isUnionOrIntersectionType(resolved)) {
|
|
94
|
+
return resolved.types.some(part => containsClass(part, seen));
|
|
95
|
+
}
|
|
96
|
+
return (!!getNominalClass(resolved) ||
|
|
97
|
+
(tsutils.isTypeReference(resolved) &&
|
|
98
|
+
checker
|
|
99
|
+
.getTypeArguments(resolved)
|
|
100
|
+
.some(typeArgument => containsClass(typeArgument, seen))) ||
|
|
101
|
+
checker
|
|
102
|
+
.getIndexInfosOfType(resolved)
|
|
103
|
+
.some(indexInfo => containsClass(indexInfo.type, seen)));
|
|
104
|
+
}
|
|
105
|
+
function isInstanceOf(source, classType) {
|
|
106
|
+
const classTarget = getClassTarget(classType);
|
|
107
|
+
return tsutils
|
|
108
|
+
.intersectionConstituents(source)
|
|
109
|
+
.some(part => (tsutils.isObjectType(part) &&
|
|
110
|
+
tsutils.isObjectFlagSet(part, ts.ObjectFlags.Mapped)) ||
|
|
111
|
+
(0, util_1.matchesTypeOrBaseType)(services, type => getClassTarget(type) === classTarget, part));
|
|
112
|
+
}
|
|
113
|
+
function findFirstViolation(items, find) {
|
|
114
|
+
for (const [i, item] of items.entries()) {
|
|
115
|
+
const violation = find(item, i);
|
|
116
|
+
if (violation) {
|
|
117
|
+
return violation;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return undefined;
|
|
121
|
+
}
|
|
122
|
+
function findViolation(source, target, shallow) {
|
|
123
|
+
const resolvedSource = resolveConstraint(source);
|
|
124
|
+
const resolvedTarget = resolveConstraint(target);
|
|
125
|
+
if (!resolvedSource ||
|
|
126
|
+
!resolvedTarget ||
|
|
127
|
+
resolvedSource === resolvedTarget ||
|
|
128
|
+
tsutils.isTypeFlagSet(resolvedSource, ts.TypeFlags.Any | ts.TypeFlags.Unknown | ts.TypeFlags.Never) ||
|
|
129
|
+
!containsClass(resolvedTarget)) {
|
|
130
|
+
return undefined;
|
|
131
|
+
}
|
|
132
|
+
if (resolvedSource.isUnion()) {
|
|
133
|
+
return findFirstViolation(resolvedSource.types.filter(part => checker.isTypeAssignableTo(part, resolvedTarget)), part => findViolation(part, resolvedTarget, shallow));
|
|
134
|
+
}
|
|
135
|
+
if (!tsutils.isObjectType(resolvedSource) &&
|
|
136
|
+
!(resolvedSource.isIntersection() &&
|
|
137
|
+
!checker.isTypeAssignableTo(resolvedSource, checker.getNeverType()))) {
|
|
138
|
+
return undefined;
|
|
139
|
+
}
|
|
140
|
+
if (resolvedTarget.isUnion()) {
|
|
141
|
+
const candidates = resolvedTarget.types.filter(part => checker.isTypeAssignableTo(resolvedSource, part));
|
|
142
|
+
if (candidates.length === 0 ||
|
|
143
|
+
candidates.some(candidate => !containsClass(candidate))) {
|
|
144
|
+
return undefined;
|
|
145
|
+
}
|
|
146
|
+
const violations = candidates.map(candidate => findViolation(resolvedSource, candidate, shallow));
|
|
147
|
+
return violations.every(Boolean) ? violations[0] : undefined;
|
|
148
|
+
}
|
|
149
|
+
if (resolvedTarget.isIntersection()) {
|
|
150
|
+
return findFirstViolation(resolvedTarget.types, part => findViolation(resolvedSource, part, shallow));
|
|
151
|
+
}
|
|
152
|
+
const nominalClass = getNominalClass(resolvedTarget);
|
|
153
|
+
if (nominalClass && !isInstanceOf(resolvedSource, nominalClass)) {
|
|
154
|
+
return nominalClass;
|
|
155
|
+
}
|
|
156
|
+
if (shallow) {
|
|
157
|
+
return undefined;
|
|
158
|
+
}
|
|
159
|
+
if (tsutils.isTypeReference(resolvedSource) &&
|
|
160
|
+
tsutils.isTypeReference(resolvedTarget) &&
|
|
161
|
+
resolvedSource.target === resolvedTarget.target) {
|
|
162
|
+
const sourceArguments = checker.getTypeArguments(resolvedSource);
|
|
163
|
+
return findFirstViolation(checker
|
|
164
|
+
.getTypeArguments(resolvedTarget)
|
|
165
|
+
.slice(0, sourceArguments.length), (targetArgument, i) => findViolation(sourceArguments[i], targetArgument, false));
|
|
166
|
+
}
|
|
167
|
+
return findFirstViolation([ts.IndexKind.Number, ts.IndexKind.String], indexKind => {
|
|
168
|
+
const sourceIndexType = checker.getIndexTypeOfType(resolvedSource, indexKind);
|
|
169
|
+
const targetIndexType = checker.getIndexTypeOfType(resolvedTarget, indexKind);
|
|
170
|
+
return (sourceIndexType &&
|
|
171
|
+
targetIndexType &&
|
|
172
|
+
findViolation(sourceIndexType, targetIndexType, false));
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
function checkSite(node) {
|
|
176
|
+
switch (node.type) {
|
|
177
|
+
case utils_1.AST_NODE_TYPES.ArrowFunctionExpression:
|
|
178
|
+
case utils_1.AST_NODE_TYPES.ConditionalExpression:
|
|
179
|
+
case utils_1.AST_NODE_TYPES.FunctionExpression:
|
|
180
|
+
case utils_1.AST_NODE_TYPES.LogicalExpression:
|
|
181
|
+
case utils_1.AST_NODE_TYPES.SequenceExpression:
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
const contextualType = checker.getContextualType(services.esTreeNodeToTSNodeMap.get(node));
|
|
185
|
+
if (!contextualType) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
const isLiteral = node.type === utils_1.AST_NODE_TYPES.ObjectExpression ||
|
|
189
|
+
node.type === utils_1.AST_NODE_TYPES.ArrayExpression;
|
|
190
|
+
const violation = findViolation(services.getTypeAtLocation(node), contextualType, isLiteral);
|
|
191
|
+
if (violation) {
|
|
192
|
+
context.report({
|
|
193
|
+
node,
|
|
194
|
+
messageId: node.type === utils_1.AST_NODE_TYPES.ObjectExpression
|
|
195
|
+
? 'objectLiteral'
|
|
196
|
+
: 'nonInstance',
|
|
197
|
+
data: { type: checker.typeToString(violation) },
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
function checkArguments(node) {
|
|
202
|
+
for (const argument of node.arguments) {
|
|
203
|
+
if (argument.type !== utils_1.AST_NODE_TYPES.SpreadElement) {
|
|
204
|
+
checkSite(argument);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return {
|
|
209
|
+
ArrayExpression(node) {
|
|
210
|
+
for (const element of node.elements) {
|
|
211
|
+
if (element && element.type !== utils_1.AST_NODE_TYPES.SpreadElement) {
|
|
212
|
+
checkSite(element);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
ArrowFunctionExpression(node) {
|
|
217
|
+
if (node.body.type !== utils_1.AST_NODE_TYPES.BlockStatement) {
|
|
218
|
+
checkSite(node.body);
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
AssignmentExpression(node) {
|
|
222
|
+
if (['=', '&&=', '??=', '||='].includes(node.operator)) {
|
|
223
|
+
checkSite(node.right);
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
AssignmentPattern(node) {
|
|
227
|
+
checkSite(node.right);
|
|
228
|
+
},
|
|
229
|
+
CallExpression: checkArguments,
|
|
230
|
+
ConditionalExpression(node) {
|
|
231
|
+
checkSite(node.consequent);
|
|
232
|
+
checkSite(node.alternate);
|
|
233
|
+
},
|
|
234
|
+
JSXExpressionContainer(node) {
|
|
235
|
+
if (node.expression.type !== utils_1.AST_NODE_TYPES.JSXEmptyExpression) {
|
|
236
|
+
checkSite(node.expression);
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
LogicalExpression(node) {
|
|
240
|
+
checkSite(node.left);
|
|
241
|
+
checkSite(node.right);
|
|
242
|
+
},
|
|
243
|
+
NewExpression: checkArguments,
|
|
244
|
+
'Property[parent.type="ObjectExpression"]'(node) {
|
|
245
|
+
checkSite(node.value);
|
|
246
|
+
},
|
|
247
|
+
'PropertyDefinition, AccessorProperty'(node) {
|
|
248
|
+
if (node.value) {
|
|
249
|
+
checkSite(node.value);
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
ReturnStatement(node) {
|
|
253
|
+
if (node.argument) {
|
|
254
|
+
checkSite(node.argument);
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
SequenceExpression(node) {
|
|
258
|
+
checkSite(node.expressions[node.expressions.length - 1]);
|
|
259
|
+
},
|
|
260
|
+
'TSAsExpression, TSSatisfiesExpression, TSTypeAssertion'(node) {
|
|
261
|
+
checkSite(node.expression);
|
|
262
|
+
},
|
|
263
|
+
VariableDeclarator(node) {
|
|
264
|
+
if (node.init) {
|
|
265
|
+
checkSite(node.init);
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
YieldExpression(node) {
|
|
269
|
+
if (node.argument) {
|
|
270
|
+
checkSite(node.argument);
|
|
271
|
+
}
|
|
272
|
+
},
|
|
273
|
+
};
|
|
274
|
+
},
|
|
275
|
+
});
|
|
276
|
+
//# sourceMappingURL=no-unsafe-class-instance-assignment.js.map
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { TSESLint } from '@typescript-eslint/utils';
|
|
2
|
+
import { AST_NODE_TYPES } from '@typescript-eslint/utils';
|
|
2
3
|
export declare const phrases: {
|
|
3
|
-
readonly TSInterfaceDeclaration: 'Interface';
|
|
4
|
-
readonly TSTypeLiteral: 'Type literal';
|
|
4
|
+
readonly [AST_NODE_TYPES.TSInterfaceDeclaration]: 'Interface';
|
|
5
|
+
readonly [AST_NODE_TYPES.TSTypeLiteral]: 'Type literal';
|
|
5
6
|
};
|
|
6
7
|
declare const _default: TSESLint.RuleModule<"functionTypeOverCallableType" | "unexpectedThisOnFunctionOnlyInterface", [], import("../../rules").ESLintPluginDocs, TSESLint.RuleListener> & {
|
|
7
8
|
name: string;
|
package/dist/util/index.d.ts
CHANGED
|
@@ -37,9 +37,6 @@ export * from './skipChainExpression';
|
|
|
37
37
|
export * from './truthinessUtils';
|
|
38
38
|
export * from './walkStatements';
|
|
39
39
|
export * from '@typescript-eslint/type-utils';
|
|
40
|
-
export declare const
|
|
41
|
-
readonly MissingParent: 'Expected node to have a parent.';
|
|
42
|
-
readonly MissingToken: (token: string, thing: string) => string;
|
|
43
|
-
};
|
|
40
|
+
export declare const { applyDefault, deepMerge, getParserServices, isObjectNotArray, nullThrows, NullThrowsReasons, }: typeof ESLintUtils;
|
|
44
41
|
export type InferMessageIdsTypeFromRule<T> = ESLintUtils.InferMessageIdsTypeFromRule<T>;
|
|
45
42
|
export type InferOptionsTypeFromRule<T> = ESLintUtils.InferOptionsTypeFromRule<T>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typescript-eslint/eslint-plugin",
|
|
3
|
-
"version": "8.72.3-alpha.
|
|
3
|
+
"version": "8.72.3-alpha.7",
|
|
4
4
|
"description": "TypeScript plugin for ESLint",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -47,10 +47,10 @@
|
|
|
47
47
|
],
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@eslint-community/regexpp": "^4.12.2",
|
|
50
|
-
"@typescript-eslint/scope-manager": "8.72.3-alpha.
|
|
51
|
-
"@typescript-eslint/type-utils": "8.72.3-alpha.
|
|
52
|
-
"@typescript-eslint/utils": "8.72.3-alpha.
|
|
53
|
-
"@typescript-eslint/visitor-keys": "8.72.3-alpha.
|
|
50
|
+
"@typescript-eslint/scope-manager": "8.72.3-alpha.7",
|
|
51
|
+
"@typescript-eslint/type-utils": "8.72.3-alpha.7",
|
|
52
|
+
"@typescript-eslint/utils": "8.72.3-alpha.7",
|
|
53
|
+
"@typescript-eslint/visitor-keys": "8.72.3-alpha.7",
|
|
54
54
|
"ignore": "^7.0.5",
|
|
55
55
|
"natural-compare": "^1.4.0",
|
|
56
56
|
"ts-api-utils": "^2.5.0"
|
|
@@ -60,9 +60,9 @@
|
|
|
60
60
|
"@types/mdast": "^4.0.4",
|
|
61
61
|
"@types/natural-compare": "^1.4.3",
|
|
62
62
|
"@types/react": "^18.3.21",
|
|
63
|
-
"@typescript-eslint/rule-schema-to-typescript-types": "8.72.3-alpha.
|
|
64
|
-
"@typescript-eslint/rule-tester": "8.72.3-alpha.
|
|
65
|
-
"@typescript/native": "npm:typescript
|
|
63
|
+
"@typescript-eslint/rule-schema-to-typescript-types": "8.72.3-alpha.7",
|
|
64
|
+
"@typescript-eslint/rule-tester": "8.72.3-alpha.7",
|
|
65
|
+
"@typescript/native": "npm:typescript@7.1.0-dev.20261009.1",
|
|
66
66
|
"@vitest/coverage-v8": "^5.0.3",
|
|
67
67
|
"ajv": "^6.12.6",
|
|
68
68
|
"eslint": "^10.0.0",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"vitest": "^5.0.3"
|
|
82
82
|
},
|
|
83
83
|
"peerDependencies": {
|
|
84
|
-
"@typescript-eslint/parser": "^8.72.3-alpha.
|
|
84
|
+
"@typescript-eslint/parser": "^8.72.3-alpha.7",
|
|
85
85
|
"eslint": "^8.57.0 || ^9.0.0 || ^10.0.0",
|
|
86
86
|
"typescript": ">=4.8.4 <6.1.0"
|
|
87
87
|
},
|