@typescript-eslint/eslint-plugin 8.31.2-alpha.7 → 8.32.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.
- package/dist/configs/eslintrc/all.d.ts +1 -0
- package/dist/configs/eslintrc/all.d.ts.map +1 -1
- 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.d.ts.map +1 -1
- package/dist/configs/eslintrc/disable-type-checked.js +1 -0
- package/dist/configs/flat/all.d.ts.map +1 -1
- package/dist/configs/flat/all.js +1 -0
- package/dist/configs/flat/disable-type-checked.d.ts.map +1 -1
- package/dist/configs/flat/disable-type-checked.js +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/raw-plugin.d.ts +3 -0
- package/dist/raw-plugin.d.ts.map +1 -1
- package/dist/rules/adjacent-overload-signatures.js +1 -1
- package/dist/rules/await-thenable.js +2 -2
- package/dist/rules/enum-utils/shared.js +1 -1
- package/dist/rules/explicit-function-return-type.js +2 -2
- package/dist/rules/index.d.ts +1 -0
- package/dist/rules/index.d.ts.map +1 -1
- package/dist/rules/index.js +2 -0
- package/dist/rules/member-ordering.js +1 -1
- package/dist/rules/no-confusing-void-expression.js +3 -3
- package/dist/rules/no-duplicate-enum-values.js +2 -2
- package/dist/rules/no-empty-interface.d.ts.map +1 -1
- package/dist/rules/no-empty-interface.js +2 -2
- package/dist/rules/no-floating-promises.d.ts.map +1 -1
- package/dist/rules/no-floating-promises.js +15 -27
- package/dist/rules/no-meaningless-void-operator.js +1 -1
- package/dist/rules/no-misused-promises.js +8 -8
- package/dist/rules/no-misused-spread.js +2 -2
- package/dist/rules/no-redundant-type-constituents.js +2 -2
- package/dist/rules/no-unnecessary-condition.js +5 -5
- package/dist/rules/no-unnecessary-template-expression.d.ts.map +1 -1
- package/dist/rules/no-unnecessary-template-expression.js +3 -3
- package/dist/rules/no-unnecessary-type-assertion.js +2 -2
- package/dist/rules/no-unnecessary-type-conversion.d.ts +4 -0
- package/dist/rules/no-unnecessary-type-conversion.d.ts.map +1 -0
- package/dist/rules/no-unnecessary-type-conversion.js +307 -0
- package/dist/rules/no-unsafe-assignment.js +1 -1
- package/dist/rules/no-unsafe-enum-comparison.js +4 -4
- package/dist/rules/no-unsafe-unary-minus.js +1 -1
- package/dist/rules/non-nullable-type-assertion-style.js +1 -1
- package/dist/rules/only-throw-error.d.ts +1 -0
- package/dist/rules/only-throw-error.d.ts.map +1 -1
- package/dist/rules/only-throw-error.js +47 -0
- package/dist/rules/prefer-find.js +2 -2
- package/dist/rules/prefer-nullish-coalescing.js +2 -2
- package/dist/rules/prefer-optional-chain-utils/analyzeChain.js +1 -1
- package/dist/rules/prefer-optional-chain-utils/checkNullishAndReport.js +1 -1
- package/dist/rules/prefer-optional-chain-utils/gatherLogicalOperands.js +1 -1
- package/dist/rules/prefer-reduce-type-parameter.js +2 -2
- package/dist/rules/prefer-regexp-exec.js +1 -1
- package/dist/rules/prefer-return-this-type.js +1 -1
- package/dist/rules/restrict-plus-operands.js +4 -4
- package/dist/rules/strict-boolean-expressions.d.ts.map +1 -1
- package/dist/rules/strict-boolean-expressions.js +3 -3
- package/dist/rules/switch-exhaustiveness-check.js +4 -4
- package/dist/rules/unbound-method.d.ts.map +1 -1
- package/dist/rules/unbound-method.js +2 -2
- package/dist/rules/use-unknown-in-catch-callback-variable.js +1 -1
- package/dist/util/getWrappingFixer.d.ts +3 -3
- package/dist/util/getWrappingFixer.d.ts.map +1 -1
- package/dist/util/getWrappingFixer.js +5 -2
- package/dist/util/isArrayMethodCallWithPredicate.js +2 -2
- package/dist/util/promiseUtils.d.ts +28 -0
- package/dist/util/promiseUtils.d.ts.map +1 -0
- package/dist/util/promiseUtils.js +98 -0
- package/dist/util/truthinessUtils.js +4 -4
- package/docs/rules/no-unnecessary-type-conversion.mdx +79 -0
- package/docs/rules/only-throw-error.mdx +6 -0
- package/package.json +13 -14
@@ -89,6 +89,7 @@ declare const _default: {
|
|
89
89
|
'@typescript-eslint/no-unnecessary-type-arguments': "error";
|
90
90
|
'@typescript-eslint/no-unnecessary-type-assertion': "error";
|
91
91
|
'@typescript-eslint/no-unnecessary-type-constraint': "error";
|
92
|
+
'@typescript-eslint/no-unnecessary-type-conversion': "error";
|
92
93
|
'@typescript-eslint/no-unnecessary-type-parameters': "error";
|
93
94
|
'@typescript-eslint/no-unsafe-argument': "error";
|
94
95
|
'@typescript-eslint/no-unsafe-assignment': "error";
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"all.d.ts","sourceRoot":"","sources":["../../../src/configs/eslintrc/all.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"all.d.ts","sourceRoot":"","sources":["../../../src/configs/eslintrc/all.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,kBA0JiC"}
|
@@ -96,6 +96,7 @@ module.exports = {
|
|
96
96
|
'@typescript-eslint/no-unnecessary-type-arguments': 'error',
|
97
97
|
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
|
98
98
|
'@typescript-eslint/no-unnecessary-type-constraint': 'error',
|
99
|
+
'@typescript-eslint/no-unnecessary-type-conversion': 'error',
|
99
100
|
'@typescript-eslint/no-unnecessary-type-parameters': 'error',
|
100
101
|
'@typescript-eslint/no-unsafe-argument': 'error',
|
101
102
|
'@typescript-eslint/no-unsafe-assignment': 'error',
|
@@ -29,6 +29,7 @@ declare const _default: {
|
|
29
29
|
'@typescript-eslint/no-unnecessary-template-expression': "off";
|
30
30
|
'@typescript-eslint/no-unnecessary-type-arguments': "off";
|
31
31
|
'@typescript-eslint/no-unnecessary-type-assertion': "off";
|
32
|
+
'@typescript-eslint/no-unnecessary-type-conversion': "off";
|
32
33
|
'@typescript-eslint/no-unnecessary-type-parameters': "off";
|
33
34
|
'@typescript-eslint/no-unsafe-argument': "off";
|
34
35
|
'@typescript-eslint/no-unsafe-assignment': "off";
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"disable-type-checked.d.ts","sourceRoot":"","sources":["../../../src/configs/eslintrc/disable-type-checked.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"disable-type-checked.d.ts","sourceRoot":"","sources":["../../../src/configs/eslintrc/disable-type-checked.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,kBA+DiC"}
|
@@ -32,6 +32,7 @@ module.exports = {
|
|
32
32
|
'@typescript-eslint/no-unnecessary-template-expression': 'off',
|
33
33
|
'@typescript-eslint/no-unnecessary-type-arguments': 'off',
|
34
34
|
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
|
35
|
+
'@typescript-eslint/no-unnecessary-type-conversion': 'off',
|
35
36
|
'@typescript-eslint/no-unnecessary-type-parameters': 'off',
|
36
37
|
'@typescript-eslint/no-unsafe-argument': 'off',
|
37
38
|
'@typescript-eslint/no-unsafe-assignment': 'off',
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"all.d.ts","sourceRoot":"","sources":["../../../src/configs/flat/all.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAKrE;;;GAGG;yBAED,QAAQ,UAAU,CAAC,MAAM,EACzB,QAAQ,UAAU,CAAC,MAAM,KACxB,UAAU,CAAC,WAAW;AAHzB,
|
1
|
+
{"version":3,"file":"all.d.ts","sourceRoot":"","sources":["../../../src/configs/flat/all.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAKrE;;;GAGG;yBAED,QAAQ,UAAU,CAAC,MAAM,EACzB,QAAQ,UAAU,CAAC,MAAM,KACxB,UAAU,CAAC,WAAW;AAHzB,wBAkKE"}
|
package/dist/configs/flat/all.js
CHANGED
@@ -109,6 +109,7 @@ exports.default = (plugin, parser) => [
|
|
109
109
|
'@typescript-eslint/no-unnecessary-type-arguments': 'error',
|
110
110
|
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
|
111
111
|
'@typescript-eslint/no-unnecessary-type-constraint': 'error',
|
112
|
+
'@typescript-eslint/no-unnecessary-type-conversion': 'error',
|
112
113
|
'@typescript-eslint/no-unnecessary-type-parameters': 'error',
|
113
114
|
'@typescript-eslint/no-unsafe-argument': 'error',
|
114
115
|
'@typescript-eslint/no-unsafe-assignment': 'error',
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"disable-type-checked.d.ts","sourceRoot":"","sources":["../../../src/configs/flat/disable-type-checked.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAErE;;;GAGG;yBAED,SAAS,UAAU,CAAC,MAAM,EAC1B,SAAS,UAAU,CAAC,MAAM,KACzB,UAAU,CAAC,MAAM;AAHpB,
|
1
|
+
{"version":3,"file":"disable-type-checked.d.ts","sourceRoot":"","sources":["../../../src/configs/flat/disable-type-checked.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAErE;;;GAGG;yBAED,SAAS,UAAU,CAAC,MAAM,EAC1B,SAAS,UAAU,CAAC,MAAM,KACzB,UAAU,CAAC,MAAM;AAHpB,wBAqEG"}
|
@@ -37,6 +37,7 @@ exports.default = (_plugin, _parser) => ({
|
|
37
37
|
'@typescript-eslint/no-unnecessary-template-expression': 'off',
|
38
38
|
'@typescript-eslint/no-unnecessary-type-arguments': 'off',
|
39
39
|
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
|
40
|
+
'@typescript-eslint/no-unnecessary-type-conversion': 'off',
|
40
41
|
'@typescript-eslint/no-unnecessary-type-parameters': 'off',
|
41
42
|
'@typescript-eslint/no-unsafe-argument': 'off',
|
42
43
|
'@typescript-eslint/no-unsafe-assignment': 'off',
|
package/dist/index.d.ts
CHANGED
@@ -91,6 +91,7 @@ declare const _default: {
|
|
91
91
|
'@typescript-eslint/no-unnecessary-type-arguments': "error";
|
92
92
|
'@typescript-eslint/no-unnecessary-type-assertion': "error";
|
93
93
|
'@typescript-eslint/no-unnecessary-type-constraint': "error";
|
94
|
+
'@typescript-eslint/no-unnecessary-type-conversion': "error";
|
94
95
|
'@typescript-eslint/no-unnecessary-type-parameters': "error";
|
95
96
|
'@typescript-eslint/no-unsafe-argument': "error";
|
96
97
|
'@typescript-eslint/no-unsafe-assignment': "error";
|
@@ -192,6 +193,7 @@ declare const _default: {
|
|
192
193
|
'@typescript-eslint/no-unnecessary-template-expression': "off";
|
193
194
|
'@typescript-eslint/no-unnecessary-type-arguments': "off";
|
194
195
|
'@typescript-eslint/no-unnecessary-type-assertion': "off";
|
196
|
+
'@typescript-eslint/no-unnecessary-type-conversion': "off";
|
195
197
|
'@typescript-eslint/no-unnecessary-type-parameters': "off";
|
196
198
|
'@typescript-eslint/no-unsafe-argument': "off";
|
197
199
|
'@typescript-eslint/no-unsafe-assignment': "off";
|
@@ -774,6 +776,7 @@ declare const _default: {
|
|
774
776
|
'no-unnecessary-type-arguments': import("@typescript-eslint/utils/ts-eslint").RuleModule<"unnecessaryTypeParameter", [], import("../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
775
777
|
'no-unnecessary-type-assertion': import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./rules/no-unnecessary-type-assertion").MessageIds, import("./rules/no-unnecessary-type-assertion").Options, import("../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
776
778
|
'no-unnecessary-type-constraint': import("@typescript-eslint/utils/ts-eslint").RuleModule<"removeUnnecessaryConstraint" | "unnecessaryConstraint", [], import("../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
779
|
+
'no-unnecessary-type-conversion': import("@typescript-eslint/utils/ts-eslint").RuleModule<"suggestRemove" | "suggestSatisfies" | "unnecessaryTypeConversion", [], import("../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
777
780
|
'no-unnecessary-type-parameters': import("@typescript-eslint/utils/ts-eslint").RuleModule<"replaceUsagesWithConstraint" | "sole", [], import("../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
778
781
|
'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>;
|
779
782
|
'no-unsafe-assignment': import("@typescript-eslint/utils/ts-eslint").RuleModule<"unsafeArraySpread" | "anyAssignment" | "anyAssignmentThis" | "unsafeArrayPattern" | "unsafeArrayPatternFromTuple" | "unsafeAssignment", [], import("../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
package/dist/index.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,kBAA0B"}
|
package/dist/raw-plugin.d.ts
CHANGED
@@ -113,6 +113,7 @@ declare const _default: {
|
|
113
113
|
'@typescript-eslint/no-unnecessary-type-arguments': "error";
|
114
114
|
'@typescript-eslint/no-unnecessary-type-assertion': "error";
|
115
115
|
'@typescript-eslint/no-unnecessary-type-constraint': "error";
|
116
|
+
'@typescript-eslint/no-unnecessary-type-conversion': "error";
|
116
117
|
'@typescript-eslint/no-unnecessary-type-parameters': "error";
|
117
118
|
'@typescript-eslint/no-unsafe-argument': "error";
|
118
119
|
'@typescript-eslint/no-unsafe-assignment': "error";
|
@@ -214,6 +215,7 @@ declare const _default: {
|
|
214
215
|
'@typescript-eslint/no-unnecessary-template-expression': "off";
|
215
216
|
'@typescript-eslint/no-unnecessary-type-arguments': "off";
|
216
217
|
'@typescript-eslint/no-unnecessary-type-assertion': "off";
|
218
|
+
'@typescript-eslint/no-unnecessary-type-conversion': "off";
|
217
219
|
'@typescript-eslint/no-unnecessary-type-parameters': "off";
|
218
220
|
'@typescript-eslint/no-unsafe-argument': "off";
|
219
221
|
'@typescript-eslint/no-unsafe-assignment': "off";
|
@@ -797,6 +799,7 @@ declare const _default: {
|
|
797
799
|
'no-unnecessary-type-arguments': TSESLint.RuleModule<"unnecessaryTypeParameter", [], import("../rules").ESLintPluginDocs, TSESLint.RuleListener>;
|
798
800
|
'no-unnecessary-type-assertion': TSESLint.RuleModule<import("./rules/no-unnecessary-type-assertion").MessageIds, import("./rules/no-unnecessary-type-assertion").Options, import("../rules").ESLintPluginDocs, TSESLint.RuleListener>;
|
799
801
|
'no-unnecessary-type-constraint': TSESLint.RuleModule<"removeUnnecessaryConstraint" | "unnecessaryConstraint", [], import("../rules").ESLintPluginDocs, TSESLint.RuleListener>;
|
802
|
+
'no-unnecessary-type-conversion': TSESLint.RuleModule<"suggestRemove" | "suggestSatisfies" | "unnecessaryTypeConversion", [], import("../rules").ESLintPluginDocs, TSESLint.RuleListener>;
|
800
803
|
'no-unnecessary-type-parameters': TSESLint.RuleModule<"replaceUsagesWithConstraint" | "sole", [], import("../rules").ESLintPluginDocs, TSESLint.RuleListener>;
|
801
804
|
'no-unsafe-argument': TSESLint.RuleModule<import("./rules/no-unsafe-argument").MessageIds, [], import("../rules").ESLintPluginDocs, TSESLint.RuleListener>;
|
802
805
|
'no-unsafe-assignment': TSESLint.RuleModule<"unsafeArraySpread" | "anyAssignment" | "anyAssignmentThis" | "unsafeArrayPattern" | "unsafeArrayPatternFromTuple" | "unsafeAssignment", [], import("../rules").ESLintPluginDocs, TSESLint.RuleListener>;
|
package/dist/raw-plugin.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"raw-plugin.d.ts","sourceRoot":"","sources":["../src/raw-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAU,MAAM,oCAAoC,CAAC;;;;;;;;;;;;;;;;;;wDAetD,CAAC
|
1
|
+
{"version":3,"file":"raw-plugin.d.ts","sourceRoot":"","sources":["../src/raw-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAU,MAAM,oCAAoC,CAAC;;;;;;;;;;;;;;;;;;wDAetD,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAqCpB,mEAAmE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDvE,kBAIE"}
|
@@ -50,7 +50,7 @@ exports.default = (0, util_1.createRule)({
|
|
50
50
|
return {
|
51
51
|
...(0, util_1.getNameFromMember)(member, context.sourceCode),
|
52
52
|
callSignature: false,
|
53
|
-
static:
|
53
|
+
static: member.static,
|
54
54
|
};
|
55
55
|
case utils_1.AST_NODE_TYPES.TSCallSignatureDeclaration:
|
56
56
|
return {
|
@@ -87,7 +87,7 @@ exports.default = (0, util_1.createRule)({
|
|
87
87
|
return;
|
88
88
|
}
|
89
89
|
const hasAsyncIteratorSymbol = tsutils
|
90
|
-
.
|
90
|
+
.unionConstituents(type)
|
91
91
|
.some(typePart => tsutils.getWellKnownSymbolPropertyOfType(typePart, 'asyncIterator', checker) != null);
|
92
92
|
if (!hasAsyncIteratorSymbol) {
|
93
93
|
context.report({
|
@@ -118,7 +118,7 @@ exports.default = (0, util_1.createRule)({
|
|
118
118
|
continue;
|
119
119
|
}
|
120
120
|
const hasAsyncDisposeSymbol = tsutils
|
121
|
-
.
|
121
|
+
.unionConstituents(type)
|
122
122
|
.some(typePart => tsutils.getWellKnownSymbolPropertyOfType(typePart, 'asyncDispose', checker) != null);
|
123
123
|
if (!hasAsyncDisposeSymbol) {
|
124
124
|
context.report({
|
@@ -116,13 +116,13 @@ exports.default = (0, util_1.createRule)({
|
|
116
116
|
}
|
117
117
|
}
|
118
118
|
}
|
119
|
-
if (!!funcName &&
|
119
|
+
if (!!funcName && options.allowedNames.includes(funcName)) {
|
120
120
|
return true;
|
121
121
|
}
|
122
122
|
}
|
123
123
|
if (node.type === utils_1.AST_NODE_TYPES.FunctionDeclaration &&
|
124
124
|
node.id &&
|
125
|
-
|
125
|
+
options.allowedNames.includes(node.id.name)) {
|
126
126
|
return true;
|
127
127
|
}
|
128
128
|
return false;
|
package/dist/rules/index.d.ts
CHANGED
@@ -107,6 +107,7 @@ declare const rules: {
|
|
107
107
|
'no-unnecessary-type-arguments': import("@typescript-eslint/utils/ts-eslint").RuleModule<"unnecessaryTypeParameter", [], import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
108
108
|
'no-unnecessary-type-assertion': import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./no-unnecessary-type-assertion").MessageIds, import("./no-unnecessary-type-assertion").Options, import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
109
109
|
'no-unnecessary-type-constraint': import("@typescript-eslint/utils/ts-eslint").RuleModule<"removeUnnecessaryConstraint" | "unnecessaryConstraint", [], import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
110
|
+
'no-unnecessary-type-conversion': import("@typescript-eslint/utils/ts-eslint").RuleModule<"suggestRemove" | "suggestSatisfies" | "unnecessaryTypeConversion", [], import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
110
111
|
'no-unnecessary-type-parameters': import("@typescript-eslint/utils/ts-eslint").RuleModule<"replaceUsagesWithConstraint" | "sole", [], import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
111
112
|
'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>;
|
112
113
|
'no-unsafe-assignment': import("@typescript-eslint/utils/ts-eslint").RuleModule<"unsafeArraySpread" | "anyAssignment" | "anyAssignmentThis" | "unsafeArrayPattern" | "unsafeArrayPatternFromTuple" | "unsafeAssignment", [], import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rules/index.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rules/index.ts"],"names":[],"mappings":"AAsIA,QAAA,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqImB,CAAC;AAE/B,SAAS,KAAK,CAAC"}
|
package/dist/rules/index.js
CHANGED
@@ -77,6 +77,7 @@ const no_unnecessary_template_expression_1 = __importDefault(require("./no-unnec
|
|
77
77
|
const no_unnecessary_type_arguments_1 = __importDefault(require("./no-unnecessary-type-arguments"));
|
78
78
|
const no_unnecessary_type_assertion_1 = __importDefault(require("./no-unnecessary-type-assertion"));
|
79
79
|
const no_unnecessary_type_constraint_1 = __importDefault(require("./no-unnecessary-type-constraint"));
|
80
|
+
const no_unnecessary_type_conversion_1 = __importDefault(require("./no-unnecessary-type-conversion"));
|
80
81
|
const no_unnecessary_type_parameters_1 = __importDefault(require("./no-unnecessary-type-parameters"));
|
81
82
|
const no_unsafe_argument_1 = __importDefault(require("./no-unsafe-argument"));
|
82
83
|
const no_unsafe_assignment_1 = __importDefault(require("./no-unsafe-assignment"));
|
@@ -208,6 +209,7 @@ const rules = {
|
|
208
209
|
'no-unnecessary-type-arguments': no_unnecessary_type_arguments_1.default,
|
209
210
|
'no-unnecessary-type-assertion': no_unnecessary_type_assertion_1.default,
|
210
211
|
'no-unnecessary-type-constraint': no_unnecessary_type_constraint_1.default,
|
212
|
+
'no-unnecessary-type-conversion': no_unnecessary_type_conversion_1.default,
|
211
213
|
'no-unnecessary-type-parameters': no_unnecessary_type_parameters_1.default,
|
212
214
|
'no-unsafe-argument': no_unsafe_argument_1.default,
|
213
215
|
'no-unsafe-assignment': no_unsafe_assignment_1.default,
|
@@ -326,7 +326,7 @@ function isMemberOptional(node) {
|
|
326
326
|
case utils_1.AST_NODE_TYPES.PropertyDefinition:
|
327
327
|
case utils_1.AST_NODE_TYPES.TSAbstractMethodDefinition:
|
328
328
|
case utils_1.AST_NODE_TYPES.MethodDefinition:
|
329
|
-
return
|
329
|
+
return node.optional;
|
330
330
|
}
|
331
331
|
return false;
|
332
332
|
}
|
@@ -327,7 +327,7 @@ exports.default = (0, util_1.createRule)({
|
|
327
327
|
return callSignatures.some(signature => {
|
328
328
|
const returnType = signature.getReturnType();
|
329
329
|
return tsutils
|
330
|
-
.
|
330
|
+
.unionConstituents(returnType)
|
331
331
|
.some(tsutils.isIntrinsicVoidType);
|
332
332
|
});
|
333
333
|
}
|
@@ -342,14 +342,14 @@ exports.default = (0, util_1.createRule)({
|
|
342
342
|
if (functionTSNode.type) {
|
343
343
|
const returnType = checker.getTypeFromTypeNode(functionTSNode.type);
|
344
344
|
return tsutils
|
345
|
-
.
|
345
|
+
.unionConstituents(returnType)
|
346
346
|
.some(tsutils.isIntrinsicVoidType);
|
347
347
|
}
|
348
348
|
if (ts.isExpression(functionTSNode)) {
|
349
349
|
const functionType = checker.getContextualType(functionTSNode);
|
350
350
|
if (functionType) {
|
351
351
|
return tsutils
|
352
|
-
.
|
352
|
+
.unionConstituents(functionType)
|
353
353
|
.some(isFunctionReturnTypeIncludesVoid);
|
354
354
|
}
|
355
355
|
}
|
@@ -39,10 +39,10 @@ exports.default = (0, util_1.createRule)({
|
|
39
39
|
}
|
40
40
|
let value;
|
41
41
|
if (isStringLiteral(member.initializer)) {
|
42
|
-
value =
|
42
|
+
value = member.initializer.value;
|
43
43
|
}
|
44
44
|
else if (isNumberLiteral(member.initializer)) {
|
45
|
-
value =
|
45
|
+
value = member.initializer.value;
|
46
46
|
}
|
47
47
|
else if (isStaticTemplateLiteral(member.initializer)) {
|
48
48
|
value = member.initializer.quasis[0].value.cooked;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"no-empty-interface.d.ts","sourceRoot":"","sources":["../../src/rules/no-empty-interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAOzD,MAAM,MAAM,OAAO,GAAG;IACpB;QACE,kBAAkB,CAAC,EAAE,OAAO,CAAC;KAC9B;CACF,CAAC;AACF,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,kBAAkB,CAAC;;AAExD,
|
1
|
+
{"version":3,"file":"no-empty-interface.d.ts","sourceRoot":"","sources":["../../src/rules/no-empty-interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAOzD,MAAM,MAAM,OAAO,GAAG;IACpB;QACE,kBAAkB,CAAC,EAAE,OAAO,CAAC;KAC9B;CACF,CAAC;AACF,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,kBAAkB,CAAC;;AAExD,wBAkHG"}
|
@@ -75,9 +75,9 @@ exports.default = (0, util_1.createRule)({
|
|
75
75
|
const mergedWithClassDeclaration = scope.set
|
76
76
|
.get(node.id.name)
|
77
77
|
?.defs.some(def => def.node.type === utils_1.AST_NODE_TYPES.ClassDeclaration);
|
78
|
-
const isInAmbientDeclaration =
|
78
|
+
const isInAmbientDeclaration = (0, util_1.isDefinitionFile)(context.filename) &&
|
79
79
|
scope.type === scope_manager_1.ScopeType.tsModule &&
|
80
|
-
scope.block.declare
|
80
|
+
scope.block.declare;
|
81
81
|
const useAutoFix = !(isInAmbientDeclaration || mergedWithClassDeclaration);
|
82
82
|
context.report({
|
83
83
|
node: node.id,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"no-floating-promises.d.ts","sourceRoot":"","sources":["../../src/rules/no-floating-promises.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAY,MAAM,0BAA0B,CAAC;AAMnE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;
|
1
|
+
{"version":3,"file":"no-floating-promises.d.ts","sourceRoot":"","sources":["../../src/rules/no-floating-promises.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAY,MAAM,0BAA0B,CAAC;AAMnE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAmBpD,MAAM,MAAM,OAAO,GAAG;IACpB;QACE,sBAAsB,CAAC,EAAE,oBAAoB,EAAE,CAAC;QAChD,yBAAyB,CAAC,EAAE,oBAAoB,EAAE,CAAC;QACnD,cAAc,CAAC,EAAE,OAAO,CAAC;QACzB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,UAAU,CAAC,EAAE,OAAO,CAAC;KACtB;CACF,CAAC;AAEF,MAAM,MAAM,SAAS,GACjB,UAAU,GACV,kBAAkB,GAClB,iBAAiB,GACjB,sBAAsB,GACtB,0BAA0B,GAC1B,iCAAiC,GACjC,qCAAqC,GACrC,cAAc,CAAC;;AAmBnB,wBAqZG"}
|
@@ -37,6 +37,7 @@ const utils_1 = require("@typescript-eslint/utils");
|
|
37
37
|
const tsutils = __importStar(require("ts-api-utils"));
|
38
38
|
const ts = __importStar(require("typescript"));
|
39
39
|
const util_1 = require("../util");
|
40
|
+
const promiseUtils_1 = require("../util/promiseUtils");
|
40
41
|
const messageBase = 'Promises must be awaited, end with a call to .catch, or end with a call to .then with a rejection handler.';
|
41
42
|
const messageBaseVoid = 'Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler' +
|
42
43
|
' or be explicitly marked as ignored with the `void` operator.';
|
@@ -256,33 +257,20 @@ exports.default = (0, util_1.createRule)({
|
|
256
257
|
if (node.type === utils_1.AST_NODE_TYPES.CallExpression) {
|
257
258
|
// If the outer expression is a call, a `.catch()` or `.then()` with
|
258
259
|
// rejection handler handles the promise.
|
259
|
-
const
|
260
|
-
if (
|
261
|
-
const
|
262
|
-
|
263
|
-
|
264
|
-
: undefined;
|
265
|
-
if (catchRejectionHandler) {
|
266
|
-
if (isValidRejectionHandler(catchRejectionHandler)) {
|
260
|
+
const promiseHandlingMethodCall = (0, promiseUtils_1.parseCatchCall)(node, context) ?? (0, promiseUtils_1.parseThenCall)(node, context);
|
261
|
+
if (promiseHandlingMethodCall != null) {
|
262
|
+
const onRejected = promiseHandlingMethodCall.onRejected;
|
263
|
+
if (onRejected != null) {
|
264
|
+
if (isValidRejectionHandler(onRejected)) {
|
267
265
|
return { isUnhandled: false };
|
268
266
|
}
|
269
267
|
return { isUnhandled: true, nonFunctionHandler: true };
|
270
268
|
}
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
return { isUnhandled: false };
|
277
|
-
}
|
278
|
-
return { isUnhandled: true, nonFunctionHandler: true };
|
279
|
-
}
|
280
|
-
// `x.finally()` is transparent to resolution of the promise, so check `x`.
|
281
|
-
// ("object" in this context is the `x` in `x.finally()`)
|
282
|
-
const promiseFinallyObject = methodName === 'finally' ? callee.object : undefined;
|
283
|
-
if (promiseFinallyObject) {
|
284
|
-
return isUnhandledPromise(checker, promiseFinallyObject);
|
285
|
-
}
|
269
|
+
return { isUnhandled: true };
|
270
|
+
}
|
271
|
+
const promiseFinallyCall = (0, promiseUtils_1.parseFinallyCall)(node, context);
|
272
|
+
if (promiseFinallyCall != null) {
|
273
|
+
return isUnhandledPromise(checker, promiseFinallyCall.object);
|
286
274
|
}
|
287
275
|
// All other cases are unhandled.
|
288
276
|
return { isUnhandled: true };
|
@@ -309,7 +297,7 @@ exports.default = (0, util_1.createRule)({
|
|
309
297
|
function isPromiseArray(node) {
|
310
298
|
const type = checker.getTypeAtLocation(node);
|
311
299
|
for (const ty of tsutils
|
312
|
-
.
|
300
|
+
.unionConstituents(type)
|
313
301
|
.map(t => checker.getApparentType(t))) {
|
314
302
|
if (checker.isArrayType(ty)) {
|
315
303
|
const arrayType = checker.getTypeArguments(ty)[0];
|
@@ -334,7 +322,7 @@ exports.default = (0, util_1.createRule)({
|
|
334
322
|
return false;
|
335
323
|
}
|
336
324
|
// Otherwise, we always consider the built-in Promise to be Promise-like...
|
337
|
-
const typeParts = tsutils.
|
325
|
+
const typeParts = tsutils.unionConstituents(checker.getApparentType(type));
|
338
326
|
if (typeParts.some(typePart => (0, util_1.isBuiltinSymbolLike)(services.program, typePart, 'Promise'))) {
|
339
327
|
return true;
|
340
328
|
}
|
@@ -363,7 +351,7 @@ exports.default = (0, util_1.createRule)({
|
|
363
351
|
},
|
364
352
|
});
|
365
353
|
function hasMatchingSignature(type, matcher) {
|
366
|
-
for (const t of tsutils.
|
354
|
+
for (const t of tsutils.unionConstituents(type)) {
|
367
355
|
if (t.getCallSignatures().some(matcher)) {
|
368
356
|
return true;
|
369
357
|
}
|
@@ -372,7 +360,7 @@ function hasMatchingSignature(type, matcher) {
|
|
372
360
|
}
|
373
361
|
function isFunctionParam(checker, param, node) {
|
374
362
|
const type = checker.getApparentType(checker.getTypeOfSymbolAtLocation(param, node));
|
375
|
-
for (const t of tsutils.
|
363
|
+
for (const t of tsutils.unionConstituents(type)) {
|
376
364
|
if (t.getCallSignatures().length !== 0) {
|
377
365
|
return true;
|
378
366
|
}
|
@@ -79,7 +79,7 @@ exports.default = (0, util_1.createRule)({
|
|
79
79
|
]);
|
80
80
|
};
|
81
81
|
const argType = services.getTypeAtLocation(node.argument);
|
82
|
-
const unionParts = tsutils.
|
82
|
+
const unionParts = tsutils.unionConstituents(argType);
|
83
83
|
if (unionParts.every(part => part.flags & (ts.TypeFlags.Void | ts.TypeFlags.Undefined))) {
|
84
84
|
context.report({
|
85
85
|
node,
|
@@ -551,7 +551,7 @@ exports.default = (0, util_1.createRule)({
|
|
551
551
|
});
|
552
552
|
function isSometimesThenable(checker, node) {
|
553
553
|
const type = checker.getTypeAtLocation(node);
|
554
|
-
for (const subType of tsutils.
|
554
|
+
for (const subType of tsutils.unionConstituents(checker.getApparentType(type))) {
|
555
555
|
if (tsutils.isThenableType(checker, node, subType)) {
|
556
556
|
return true;
|
557
557
|
}
|
@@ -564,7 +564,7 @@ function isSometimesThenable(checker, node) {
|
|
564
564
|
// branches is thenable.
|
565
565
|
function isAlwaysThenable(checker, node) {
|
566
566
|
const type = checker.getTypeAtLocation(node);
|
567
|
-
for (const subType of tsutils.
|
567
|
+
for (const subType of tsutils.unionConstituents(checker.getApparentType(type))) {
|
568
568
|
const thenProp = subType.getProperty('then');
|
569
569
|
// If one of the alternates has no then property, it is not thenable in all
|
570
570
|
// cases.
|
@@ -576,7 +576,7 @@ function isAlwaysThenable(checker, node) {
|
|
576
576
|
// be of the right form to consider it thenable.
|
577
577
|
const thenType = checker.getTypeOfSymbolAtLocation(thenProp, node);
|
578
578
|
let hasThenableSignature = false;
|
579
|
-
for (const subType of tsutils.
|
579
|
+
for (const subType of tsutils.unionConstituents(thenType)) {
|
580
580
|
for (const signature of subType.getCallSignatures()) {
|
581
581
|
if (signature.parameters.length !== 0 &&
|
582
582
|
isFunctionParam(checker, signature.parameters[0], node)) {
|
@@ -602,7 +602,7 @@ function isAlwaysThenable(checker, node) {
|
|
602
602
|
}
|
603
603
|
function isFunctionParam(checker, param, node) {
|
604
604
|
const type = checker.getApparentType(checker.getTypeOfSymbolAtLocation(param, node));
|
605
|
-
for (const subType of tsutils.
|
605
|
+
for (const subType of tsutils.unionConstituents(type)) {
|
606
606
|
if (subType.getCallSignatures().length !== 0) {
|
607
607
|
return true;
|
608
608
|
}
|
@@ -641,7 +641,7 @@ function voidFunctionArguments(checker, node) {
|
|
641
641
|
const type = checker.getTypeAtLocation(node.expression);
|
642
642
|
// We can't use checker.getResolvedSignature because it prefers an early '() => void' over a later '() => Promise<void>'
|
643
643
|
// See https://github.com/microsoft/TypeScript/issues/48077
|
644
|
-
for (const subType of tsutils.
|
644
|
+
for (const subType of tsutils.unionConstituents(type)) {
|
645
645
|
// Standard function calls and `new` have two different types of signatures
|
646
646
|
const signatures = ts.isCallExpression(node)
|
647
647
|
? subType.getCallSignatures()
|
@@ -698,7 +698,7 @@ function anySignatureIsThenableType(checker, node, type) {
|
|
698
698
|
* @returns Whether type is a thenable-returning function.
|
699
699
|
*/
|
700
700
|
function isThenableReturningFunctionType(checker, node, type) {
|
701
|
-
for (const subType of tsutils.
|
701
|
+
for (const subType of tsutils.unionConstituents(type)) {
|
702
702
|
if (anySignatureIsThenableType(checker, node, subType)) {
|
703
703
|
return true;
|
704
704
|
}
|
@@ -710,7 +710,7 @@ function isThenableReturningFunctionType(checker, node, type) {
|
|
710
710
|
*/
|
711
711
|
function isVoidReturningFunctionType(checker, node, type) {
|
712
712
|
let hadVoidReturn = false;
|
713
|
-
for (const subType of tsutils.
|
713
|
+
for (const subType of tsutils.unionConstituents(type)) {
|
714
714
|
for (const signature of subType.getCallSignatures()) {
|
715
715
|
const returnType = signature.getReturnType();
|
716
716
|
// If a certain positional argument accepts both thenable and void returns,
|
@@ -729,7 +729,7 @@ function isVoidReturningFunctionType(checker, node, type) {
|
|
729
729
|
function returnsThenable(checker, node) {
|
730
730
|
const type = checker.getApparentType(checker.getTypeAtLocation(node));
|
731
731
|
return tsutils
|
732
|
-
.
|
732
|
+
.unionConstituents(type)
|
733
733
|
.some(t => anySignatureIsThenableType(checker, node, t));
|
734
734
|
}
|
735
735
|
function getHeritageTypes(checker, tsNode) {
|
@@ -97,7 +97,7 @@ exports.default = (0, util_1.createRule)({
|
|
97
97
|
}
|
98
98
|
}
|
99
99
|
function getMapSpreadSuggestions(node, type) {
|
100
|
-
const types = tsutils.
|
100
|
+
const types = tsutils.unionConstituents(type);
|
101
101
|
if (types.some(t => !isMap(services.program, t))) {
|
102
102
|
return null;
|
103
103
|
}
|
@@ -208,7 +208,7 @@ exports.default = (0, util_1.createRule)({
|
|
208
208
|
});
|
209
209
|
function isIterable(type, checker) {
|
210
210
|
return tsutils
|
211
|
-
.
|
211
|
+
.typeConstituents(type)
|
212
212
|
.some(t => !!tsutils.getWellKnownSymbolPropertyOfType(t, 'iterator', checker));
|
213
213
|
}
|
214
214
|
function isArray(checker, type) {
|
@@ -156,7 +156,7 @@ function describeLiteralTypeNode(typeNode) {
|
|
156
156
|
return 'literal type';
|
157
157
|
}
|
158
158
|
function isNodeInsideReturnType(node) {
|
159
|
-
return
|
159
|
+
return (node.parent.type === utils_1.AST_NODE_TYPES.TSTypeAnnotation &&
|
160
160
|
(0, util_1.isFunctionOrFunctionType)(node.parent.parent));
|
161
161
|
}
|
162
162
|
/**
|
@@ -168,7 +168,7 @@ function unionTypePartsUnlessBoolean(type) {
|
|
168
168
|
tsutils.isFalseLiteralType(type.types[0]) &&
|
169
169
|
tsutils.isTrueLiteralType(type.types[1])
|
170
170
|
? [type]
|
171
|
-
: tsutils.
|
171
|
+
: tsutils.unionConstituents(type);
|
172
172
|
}
|
173
173
|
exports.default = (0, util_1.createRule)({
|
174
174
|
name: 'no-redundant-type-constituents',
|
@@ -44,14 +44,14 @@ function isNullishType(type) {
|
|
44
44
|
return tsutils.isTypeFlagSet(type, nullishFlag);
|
45
45
|
}
|
46
46
|
function isAlwaysNullish(type) {
|
47
|
-
return tsutils.
|
47
|
+
return tsutils.unionConstituents(type).every(isNullishType);
|
48
48
|
}
|
49
49
|
/**
|
50
50
|
* Note that this differs from {@link isNullableType} in that it doesn't consider
|
51
51
|
* `any` or `unknown` to be nullable.
|
52
52
|
*/
|
53
53
|
function isPossiblyNullish(type) {
|
54
|
-
return tsutils.
|
54
|
+
return tsutils.unionConstituents(type).some(isNullishType);
|
55
55
|
}
|
56
56
|
function toStaticValue(type) {
|
57
57
|
// type.isLiteral() only covers numbers/bigints and strings, hence the rest of the branches.
|
@@ -198,13 +198,13 @@ exports.default = (0, util_1.createRule)({
|
|
198
198
|
function nodeIsArrayType(node) {
|
199
199
|
const nodeType = (0, util_1.getConstrainedTypeAtLocation)(services, node);
|
200
200
|
return tsutils
|
201
|
-
.
|
201
|
+
.unionConstituents(nodeType)
|
202
202
|
.some(part => checker.isArrayType(part));
|
203
203
|
}
|
204
204
|
function nodeIsTupleType(node) {
|
205
205
|
const nodeType = (0, util_1.getConstrainedTypeAtLocation)(services, node);
|
206
206
|
return tsutils
|
207
|
-
.
|
207
|
+
.unionConstituents(nodeType)
|
208
208
|
.some(part => checker.isTupleType(part));
|
209
209
|
}
|
210
210
|
function isArrayIndexExpression(node) {
|
@@ -223,7 +223,7 @@ exports.default = (0, util_1.createRule)({
|
|
223
223
|
// `any` or `unknown` or a naked type variable
|
224
224
|
function isConditionalAlwaysNecessary(type) {
|
225
225
|
return tsutils
|
226
|
-
.
|
226
|
+
.unionConstituents(type)
|
227
227
|
.some(part => (0, util_1.isTypeAnyType)(part) ||
|
228
228
|
(0, util_1.isTypeUnknownType)(part) ||
|
229
229
|
(0, util_1.isTypeFlagSet)(part, ts.TypeFlags.TypeVariable));
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"no-unnecessary-template-expression.d.ts","sourceRoot":"","sources":["../../src/rules/no-unnecessary-template-expression.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAmBzD,MAAM,MAAM,SAAS,GAAG,iCAAiC,CAAC;;
|
1
|
+
{"version":3,"file":"no-unnecessary-template-expression.d.ts","sourceRoot":"","sources":["../../src/rules/no-unnecessary-template-expression.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAmBzD,MAAM,MAAM,SAAS,GAAG,iCAAiC,CAAC;;AAqB1D,wBAgbG"}
|
@@ -43,7 +43,7 @@ const evenNumOfBackslashesRegExp = /(?<!(?:[^\\]|^)(?:\\\\)*\\)/;
|
|
43
43
|
// '\\\\$' <- true
|
44
44
|
// '\\\\\\$' <- false
|
45
45
|
function endsWithUnescapedDollarSign(str) {
|
46
|
-
return new RegExp(`${
|
46
|
+
return new RegExp(`${evenNumOfBackslashesRegExp.source}\\$$`).test(str);
|
47
47
|
}
|
48
48
|
exports.default = (0, util_1.createRule)({
|
49
49
|
name: 'no-unnecessary-template-expression',
|
@@ -77,7 +77,7 @@ exports.default = (0, util_1.createRule)({
|
|
77
77
|
return isStringLike(type);
|
78
78
|
}
|
79
79
|
function isEnumMemberType(type) {
|
80
|
-
return tsutils.
|
80
|
+
return tsutils.typeConstituents(type).some(t => {
|
81
81
|
const symbol = t.getSymbol();
|
82
82
|
return !!(symbol?.valueDeclaration && ts.isEnumMember(symbol.valueDeclaration));
|
83
83
|
});
|
@@ -233,7 +233,7 @@ exports.default = (0, util_1.createRule)({
|
|
233
233
|
// \\` -> \\\`
|
234
234
|
// \${ -> \${
|
235
235
|
// \\${ -> \\\${
|
236
|
-
.replaceAll(new RegExp(`${
|
236
|
+
.replaceAll(new RegExp(`${evenNumOfBackslashesRegExp.source}(\`|\\\${)`, 'g'), '\\$1');
|
237
237
|
// `...${'...$'}{...`
|
238
238
|
// ^^^^
|
239
239
|
if (nextCharacterIsOpeningCurlyBrace &&
|
@@ -171,10 +171,10 @@ exports.default = (0, util_1.createRule)({
|
|
171
171
|
(0, util_1.isTypeFlagSet)(cast, ts.TypeFlags.Undefined) &&
|
172
172
|
tsutils.isCompilerOptionEnabled(compilerOptions, 'exactOptionalPropertyTypes')) {
|
173
173
|
const uncastParts = tsutils
|
174
|
-
.
|
174
|
+
.unionConstituents(uncast)
|
175
175
|
.filter(part => !(0, util_1.isTypeFlagSet)(part, ts.TypeFlags.Undefined));
|
176
176
|
const castParts = tsutils
|
177
|
-
.
|
177
|
+
.unionConstituents(cast)
|
178
178
|
.filter(part => !(0, util_1.isTypeFlagSet)(part, ts.TypeFlags.Undefined));
|
179
179
|
if (uncastParts.length !== castParts.length) {
|
180
180
|
return false;
|