@typescript-eslint/eslint-plugin 8.46.4-alpha.3 → 8.46.4-alpha.5
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/rules/explicit-member-accessibility.js +3 -3
- package/dist/rules/no-misused-promises.js +1 -1
- package/dist/rules/no-misused-spread.js +2 -2
- package/dist/rules/no-unnecessary-template-expression.js +2 -2
- package/dist/rules/no-unnecessary-type-arguments.js +2 -2
- package/dist/rules/return-await.js +2 -2
- package/dist/util/collectUnusedVariables.js +4 -4
- package/package.json +8 -8
|
@@ -163,13 +163,13 @@ exports.default = (0, util_1.createRule)({
|
|
|
163
163
|
if (token.type === utils_1.AST_TOKEN_TYPES.Keyword &&
|
|
164
164
|
token.value === 'public') {
|
|
165
165
|
keywordRange = structuredClone(token.range);
|
|
166
|
-
const
|
|
167
|
-
if (
|
|
166
|
+
const commentsAfterPublicKeyword = context.sourceCode.getCommentsAfter(token);
|
|
167
|
+
if (commentsAfterPublicKeyword.length) {
|
|
168
168
|
// public /* Hi there! */ static foo()
|
|
169
169
|
// ^^^^^^^
|
|
170
170
|
rangeToRemove = [
|
|
171
171
|
token.range[0],
|
|
172
|
-
|
|
172
|
+
commentsAfterPublicKeyword[0].range[0],
|
|
173
173
|
];
|
|
174
174
|
break;
|
|
175
175
|
}
|
|
@@ -75,7 +75,7 @@ exports.default = (0, util_1.createRule)({
|
|
|
75
75
|
messages: {
|
|
76
76
|
conditional: 'Expected non-Promise value in a boolean conditional.',
|
|
77
77
|
predicate: 'Expected a non-Promise value to be returned.',
|
|
78
|
-
spread: 'Expected a non-Promise value to be
|
|
78
|
+
spread: 'Expected a non-Promise value to be spread in an object.',
|
|
79
79
|
voidReturnArgument: 'Promise returned in function argument where a void return was expected.',
|
|
80
80
|
voidReturnAttribute: 'Promise-returning function provided to attribute where a void return was expected.',
|
|
81
81
|
voidReturnInheritedMethod: "Promise-returning method provided where a void return was expected by extended/implemented type '{{ heritageTypeName }}'.",
|
|
@@ -127,11 +127,11 @@ exports.default = (0, util_1.createRule)({
|
|
|
127
127
|
];
|
|
128
128
|
}
|
|
129
129
|
function getPromiseSpreadSuggestions(node) {
|
|
130
|
-
const
|
|
130
|
+
const isHighPrecedence = (0, util_1.isHigherPrecedenceThanAwait)(services.esTreeNodeToTSNodeMap.get(node));
|
|
131
131
|
return [
|
|
132
132
|
{
|
|
133
133
|
messageId: 'addAwait',
|
|
134
|
-
fix: fixer =>
|
|
134
|
+
fix: fixer => isHighPrecedence
|
|
135
135
|
? fixer.insertTextBefore(node, 'await ')
|
|
136
136
|
: [
|
|
137
137
|
fixer.insertTextBefore(node, 'await ('),
|
|
@@ -148,7 +148,7 @@ exports.default = (0, util_1.createRule)({
|
|
|
148
148
|
},
|
|
149
149
|
});
|
|
150
150
|
}
|
|
151
|
-
function
|
|
151
|
+
function isUnnecessaryValueInterpolation({ interpolation, nextQuasi, prevQuasi, }) {
|
|
152
152
|
if (hasCommentsBetweenQuasi(prevQuasi, nextQuasi)) {
|
|
153
153
|
return false;
|
|
154
154
|
}
|
|
@@ -320,7 +320,7 @@ exports.default = (0, util_1.createRule)({
|
|
|
320
320
|
return;
|
|
321
321
|
}
|
|
322
322
|
}
|
|
323
|
-
const infos = getInterpolationInfos(node).filter(
|
|
323
|
+
const infos = getInterpolationInfos(node).filter(isUnnecessaryValueInterpolation);
|
|
324
324
|
for (const reportDescriptor of getReportDescriptors(infos)) {
|
|
325
325
|
context.report(reportDescriptor);
|
|
326
326
|
}
|
|
@@ -141,8 +141,8 @@ function getTypeParametersFromType(node, type, checker) {
|
|
|
141
141
|
if (!declarations) {
|
|
142
142
|
return undefined;
|
|
143
143
|
}
|
|
144
|
-
const
|
|
145
|
-
return (0, util_1.findFirstResult)(
|
|
144
|
+
const sortedDeclarations = sortDeclarationsByTypeValueContext(node, declarations);
|
|
145
|
+
return (0, util_1.findFirstResult)(sortedDeclarations, decl => {
|
|
146
146
|
if (ts.isTypeAliasDeclaration(decl) ||
|
|
147
147
|
ts.isInterfaceDeclaration(decl) ||
|
|
148
148
|
ts.isClassLike(decl)) {
|
|
@@ -222,8 +222,8 @@ exports.default = (0, util_1.createRule)({
|
|
|
222
222
|
}
|
|
223
223
|
return fixer.removeRange([startAt, endAt]);
|
|
224
224
|
}
|
|
225
|
-
function insertAwait(fixer, node,
|
|
226
|
-
if (
|
|
225
|
+
function insertAwait(fixer, node, isHighPrecedence) {
|
|
226
|
+
if (isHighPrecedence) {
|
|
227
227
|
return fixer.insertTextBefore(node, 'await ');
|
|
228
228
|
}
|
|
229
229
|
return [
|
|
@@ -119,7 +119,7 @@ class UnusedVarsVisitor extends scope_manager_1.Visitor {
|
|
|
119
119
|
// basic exported variables
|
|
120
120
|
isExported(variable) ||
|
|
121
121
|
// variables implicitly exported via a merged declaration
|
|
122
|
-
|
|
122
|
+
isMergeableExported(variable) ||
|
|
123
123
|
// used variables
|
|
124
124
|
isUsedVariable(variable)) {
|
|
125
125
|
variables.usedVariables.add(variable);
|
|
@@ -285,7 +285,7 @@ function isSelfReference(ref, nodes) {
|
|
|
285
285
|
}
|
|
286
286
|
return false;
|
|
287
287
|
}
|
|
288
|
-
const
|
|
288
|
+
const MERGEABLE_TYPES = new Set([
|
|
289
289
|
utils_1.AST_NODE_TYPES.ClassDeclaration,
|
|
290
290
|
utils_1.AST_NODE_TYPES.FunctionDeclaration,
|
|
291
291
|
utils_1.AST_NODE_TYPES.TSInterfaceDeclaration,
|
|
@@ -296,7 +296,7 @@ const MERGABLE_TYPES = new Set([
|
|
|
296
296
|
* Determine if the variable is directly exported
|
|
297
297
|
* @param variable the variable to check
|
|
298
298
|
*/
|
|
299
|
-
function
|
|
299
|
+
function isMergeableExported(variable) {
|
|
300
300
|
// If all of the merged things are of the same type, TS will error if not all of them are exported - so we only need to find one
|
|
301
301
|
for (const def of variable.defs) {
|
|
302
302
|
// parameters can never be exported.
|
|
@@ -305,7 +305,7 @@ function isMergableExported(variable) {
|
|
|
305
305
|
if (def.type === utils_1.TSESLint.Scope.DefinitionType.Parameter) {
|
|
306
306
|
continue;
|
|
307
307
|
}
|
|
308
|
-
if ((
|
|
308
|
+
if ((MERGEABLE_TYPES.has(def.node.type) &&
|
|
309
309
|
def.node.parent.type === utils_1.AST_NODE_TYPES.ExportNamedDeclaration) ||
|
|
310
310
|
def.node.parent.type === utils_1.AST_NODE_TYPES.ExportDefaultDeclaration) {
|
|
311
311
|
return true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typescript-eslint/eslint-plugin",
|
|
3
|
-
"version": "8.46.4-alpha.
|
|
3
|
+
"version": "8.46.4-alpha.5",
|
|
4
4
|
"description": "TypeScript plugin for ESLint",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -59,10 +59,10 @@
|
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"@eslint-community/regexpp": "^4.10.0",
|
|
62
|
-
"@typescript-eslint/scope-manager": "8.46.4-alpha.
|
|
63
|
-
"@typescript-eslint/type-utils": "8.46.4-alpha.
|
|
64
|
-
"@typescript-eslint/utils": "8.46.4-alpha.
|
|
65
|
-
"@typescript-eslint/visitor-keys": "8.46.4-alpha.
|
|
62
|
+
"@typescript-eslint/scope-manager": "8.46.4-alpha.5",
|
|
63
|
+
"@typescript-eslint/type-utils": "8.46.4-alpha.5",
|
|
64
|
+
"@typescript-eslint/utils": "8.46.4-alpha.5",
|
|
65
|
+
"@typescript-eslint/visitor-keys": "8.46.4-alpha.5",
|
|
66
66
|
"graphemer": "^1.4.0",
|
|
67
67
|
"ignore": "^7.0.0",
|
|
68
68
|
"natural-compare": "^1.4.0",
|
|
@@ -71,8 +71,8 @@
|
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@types/mdast": "^4.0.3",
|
|
73
73
|
"@types/natural-compare": "*",
|
|
74
|
-
"@typescript-eslint/rule-schema-to-typescript-types": "8.46.4-alpha.
|
|
75
|
-
"@typescript-eslint/rule-tester": "8.46.4-alpha.
|
|
74
|
+
"@typescript-eslint/rule-schema-to-typescript-types": "8.46.4-alpha.5",
|
|
75
|
+
"@typescript-eslint/rule-tester": "8.46.4-alpha.5",
|
|
76
76
|
"@vitest/coverage-v8": "^3.1.3",
|
|
77
77
|
"ajv": "^6.12.6",
|
|
78
78
|
"cross-fetch": "*",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"vitest": "^3.1.3"
|
|
93
93
|
},
|
|
94
94
|
"peerDependencies": {
|
|
95
|
-
"@typescript-eslint/parser": "^8.46.4-alpha.
|
|
95
|
+
"@typescript-eslint/parser": "^8.46.4-alpha.5",
|
|
96
96
|
"eslint": "^8.57.0 || ^9.0.0",
|
|
97
97
|
"typescript": ">=4.8.4 <6.0.0"
|
|
98
98
|
},
|