knip 0.13.0 → 0.13.2
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.
- package/README.md +1 -1
- package/dist/cli.js +2 -1
- package/dist/index.js +1 -1
- package/dist/util/config.js +2 -1
- package/dist/util/loader.d.ts +2 -0
- package/dist/util/loader.js +17 -0
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -19,6 +19,7 @@ The dots don't connect themselves. This is where Knip comes in:
|
|
|
19
19
|
- [x] Finds **unused files, dependencies and exports**.
|
|
20
20
|
- [x] Finds used dependencies not listed in `package.json`.
|
|
21
21
|
- [x] Finds duplicate exports.
|
|
22
|
+
- [x] Find unused members of classes and enums
|
|
22
23
|
- [x] Supports JavaScript (without `tsconfig.json`, or TypeScript `allowJs: true`).
|
|
23
24
|
- [x] Features multiple [reporters][1] and supports [custom reporters][2] (think JSON and `CODEOWNERS`)
|
|
24
25
|
- [x] Run Knip as part of your CI environment to detect issues and prevent regressions.
|
|
@@ -39,7 +40,6 @@ over new features:
|
|
|
39
40
|
|
|
40
41
|
### Upcoming Features
|
|
41
42
|
|
|
42
|
-
- [ ] Find unused members of classes and enums (#11 and #20).
|
|
43
43
|
- [ ] Custom dependency resolvers: find dependencies used in npm scripts.
|
|
44
44
|
- [ ] Custom dependency resolvers: find unused and unlisted plugins for Webpack, ESLint & Babel, etc. (#7)
|
|
45
45
|
- [ ] Smart default configurations and more fine-grained configuration options.
|
package/dist/cli.js
CHANGED
|
@@ -6,6 +6,7 @@ import { printHelp } from './help.js';
|
|
|
6
6
|
import reporters from './reporters/index.js';
|
|
7
7
|
import { ConfigurationError } from './util/errors.js';
|
|
8
8
|
import { measure } from './util/performance.js';
|
|
9
|
+
import load from './util/loader.js';
|
|
9
10
|
const { values: { help, dir, config: configFilePath, tsConfig: tsConfigFilePath, include = [], exclude = [], ignore = [], 'no-gitignore': isNoGitIgnore = false, dev: isDev = false, 'include-entry-files': isIncludeEntryFiles = false, 'no-progress': noProgress = false, reporter = 'symbols', 'reporter-options': reporterOptions = '', 'max-issues': maxIssues = '0', debug: isDebug = false, 'debug-level': debugLevel = '1', }, } = parsedArgs;
|
|
10
11
|
if (help) {
|
|
11
12
|
printHelp();
|
|
@@ -14,7 +15,7 @@ if (help) {
|
|
|
14
15
|
const cwd = process.cwd();
|
|
15
16
|
const workingDir = dir ? path.resolve(dir) : cwd;
|
|
16
17
|
const isShowProgress = !isDebug && noProgress === false && process.stdout.isTTY && typeof process.stdout.cursorTo === 'function';
|
|
17
|
-
const printReport = reporter in reporters ? reporters[reporter] : await
|
|
18
|
+
const printReport = reporter in reporters ? reporters[reporter] : await load(path.join(workingDir, reporter));
|
|
18
19
|
const run = async () => {
|
|
19
20
|
try {
|
|
20
21
|
const { report, issues, counters } = await main({
|
package/dist/index.js
CHANGED
package/dist/util/config.js
CHANGED
|
@@ -15,7 +15,8 @@ export const resolveConfig = (importedConfiguration, options) => {
|
|
|
15
15
|
resolvedConfig = resolvedConfig.dev;
|
|
16
16
|
}
|
|
17
17
|
if (!resolvedConfig.entryFiles || !resolvedConfig.projectFiles) {
|
|
18
|
-
console.info(`Add
|
|
18
|
+
console.info(`Add "entryFiles" and "projectFiles" properties at root level`);
|
|
19
|
+
configKeys.length && console.info(`or use --dir and match one of: ${configKeys.join(', ')}\n`);
|
|
19
20
|
return;
|
|
20
21
|
}
|
|
21
22
|
resolvedConfig.dev = Boolean(typeof resolvedConfig.dev === 'boolean' ? resolvedConfig.dev : isDev);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { register } from 'esbuild-register/dist/node.js';
|
|
3
|
+
import { loadJSON } from './fs.js';
|
|
4
|
+
register();
|
|
5
|
+
export default async (filePath) => {
|
|
6
|
+
if (path.extname(filePath) === '.json' || /rc$/.test(filePath)) {
|
|
7
|
+
return loadJSON(filePath);
|
|
8
|
+
}
|
|
9
|
+
try {
|
|
10
|
+
const imported = await import(filePath);
|
|
11
|
+
return imported.default ?? imported;
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
console.log('Failed to load ' + filePath);
|
|
15
|
+
console.log(error);
|
|
16
|
+
}
|
|
17
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "knip",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.2",
|
|
4
4
|
"description": "Find unused files, dependencies and exports in your TypeScript and JavaScript project",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"find",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"type": "module",
|
|
27
27
|
"scripts": {
|
|
28
|
-
"knip": "node ./dist/cli.js",
|
|
28
|
+
"knip": "node ./dist/cli.js --exclude dependencies",
|
|
29
29
|
"test": "globstar -- node --loader tsx --test \"test/*.spec.ts\"",
|
|
30
30
|
"watch": "tsc --watch",
|
|
31
31
|
"build": "rm -rf dist && tsc",
|
|
@@ -44,6 +44,8 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@snyk/github-codeowners": "1.0.0",
|
|
46
46
|
"easy-table": "1.2.0",
|
|
47
|
+
"esbuild": "0.15.13",
|
|
48
|
+
"esbuild-register": "3.3.3",
|
|
47
49
|
"globby": "13.1.2",
|
|
48
50
|
"micromatch": "4.0.5",
|
|
49
51
|
"summary": "2.1.0",
|