-
Notifications
You must be signed in to change notification settings - Fork 0
/
unused.js
59 lines (56 loc) · 1.63 KB
/
unused.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
const depcheck = require('depcheck');
const { writeFileSync } = require('fs');
const { join } = require('path');
// Check dependencies using depcheck
// repo : https://github.com/dimaslanjaka/hexo-seo/blob/master/unused.js
// raw : https://raw.githubusercontent.com/dimaslanjaka/hexo-seo/master/unused.js
// update : curl https://raw.githubusercontent.com/dimaslanjaka/hexo-seo/master/unused.js > unused.js
const options = {
ignoreBinPackage: false, // ignore the packages with bin entry
skipMissing: false, // skip calculation of missing dependencies
ignorePatterns: [
// files matching these patterns will be ignored
'sandbox',
'dist',
'bower_components',
'node_modules',
'docs',
'exclude'
],
ignoreMatches: [
// ignore dependencies that matches these globs
'grunt-*',
'hexo-*',
'@typescript-eslint*'
],
parsers: {
// the target parsers
'**/*.ts': depcheck.parser.typescript,
'**/*.js': depcheck.parser.es6,
'**/*.jsx': depcheck.parser.jsx
},
detectors: [
// the target detectors
depcheck.detector.requireCallExpression,
depcheck.detector.importDeclaration
],
specials: [
// the target special parsers
depcheck.special.eslint,
depcheck.special.webpack
],
package: {
// may specify dependencies instead of parsing package.json
dependencies: {
lodash: '^4.17.15'
},
devDependencies: {
eslint: '^6.6.0'
},
peerDependencies: {},
optionalDependencies: {}
}
};
depcheck(__dirname, options).then((unused) => {
writeFileSync(join(__dirname, 'unused.md'), '```json\n' + JSON.stringify(unused, null, 2) + '\n```');
});