@typescript-eslint/eslint-plugin 8.71.1-alpha.4 → 8.71.1-alpha.6
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.
|
@@ -337,8 +337,9 @@ exports.default = (0, util_1.createRule)({
|
|
|
337
337
|
}
|
|
338
338
|
}
|
|
339
339
|
function checkArguments(node) {
|
|
340
|
-
if (node.
|
|
341
|
-
|
|
340
|
+
if (node.arguments.length === 0 ||
|
|
341
|
+
(node.type === utils_1.AST_NODE_TYPES.CallExpression &&
|
|
342
|
+
isPromiseFinallyMethod(node))) {
|
|
342
343
|
return;
|
|
343
344
|
}
|
|
344
345
|
const tsNode = services.esTreeNodeToTSNodeMap.get(node);
|
|
@@ -3,8 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const scope_manager_1 = require("@typescript-eslint/scope-manager");
|
|
4
4
|
const utils_1 = require("@typescript-eslint/utils");
|
|
5
5
|
const util_1 = require("../util");
|
|
6
|
-
const
|
|
7
|
-
const referenceContainsTypeQuery_1 = require("../util/referenceContainsTypeQuery");
|
|
6
|
+
const isTypeOnlyReference_1 = require("../util/isTypeOnlyReference");
|
|
8
7
|
// this is a superset of DefinitionType which defines sub-types for better granularity
|
|
9
8
|
var VariableType;
|
|
10
9
|
(function (VariableType) {
|
|
@@ -821,8 +820,7 @@ exports.default = (0, util_1.createRule)({
|
|
|
821
820
|
for (const unusedVar of unusedVars) {
|
|
822
821
|
// Report the first declaration.
|
|
823
822
|
if (unusedVar.defs.length > 0) {
|
|
824
|
-
const usedOnlyAsType = unusedVar.references.some(ref => (0,
|
|
825
|
-
(0, referenceContainsTypePredicate_1.referenceContainsTypePredicate)(ref.identifier));
|
|
823
|
+
const usedOnlyAsType = unusedVar.references.some(ref => (0, isTypeOnlyReference_1.isTypeOnlyReference)(unusedVar, ref));
|
|
826
824
|
const messageId = usedOnlyAsType ? 'usedOnlyAsType' : 'unusedVar';
|
|
827
825
|
const isImportUsedOnlyAsType = usedOnlyAsType &&
|
|
828
826
|
unusedVar.defs.some(def => def.type === scope_manager_1.DefinitionType.ImportBinding);
|
|
@@ -4,8 +4,7 @@ exports.collectVariables = collectVariables;
|
|
|
4
4
|
const scope_manager_1 = require("@typescript-eslint/scope-manager");
|
|
5
5
|
const utils_1 = require("@typescript-eslint/utils");
|
|
6
6
|
const isTypeImport_1 = require("./isTypeImport");
|
|
7
|
-
const
|
|
8
|
-
const referenceContainsTypeQuery_1 = require("./referenceContainsTypeQuery");
|
|
7
|
+
const isTypeOnlyReference_1 = require("./isTypeOnlyReference");
|
|
9
8
|
/**
|
|
10
9
|
* This class leverages an AST visitor to mark variables as used via the
|
|
11
10
|
* `eslintUsed` property.
|
|
@@ -289,6 +288,11 @@ const MERGEABLE_TYPES = new Set([
|
|
|
289
288
|
utils_1.AST_NODE_TYPES.TSModuleDeclaration,
|
|
290
289
|
utils_1.AST_NODE_TYPES.TSTypeAliasDeclaration,
|
|
291
290
|
]);
|
|
291
|
+
function isMergedTypeDeclaration(variable, node) {
|
|
292
|
+
return ((node.type === utils_1.AST_NODE_TYPES.TSTypeAliasDeclaration ||
|
|
293
|
+
node.type === utils_1.AST_NODE_TYPES.TSInterfaceDeclaration) &&
|
|
294
|
+
(0, isTypeOnlyReference_1.isMergedTypeValueVariable)(variable));
|
|
295
|
+
}
|
|
292
296
|
/**
|
|
293
297
|
* Determine if the variable is directly exported
|
|
294
298
|
* @param variable the variable to check
|
|
@@ -305,7 +309,7 @@ function isMergeableExported(variable) {
|
|
|
305
309
|
if ((MERGEABLE_TYPES.has(def.node.type) &&
|
|
306
310
|
def.node.parent.type === utils_1.AST_NODE_TYPES.ExportNamedDeclaration) ||
|
|
307
311
|
def.node.parent.type === utils_1.AST_NODE_TYPES.ExportDefaultDeclaration) {
|
|
308
|
-
return
|
|
312
|
+
return !isMergedTypeDeclaration(variable, def.node);
|
|
309
313
|
}
|
|
310
314
|
}
|
|
311
315
|
return false;
|
|
@@ -324,7 +328,8 @@ function isExported(variable) {
|
|
|
324
328
|
else if (definition.type === utils_1.TSESLint.Scope.DefinitionType.Parameter) {
|
|
325
329
|
return false;
|
|
326
330
|
}
|
|
327
|
-
return node
|
|
331
|
+
return (!isMergedTypeDeclaration(variable, node) &&
|
|
332
|
+
node.parent.type.startsWith('Export'));
|
|
328
333
|
});
|
|
329
334
|
}
|
|
330
335
|
const LOGICAL_ASSIGNMENT_OPERATORS = new Set(['??=', '&&=', '||=']);
|
|
@@ -579,9 +584,7 @@ function isUsedVariable(variable) {
|
|
|
579
584
|
rhsNode = getRhsNode(ref, rhsNode);
|
|
580
585
|
return (ref.isRead() &&
|
|
581
586
|
!forItself &&
|
|
582
|
-
!(!isImportedAsType &&
|
|
583
|
-
((0, referenceContainsTypeQuery_1.referenceContainsTypeQuery)(ref.identifier) ||
|
|
584
|
-
(0, referenceContainsTypePredicate_1.referenceContainsTypePredicate)(ref.identifier))) &&
|
|
587
|
+
!(!isImportedAsType && (0, isTypeOnlyReference_1.isTypeOnlyReference)(variable, ref)) &&
|
|
585
588
|
!(isFunctionDefinition && isSelfReference(ref, functionNodes)) &&
|
|
586
589
|
!(isTypeDecl && isInsideOneOf(ref, typeDeclNodes)) &&
|
|
587
590
|
!(isModuleDecl && isSelfReference(ref, moduleDeclNodes)) &&
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ScopeVariable } from '@typescript-eslint/scope-manager';
|
|
2
|
+
import type { TSESLint } from '@typescript-eslint/utils';
|
|
3
|
+
export declare function isMergedTypeValueVariable(variable: ScopeVariable): boolean;
|
|
4
|
+
export declare function isTypeOnlyReference(variable: ScopeVariable, ref: TSESLint.Scope.Reference): boolean;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isMergedTypeValueVariable = isMergedTypeValueVariable;
|
|
4
|
+
exports.isTypeOnlyReference = isTypeOnlyReference;
|
|
5
|
+
const scope_manager_1 = require("@typescript-eslint/scope-manager");
|
|
6
|
+
const referenceContainsTypePredicate_1 = require("./referenceContainsTypePredicate");
|
|
7
|
+
const referenceContainsTypeQuery_1 = require("./referenceContainsTypeQuery");
|
|
8
|
+
function isMergedTypeValueVariable(variable) {
|
|
9
|
+
return ('isTypeVariable' in variable &&
|
|
10
|
+
'isValueVariable' in variable &&
|
|
11
|
+
variable.isTypeVariable &&
|
|
12
|
+
variable.isValueVariable);
|
|
13
|
+
}
|
|
14
|
+
function isTypeOnlyReference(variable, ref) {
|
|
15
|
+
if ((0, referenceContainsTypeQuery_1.referenceContainsTypeQuery)(ref.identifier) ||
|
|
16
|
+
(0, referenceContainsTypePredicate_1.referenceContainsTypePredicate)(ref.identifier)) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
return (variable.defs.some(def => def.type === scope_manager_1.DefinitionType.Variable) &&
|
|
20
|
+
!ref.isValueReference);
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=isTypeOnlyReference.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typescript-eslint/eslint-plugin",
|
|
3
|
-
"version": "8.71.1-alpha.
|
|
3
|
+
"version": "8.71.1-alpha.6",
|
|
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.71.1-alpha.
|
|
51
|
-
"@typescript-eslint/type-utils": "8.71.1-alpha.
|
|
52
|
-
"@typescript-eslint/utils": "8.71.1-alpha.
|
|
53
|
-
"@typescript-eslint/visitor-keys": "8.71.1-alpha.
|
|
50
|
+
"@typescript-eslint/scope-manager": "8.71.1-alpha.6",
|
|
51
|
+
"@typescript-eslint/type-utils": "8.71.1-alpha.6",
|
|
52
|
+
"@typescript-eslint/utils": "8.71.1-alpha.6",
|
|
53
|
+
"@typescript-eslint/visitor-keys": "8.71.1-alpha.6",
|
|
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.71.1-alpha.
|
|
64
|
-
"@typescript-eslint/rule-tester": "8.71.1-alpha.
|
|
63
|
+
"@typescript-eslint/rule-schema-to-typescript-types": "8.71.1-alpha.6",
|
|
64
|
+
"@typescript-eslint/rule-tester": "8.71.1-alpha.6",
|
|
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.71.1-alpha.
|
|
84
|
+
"@typescript-eslint/parser": "^8.71.1-alpha.6",
|
|
85
85
|
"eslint": "^8.57.0 || ^9.0.0 || ^10.0.0",
|
|
86
86
|
"typescript": ">=4.8.4 <6.1.0"
|
|
87
87
|
},
|