Skip to content

Instantly share code, notes, and snippets.

@jrgleason
Created April 26, 2019 15:32
Show Gist options
  • Save jrgleason/07b867ba77d9766b87c6946a158bec56 to your computer and use it in GitHub Desktop.
Save jrgleason/07b867ba77d9766b87c6946a158bec56 to your computer and use it in GitHub Desktop.
import depcheck from 'depcheck';
import path from "path";
const options = {
withoutDev: false, // [DEPRECATED] check against devDependencies
ignoreBinPackage: false, // ignore the packages with bin entry
skipMissing: false, // skip calculation of missing dependencies
ignoreDirs: [ // folder with these names will be ignored
'dist'
],
parsers: { // the target parsers
'*.js': depcheck.parser.es6
},
detectors: [ // the target detectors
depcheck.detector.requireCallExpression,
depcheck.detector.importDeclaration
],
specials: [ // the target special parsers
depcheck.special.eslint
]
};
depcheck(path.join(path.resolve(), "./"),options, (unused) => {
console.log(`Unused ${unused.dependencies}`); // an array containing the unused dependencies
console.log(`Unused dev ${unused.devDependencies}`); // an array containing the unused devDependencies
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment