eslint-plugin-unused-imports
Advanced tools
Comparing version 3.1.0 to 3.2.0
@@ -1,49 +0,21 @@ | ||
exports.unusedVarsPredicate = (problem, context) => { | ||
const { node } = problem; | ||
const { parent } = node; | ||
const makePredicate = | ||
(isImport, addFixer) => | ||
(problem, { sourceCode }) => { | ||
const { parent } = | ||
problem.node ?? | ||
// typescript-eslint >= 7.8 sets a range instead of a node | ||
sourceCode.getNodeByRangeIndex(sourceCode.getIndexFromLoc(problem.loc.start)); | ||
return parent | ||
? /^Import(|Default|Namespace)Specifier$/.test(parent.type) == isImport && | ||
Object.assign(problem, addFixer?.(parent, sourceCode)) | ||
: problem; // If parent is null just let the composed rule handle it | ||
}; | ||
// If parent is null just let the composed rule handle it | ||
if (parent == null) { | ||
return problem; | ||
} | ||
exports.unusedVarsPredicate = makePredicate(false); | ||
// Remove these 3 cases, pass any other trough. | ||
switch (parent.type) { | ||
case "ImportSpecifier": | ||
case "ImportDefaultSpecifier": | ||
case "ImportNamespaceSpecifier": | ||
return false; | ||
default: | ||
return problem; | ||
} | ||
}; | ||
const commaFilter = { filter: (token) => token.value === "," }; | ||
const includeCommentsFilter = { includeComments: true }; | ||
exports.unusedImportsPredicate = (problem, context) => { | ||
const { sourceCode } = context; | ||
const { node } = problem; | ||
const { parent } = node; | ||
// If parent is null just let the composed rule handle it | ||
if (parent == null) { | ||
return problem; | ||
} | ||
// Only handle these 3 cases. | ||
switch (parent.type) { | ||
case "ImportSpecifier": | ||
case "ImportDefaultSpecifier": | ||
case "ImportNamespaceSpecifier": | ||
break; | ||
default: | ||
return false; | ||
} | ||
problem.fix = (fixer) => { | ||
if (!parent) { | ||
return null; | ||
} | ||
exports.unusedImportsPredicate = makePredicate(true, (parent, sourceCode) => ({ | ||
fix(fixer) { | ||
const grandParent = parent.parent; | ||
@@ -102,4 +74,3 @@ | ||
]); | ||
}; | ||
return problem; | ||
}; | ||
}, | ||
})); |
{ | ||
"name": "eslint-plugin-unused-imports", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"description": "Report and remove unused es6 modules", | ||
@@ -32,6 +32,6 @@ "keywords": [ | ||
"devDependencies": { | ||
"@typescript-eslint/eslint-plugin": "^7.0.0", | ||
"@typescript-eslint/parser": "^7.0.0", | ||
"eslint": "^8.0.1", | ||
"jest": "^29.2.5", | ||
"@typescript-eslint/eslint-plugin": "^7.8.0", | ||
"@typescript-eslint/parser": "^7.8.0", | ||
"eslint": "^8.57.0", | ||
"jest": "^29.7.0", | ||
"prettier": "^3.2.5", | ||
@@ -38,0 +38,0 @@ "ts-jest": "^29.1.2" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
15673
17
0
283