@typescript-eslint/eslint-plugin 8.25.1-alpha.13 → 8.25.1-alpha.14
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.
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"no-unused-vars.d.ts","sourceRoot":"","sources":["../../src/rules/no-unused-vars.ts"],"names":[],"mappings":"AAUA,OAAO,EAAkB,QAAQ,EAAE,MAAM,0BAA0B,CAAC;
|
1
|
+
{"version":3,"file":"no-unused-vars.d.ts","sourceRoot":"","sources":["../../src/rules/no-unused-vars.ts"],"names":[],"mappings":"AAUA,OAAO,EAAkB,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAepE,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG,gBAAgB,GAAG,gBAAgB,CAAC;AAC3E,MAAM,MAAM,OAAO,GAAG;IAClB,KAAK,GACL,OAAO,GACP;QACE,IAAI,CAAC,EAAE,YAAY,GAAG,KAAK,GAAG,MAAM,CAAC;QACrC,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,YAAY,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;QAC9B,yBAAyB,CAAC,EAAE,MAAM,CAAC;QACnC,8BAA8B,CAAC,EAAE,MAAM,CAAC;QACxC,8BAA8B,CAAC,EAAE,OAAO,CAAC;QACzC,kBAAkB,CAAC,EAAE,OAAO,CAAC;QAC7B,uBAAuB,CAAC,EAAE,OAAO,CAAC;QAClC,IAAI,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC;QACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;KAC5B;CACJ,CAAC;;AA0BF,wBAuuBG"}
|
@@ -396,24 +396,40 @@ exports.default = (0, util_1.createRule)({
|
|
396
396
|
return unusedVariablesReturn;
|
397
397
|
}
|
398
398
|
return {
|
399
|
-
// declaration file handling
|
400
|
-
[ambientDeclarationSelector(utils_1.AST_NODE_TYPES.Program
|
399
|
+
// top-level declaration file handling
|
400
|
+
[ambientDeclarationSelector(utils_1.AST_NODE_TYPES.Program)](node) {
|
401
401
|
if (!(0, util_1.isDefinitionFile)(context.filename)) {
|
402
402
|
return;
|
403
403
|
}
|
404
|
+
const moduleDecl = (0, util_1.nullThrows)(node.parent, util_1.NullThrowsReasons.MissingParent);
|
405
|
+
if (checkForOverridingExportStatements(moduleDecl)) {
|
406
|
+
return;
|
407
|
+
}
|
404
408
|
markDeclarationChildAsUsed(node);
|
405
409
|
},
|
406
410
|
// children of a namespace that is a child of a declared namespace are auto-exported
|
407
|
-
[ambientDeclarationSelector('TSModuleDeclaration[declare = true] > TSModuleBlock TSModuleDeclaration > TSModuleBlock'
|
411
|
+
[ambientDeclarationSelector('TSModuleDeclaration[declare = true] > TSModuleBlock TSModuleDeclaration > TSModuleBlock')](node) {
|
412
|
+
const moduleDecl = (0, util_1.nullThrows)(node.parent.parent, util_1.NullThrowsReasons.MissingParent);
|
413
|
+
if (checkForOverridingExportStatements(moduleDecl)) {
|
414
|
+
return;
|
415
|
+
}
|
408
416
|
markDeclarationChildAsUsed(node);
|
409
417
|
},
|
410
418
|
// declared namespace handling
|
411
|
-
[ambientDeclarationSelector('TSModuleDeclaration[declare = true] > TSModuleBlock'
|
419
|
+
[ambientDeclarationSelector('TSModuleDeclaration[declare = true] > TSModuleBlock')](node) {
|
420
|
+
const moduleDecl = (0, util_1.nullThrows)(node.parent.parent, util_1.NullThrowsReasons.MissingParent);
|
421
|
+
if (checkForOverridingExportStatements(moduleDecl)) {
|
422
|
+
return;
|
423
|
+
}
|
424
|
+
markDeclarationChildAsUsed(node);
|
425
|
+
},
|
426
|
+
// namespace handling in definition files
|
427
|
+
[ambientDeclarationSelector('TSModuleDeclaration > TSModuleBlock')](node) {
|
428
|
+
if (!(0, util_1.isDefinitionFile)(context.filename)) {
|
429
|
+
return;
|
430
|
+
}
|
412
431
|
const moduleDecl = (0, util_1.nullThrows)(node.parent.parent, util_1.NullThrowsReasons.MissingParent);
|
413
|
-
|
414
|
-
// all other statements are not automatically exported in this case
|
415
|
-
if (moduleDecl.id.type === utils_1.AST_NODE_TYPES.Literal &&
|
416
|
-
checkModuleDeclForExportEquals(moduleDecl)) {
|
432
|
+
if (checkForOverridingExportStatements(moduleDecl)) {
|
417
433
|
return;
|
418
434
|
}
|
419
435
|
markDeclarationChildAsUsed(node);
|
@@ -467,23 +483,20 @@ exports.default = (0, util_1.createRule)({
|
|
467
483
|
}
|
468
484
|
},
|
469
485
|
};
|
470
|
-
function
|
486
|
+
function checkForOverridingExportStatements(node) {
|
471
487
|
const cached = MODULE_DECL_CACHE.get(node);
|
472
488
|
if (cached != null) {
|
473
489
|
return cached;
|
474
490
|
}
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
return true;
|
480
|
-
}
|
481
|
-
}
|
491
|
+
const body = getStatementsOfNode(node);
|
492
|
+
if (hasOverridingExportStatement(body)) {
|
493
|
+
MODULE_DECL_CACHE.set(node, true);
|
494
|
+
return true;
|
482
495
|
}
|
483
496
|
MODULE_DECL_CACHE.set(node, false);
|
484
497
|
return false;
|
485
498
|
}
|
486
|
-
function ambientDeclarationSelector(parent
|
499
|
+
function ambientDeclarationSelector(parent) {
|
487
500
|
return [
|
488
501
|
// Types are ambiently exported
|
489
502
|
`${parent} > :matches(${[
|
@@ -497,7 +510,7 @@ exports.default = (0, util_1.createRule)({
|
|
497
510
|
utils_1.AST_NODE_TYPES.TSEnumDeclaration,
|
498
511
|
utils_1.AST_NODE_TYPES.TSModuleDeclaration,
|
499
512
|
utils_1.AST_NODE_TYPES.VariableDeclaration,
|
500
|
-
].join(', ')})
|
513
|
+
].join(', ')})`,
|
501
514
|
].join(', ');
|
502
515
|
}
|
503
516
|
function markDeclarationChildAsUsed(node) {
|
@@ -546,6 +559,27 @@ exports.default = (0, util_1.createRule)({
|
|
546
559
|
}
|
547
560
|
},
|
548
561
|
});
|
562
|
+
function hasOverridingExportStatement(body) {
|
563
|
+
for (const statement of body) {
|
564
|
+
if ((statement.type === utils_1.AST_NODE_TYPES.ExportNamedDeclaration &&
|
565
|
+
statement.declaration == null) ||
|
566
|
+
statement.type === utils_1.AST_NODE_TYPES.ExportAllDeclaration ||
|
567
|
+
statement.type === utils_1.AST_NODE_TYPES.TSExportAssignment) {
|
568
|
+
return true;
|
569
|
+
}
|
570
|
+
if (statement.type === utils_1.AST_NODE_TYPES.ExportDefaultDeclaration &&
|
571
|
+
statement.declaration.type === utils_1.AST_NODE_TYPES.Identifier) {
|
572
|
+
return true;
|
573
|
+
}
|
574
|
+
}
|
575
|
+
return false;
|
576
|
+
}
|
577
|
+
function getStatementsOfNode(block) {
|
578
|
+
if (block.type === utils_1.AST_NODE_TYPES.Program) {
|
579
|
+
return block.body;
|
580
|
+
}
|
581
|
+
return block.body.body;
|
582
|
+
}
|
549
583
|
/*
|
550
584
|
|
551
585
|
###### TODO ######
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@typescript-eslint/eslint-plugin",
|
3
|
-
"version": "8.25.1-alpha.
|
3
|
+
"version": "8.25.1-alpha.14",
|
4
4
|
"description": "TypeScript plugin for ESLint",
|
5
5
|
"files": [
|
6
6
|
"dist",
|
@@ -62,10 +62,10 @@
|
|
62
62
|
},
|
63
63
|
"dependencies": {
|
64
64
|
"@eslint-community/regexpp": "^4.10.0",
|
65
|
-
"@typescript-eslint/scope-manager": "8.25.1-alpha.
|
66
|
-
"@typescript-eslint/type-utils": "8.25.1-alpha.
|
67
|
-
"@typescript-eslint/utils": "8.25.1-alpha.
|
68
|
-
"@typescript-eslint/visitor-keys": "8.25.1-alpha.
|
65
|
+
"@typescript-eslint/scope-manager": "8.25.1-alpha.14",
|
66
|
+
"@typescript-eslint/type-utils": "8.25.1-alpha.14",
|
67
|
+
"@typescript-eslint/utils": "8.25.1-alpha.14",
|
68
|
+
"@typescript-eslint/visitor-keys": "8.25.1-alpha.14",
|
69
69
|
"graphemer": "^1.4.0",
|
70
70
|
"ignore": "^5.3.1",
|
71
71
|
"natural-compare": "^1.4.0",
|
@@ -76,8 +76,8 @@
|
|
76
76
|
"@types/marked": "^5.0.2",
|
77
77
|
"@types/mdast": "^4.0.3",
|
78
78
|
"@types/natural-compare": "*",
|
79
|
-
"@typescript-eslint/rule-schema-to-typescript-types": "8.25.1-alpha.
|
80
|
-
"@typescript-eslint/rule-tester": "8.25.1-alpha.
|
79
|
+
"@typescript-eslint/rule-schema-to-typescript-types": "8.25.1-alpha.14",
|
80
|
+
"@typescript-eslint/rule-tester": "8.25.1-alpha.14",
|
81
81
|
"ajv": "^6.12.6",
|
82
82
|
"cross-env": "^7.0.3",
|
83
83
|
"cross-fetch": "*",
|