@typescript-eslint/eslint-plugin 8.67.1-alpha.16 → 8.67.1-alpha.18
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.
|
@@ -112,69 +112,77 @@ exports.default = (0, util_1.createRule)({
|
|
|
112
112
|
const allowForKnownSafeCalls = options.allowForKnownSafeCalls;
|
|
113
113
|
/* eslint-enable @typescript-eslint/no-non-null-assertion */
|
|
114
114
|
return {
|
|
115
|
+
ArrowFunctionExpression(node) {
|
|
116
|
+
if (node.body.type === utils_1.AST_NODE_TYPES.UnaryExpression) {
|
|
117
|
+
checkNode(node.body, node.body);
|
|
118
|
+
}
|
|
119
|
+
},
|
|
115
120
|
ExpressionStatement(node) {
|
|
116
121
|
if (options.ignoreIIFE && isAsyncIife(node)) {
|
|
117
122
|
return;
|
|
118
123
|
}
|
|
119
124
|
const expression = (0, util_1.skipChainExpression)(node.expression);
|
|
120
|
-
|
|
121
|
-
|
|
125
|
+
checkNode(node, expression);
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
function checkNode(node, expression) {
|
|
129
|
+
if (isKnownSafePromiseCall(expression)) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
const { isUnhandled, nonFunctionHandler, promiseArray } = isUnhandledPromise(checker, expression);
|
|
133
|
+
if (isUnhandled) {
|
|
134
|
+
if (promiseArray) {
|
|
135
|
+
context.report({
|
|
136
|
+
node,
|
|
137
|
+
messageId: options.ignoreVoid
|
|
138
|
+
? 'floatingPromiseArrayVoid'
|
|
139
|
+
: 'floatingPromiseArray',
|
|
140
|
+
});
|
|
122
141
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
fix(fixer) {
|
|
143
|
-
if ((0, util_1.isParenthesized)(expression, context.sourceCode) ||
|
|
144
|
-
(0, util_1.getOperatorPrecedenceForNode)(expression) >
|
|
145
|
-
util_1.OperatorPrecedence.Unary) {
|
|
146
|
-
return fixer.insertTextBefore(node, 'void ');
|
|
147
|
-
}
|
|
148
|
-
return [
|
|
149
|
-
fixer.insertTextBefore(node, 'void ('),
|
|
150
|
-
fixer.insertTextAfterRange([expression.range[1], expression.range[1]], ')'),
|
|
151
|
-
];
|
|
152
|
-
},
|
|
153
|
-
},
|
|
154
|
-
{
|
|
155
|
-
messageId: 'floatingFixAwait',
|
|
156
|
-
fix: (fixer) => addAwait(fixer, expression, node),
|
|
142
|
+
else if (options.ignoreVoid) {
|
|
143
|
+
context.report({
|
|
144
|
+
node,
|
|
145
|
+
messageId: nonFunctionHandler
|
|
146
|
+
? 'floatingUselessRejectionHandlerVoid'
|
|
147
|
+
: 'floatingVoid',
|
|
148
|
+
suggest: [
|
|
149
|
+
{
|
|
150
|
+
messageId: 'floatingFixVoid',
|
|
151
|
+
fix(fixer) {
|
|
152
|
+
if ((0, util_1.isParenthesized)(expression, context.sourceCode) ||
|
|
153
|
+
(0, util_1.getOperatorPrecedenceForNode)(expression) >
|
|
154
|
+
util_1.OperatorPrecedence.Unary) {
|
|
155
|
+
return fixer.insertTextBefore(node, 'void ');
|
|
156
|
+
}
|
|
157
|
+
return [
|
|
158
|
+
fixer.insertTextBefore(node, 'void ('),
|
|
159
|
+
fixer.insertTextAfterRange([expression.range[1], expression.range[1]], ')'),
|
|
160
|
+
];
|
|
157
161
|
},
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
? 'floatingUselessRejectionHandler'
|
|
166
|
-
: 'floating',
|
|
167
|
-
suggest: [
|
|
168
|
-
{
|
|
169
|
-
messageId: 'floatingFixAwait',
|
|
170
|
-
fix: (fixer) => addAwait(fixer, expression, node),
|
|
171
|
-
},
|
|
172
|
-
],
|
|
173
|
-
});
|
|
174
|
-
}
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
messageId: 'floatingFixAwait',
|
|
165
|
+
fix: (fixer) => addAwait(fixer, expression, node),
|
|
166
|
+
},
|
|
167
|
+
],
|
|
168
|
+
});
|
|
175
169
|
}
|
|
176
|
-
|
|
177
|
-
|
|
170
|
+
else {
|
|
171
|
+
context.report({
|
|
172
|
+
node,
|
|
173
|
+
messageId: nonFunctionHandler
|
|
174
|
+
? 'floatingUselessRejectionHandler'
|
|
175
|
+
: 'floating',
|
|
176
|
+
suggest: [
|
|
177
|
+
{
|
|
178
|
+
messageId: 'floatingFixAwait',
|
|
179
|
+
fix: (fixer) => addAwait(fixer, expression, node),
|
|
180
|
+
},
|
|
181
|
+
],
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
178
186
|
function addAwait(fixer, expression, node) {
|
|
179
187
|
if (expression.type === utils_1.AST_NODE_TYPES.UnaryExpression &&
|
|
180
188
|
expression.operator === 'void') {
|
|
@@ -249,7 +249,17 @@ exports.default = (0, util_1.createRule)({
|
|
|
249
249
|
return nestedTypes.some(t => typeContains(t, predicate, seen));
|
|
250
250
|
}
|
|
251
251
|
function containsAny(type) {
|
|
252
|
-
|
|
252
|
+
try {
|
|
253
|
+
return typeContains(type, t => (0, util_1.isTypeFlagSet)(t, ts.TypeFlags.Any));
|
|
254
|
+
}
|
|
255
|
+
catch (error) {
|
|
256
|
+
// Workaround for https://github.com/typescript-eslint/typescript-eslint/issues/12705
|
|
257
|
+
if (error instanceof RangeError &&
|
|
258
|
+
error.message === 'Maximum call stack size exceeded') {
|
|
259
|
+
return false;
|
|
260
|
+
}
|
|
261
|
+
throw error;
|
|
262
|
+
}
|
|
253
263
|
}
|
|
254
264
|
function containsTypeVariable(type) {
|
|
255
265
|
return typeContains(type, t => (0, util_1.isTypeFlagSet)(t, ts.TypeFlags.TypeVariable | ts.TypeFlags.Index));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typescript-eslint/eslint-plugin",
|
|
3
|
-
"version": "8.67.1-alpha.
|
|
3
|
+
"version": "8.67.1-alpha.18",
|
|
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.67.1-alpha.
|
|
51
|
-
"@typescript-eslint/type-utils": "8.67.1-alpha.
|
|
52
|
-
"@typescript-eslint/utils": "8.67.1-alpha.
|
|
53
|
-
"@typescript-eslint/visitor-keys": "8.67.1-alpha.
|
|
50
|
+
"@typescript-eslint/scope-manager": "8.67.1-alpha.18",
|
|
51
|
+
"@typescript-eslint/type-utils": "8.67.1-alpha.18",
|
|
52
|
+
"@typescript-eslint/utils": "8.67.1-alpha.18",
|
|
53
|
+
"@typescript-eslint/visitor-keys": "8.67.1-alpha.18",
|
|
54
54
|
"ignore": "^7.0.5",
|
|
55
55
|
"natural-compare": "^1.4.0",
|
|
56
56
|
"ts-api-utils": "^2.5.0"
|
|
@@ -60,8 +60,8 @@
|
|
|
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.67.1-alpha.
|
|
64
|
-
"@typescript-eslint/rule-tester": "8.67.1-alpha.
|
|
63
|
+
"@typescript-eslint/rule-schema-to-typescript-types": "8.67.1-alpha.18",
|
|
64
|
+
"@typescript-eslint/rule-tester": "8.67.1-alpha.18",
|
|
65
65
|
"@typescript/native": "npm:typescript@^7.0.2",
|
|
66
66
|
"@vitest/coverage-v8": "^4.0.18",
|
|
67
67
|
"ajv": "^6.12.6",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"vitest": "^4.0.18"
|
|
82
82
|
},
|
|
83
83
|
"peerDependencies": {
|
|
84
|
-
"@typescript-eslint/parser": "^8.67.1-alpha.
|
|
84
|
+
"@typescript-eslint/parser": "^8.67.1-alpha.18",
|
|
85
85
|
"eslint": "^8.57.0 || ^9.0.0 || ^10.0.0",
|
|
86
86
|
"typescript": ">=4.8.4 <6.1.0"
|
|
87
87
|
},
|