Socket
Socket
Sign inDemoInstall

eslint-plugin-unused-imports

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-unused-imports - npm Package Compare versions

Comparing version 3.1.0 to 3.2.0

.github/workflows/run_test.yml

63

lib/rules/predicates.js

@@ -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"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc