knip 2.33.3 → 2.34.0
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 +27 -7
- package/dist/ConfigurationChief.d.ts +1 -0
- package/dist/ConfigurationChief.js +13 -1
- package/dist/ConfigurationValidator.d.ts +56 -0
- package/dist/ConfigurationValidator.js +1 -0
- package/dist/WorkspaceWorker.d.ts +1 -1
- package/dist/WorkspaceWorker.js +12 -17
- package/dist/binaries/bash-parser.js +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.js +17 -16
- package/dist/plugins/_template/index.js +14 -3
- package/dist/plugins/_template/types.d.ts +1 -0
- package/dist/plugins/angular/index.js +11 -11
- package/dist/plugins/astro/index.d.ts +7 -0
- package/dist/plugins/astro/index.js +10 -0
- package/dist/plugins/ava/index.js +13 -12
- package/dist/plugins/babel/index.js +8 -5
- package/dist/plugins/capacitor/index.js +4 -2
- package/dist/plugins/changesets/index.js +7 -5
- package/dist/plugins/commitizen/index.js +4 -3
- package/dist/plugins/commitizen/types.d.ts +1 -1
- package/dist/plugins/commitlint/index.js +4 -2
- package/dist/plugins/cspell/index.js +4 -2
- package/dist/plugins/cspell/types.d.ts +1 -1
- package/dist/plugins/cypress/index.js +7 -4
- package/dist/plugins/drizzle/index.js +4 -4
- package/dist/plugins/eslint/fallback.js +6 -1
- package/dist/plugins/eslint/helpers.d.ts +2 -2
- package/dist/plugins/eslint/helpers.js +7 -7
- package/dist/plugins/eslint/index.d.ts +0 -1
- package/dist/plugins/eslint/index.js +3 -4
- package/dist/plugins/gatsby/index.js +5 -8
- package/dist/plugins/github-actions/index.d.ts +1 -1
- package/dist/plugins/github-actions/index.js +5 -4
- package/dist/plugins/husky/index.js +4 -2
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/index.js +1 -0
- package/dist/plugins/jest/index.js +8 -8
- package/dist/plugins/jest/types.d.ts +3 -0
- package/dist/plugins/jest/types.js +1 -0
- package/dist/plugins/lefthook/index.js +5 -4
- package/dist/plugins/lint-staged/index.js +7 -7
- package/dist/plugins/markdownlint/index.js +5 -4
- package/dist/plugins/mocha/index.js +8 -7
- package/dist/plugins/mocha/types.d.ts +4 -0
- package/dist/plugins/mocha/types.js +1 -0
- package/dist/plugins/npm-package-json-lint/index.js +4 -3
- package/dist/plugins/nx/index.js +6 -5
- package/dist/plugins/nyc/index.js +4 -3
- package/dist/plugins/nyc/types.d.ts +3 -0
- package/dist/plugins/nyc/types.js +1 -0
- package/dist/plugins/playwright/index.d.ts +1 -1
- package/dist/plugins/playwright/index.js +7 -6
- package/dist/plugins/playwright-ct/index.js +11 -6
- package/dist/plugins/postcss/index.js +6 -5
- package/dist/plugins/prettier/index.js +3 -3
- package/dist/plugins/prettier/types.d.ts +8 -0
- package/dist/plugins/prettier/types.js +1 -0
- package/dist/plugins/release-it/index.js +10 -9
- package/dist/plugins/remark/index.js +6 -5
- package/dist/plugins/remix/index.js +1 -5
- package/dist/plugins/rollup/index.js +1 -1
- package/dist/plugins/semantic-release/index.js +5 -4
- package/dist/plugins/semantic-release/types.d.ts +1 -1
- package/dist/plugins/storybook/index.js +13 -11
- package/dist/plugins/stryker/index.js +9 -6
- package/dist/plugins/stylelint/index.js +6 -5
- package/dist/plugins/typedoc/index.js +4 -3
- package/dist/plugins/typedoc/types.d.ts +1 -1
- package/dist/plugins/typescript/index.js +13 -10
- package/dist/plugins/vite/index.js +4 -2
- package/dist/plugins/vitest/index.d.ts +1 -1
- package/dist/plugins/vitest/index.js +8 -8
- package/dist/plugins/webpack/index.js +25 -15
- package/dist/plugins/webpack/types.d.ts +2 -1
- package/dist/types/config.d.ts +1 -1
- package/dist/types/plugins.d.ts +1 -1
- package/dist/typescript/SourceFileManager.js +3 -3
- package/dist/typescript/ast-helpers.d.ts +2 -1
- package/dist/typescript/ast-helpers.js +3 -0
- package/dist/typescript/visitors/exports/exportKeyword.js +5 -2
- package/dist/util/cli-arguments.d.ts +2 -1
- package/dist/util/cli-arguments.js +2 -0
- package/dist/util/compilers.d.ts +10 -0
- package/dist/util/debug.d.ts +3 -3
- package/dist/util/debug.js +10 -8
- package/dist/util/glob.js +1 -1
- package/dist/util/modules.js +1 -1
- package/dist/util/path.js +4 -2
- package/dist/util/plugin.js +7 -1
- package/dist/util/require.js +1 -1
- package/dist/util/unwrapFunction.d.ts +1 -0
- package/dist/util/unwrapFunction.js +13 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/schema.json +4 -0
package/dist/util/debug.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import util from 'node:util';
|
|
2
|
+
import chalk from 'chalk';
|
|
2
3
|
import parsedArgValues from './cli-arguments.js';
|
|
3
4
|
const { debug, 'debug-file-filter': debugFileFilter } = parsedArgValues;
|
|
4
5
|
const IS_ENABLED = debug ?? false;
|
|
5
6
|
const FILE_FILTER = debugFileFilter;
|
|
6
7
|
const inspectOptions = { maxArrayLength: null, depth: null, colors: true };
|
|
8
|
+
const ctx = (text) => typeof text === 'string' ? chalk.yellow(`[${text}]`) : `${chalk.yellow(`[${text[0]}]`)} ${chalk.cyan(text[1])}`;
|
|
7
9
|
const logArray = (collection) => {
|
|
8
10
|
if (FILE_FILTER) {
|
|
9
11
|
const fileFilter = new RegExp(FILE_FILTER);
|
|
@@ -14,21 +16,21 @@ const logArray = (collection) => {
|
|
|
14
16
|
console.log(util.inspect(collection.sort(), inspectOptions));
|
|
15
17
|
}
|
|
16
18
|
};
|
|
17
|
-
export const debugLog = (message) => {
|
|
19
|
+
export const debugLog = (context, message) => {
|
|
18
20
|
if (!IS_ENABLED)
|
|
19
21
|
return;
|
|
20
|
-
console.log(
|
|
22
|
+
console.log(`${ctx(context)} ${message}`);
|
|
21
23
|
};
|
|
22
|
-
export const debugLogObject = (name, obj) => {
|
|
24
|
+
export const debugLogObject = (context, name, obj) => {
|
|
23
25
|
if (!IS_ENABLED)
|
|
24
26
|
return;
|
|
25
|
-
console.log(
|
|
26
|
-
console.log(util.inspect(obj, inspectOptions));
|
|
27
|
+
console.log(`${ctx(context)} ${name}`);
|
|
28
|
+
console.log(util.inspect(typeof obj === 'function' ? obj() : obj, inspectOptions));
|
|
27
29
|
};
|
|
28
|
-
export const debugLogArray = (
|
|
30
|
+
export const debugLogArray = (context, message, elements) => {
|
|
29
31
|
if (!IS_ENABLED)
|
|
30
32
|
return;
|
|
31
|
-
const collection = Array.from(
|
|
32
|
-
console.debug(
|
|
33
|
+
const collection = Array.from(elements);
|
|
34
|
+
console.debug(`${ctx(context)} ${message} (${collection.length})`);
|
|
33
35
|
logArray(collection);
|
|
34
36
|
};
|
package/dist/util/glob.js
CHANGED
|
@@ -24,7 +24,7 @@ const glob = async ({ cwd, workingDir = cwd, patterns, ignore = [], gitignore =
|
|
|
24
24
|
if (globPatterns[0].startsWith('!'))
|
|
25
25
|
return [];
|
|
26
26
|
const ignorePatterns = compact([...ignore, ...GLOBAL_IGNORE_PATTERNS]);
|
|
27
|
-
debugLogObject(
|
|
27
|
+
debugLogObject(relativePath || ROOT_WORKSPACE_NAME, `Glob options`, { cwd, globPatterns, ignorePatterns });
|
|
28
28
|
return globby(globPatterns, {
|
|
29
29
|
cwd,
|
|
30
30
|
ignore: ignorePatterns,
|
package/dist/util/modules.js
CHANGED
|
@@ -51,4 +51,4 @@ export const getEntryPathFromManifest = (cwd, dir, manifest) => {
|
|
|
51
51
|
}
|
|
52
52
|
return _glob({ cwd, workingDir: dir, patterns: Array.from(entryPaths) });
|
|
53
53
|
};
|
|
54
|
-
export const sanitizeSpecifier = (specifier) => specifier.replace(/^([?!|-]+)?([
|
|
54
|
+
export const sanitizeSpecifier = (specifier) => specifier.replace(/^([?!|-]+)?([^!?:]+).*/, '$2');
|
package/dist/util/path.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
+
import parsedArgValues from './cli-arguments.js';
|
|
3
|
+
const { directory } = parsedArgValues;
|
|
2
4
|
const isAbsolute = path.isAbsolute;
|
|
3
5
|
export const dirname = path.posix.dirname;
|
|
4
6
|
export const extname = path.posix.extname;
|
|
5
7
|
export const join = path.posix.join;
|
|
6
8
|
export const toPosix = (value) => value.split(path.sep).join(path.posix.sep);
|
|
7
|
-
export const cwd = toPosix(process.cwd());
|
|
9
|
+
export const cwd = directory ? path.posix.resolve(directory) : toPosix(process.cwd());
|
|
8
10
|
export const resolve = (...paths) => paths.length === 1 ? path.posix.join(cwd, paths[0]) : path.posix.resolve(...paths);
|
|
9
|
-
export const relative = (from, to) => path.
|
|
11
|
+
export const relative = (from, to) => toPosix(path.relative(to ? from : cwd, to ?? from));
|
|
10
12
|
export const isInNodeModules = (filePath) => filePath.includes('node_modules');
|
|
11
13
|
export const toAbsolute = (id, base) => (isAbsolute(id) ? id : join(base, id));
|
|
12
14
|
export const toRelative = (id) => (isAbsolute(id) ? relative(id) : id);
|
package/dist/util/plugin.js
CHANGED
|
@@ -19,7 +19,13 @@ export const normalizePluginConfig = (pluginConfig) => {
|
|
|
19
19
|
}
|
|
20
20
|
else {
|
|
21
21
|
const isObject = typeof pluginConfig !== 'string' && !Array.isArray(pluginConfig);
|
|
22
|
-
const config = isObject
|
|
22
|
+
const config = isObject
|
|
23
|
+
? 'config' in pluginConfig
|
|
24
|
+
? arrayify(pluginConfig.config)
|
|
25
|
+
: null
|
|
26
|
+
: pluginConfig
|
|
27
|
+
? arrayify(pluginConfig)
|
|
28
|
+
: null;
|
|
23
29
|
const entry = isObject && 'entry' in pluginConfig ? arrayify(pluginConfig.entry) : null;
|
|
24
30
|
const project = isObject && 'project' in pluginConfig ? arrayify(pluginConfig.project) : entry;
|
|
25
31
|
return { config, entry, project };
|
package/dist/util/require.js
CHANGED
|
@@ -12,7 +12,7 @@ const tryResolve = (specifier, from) => {
|
|
|
12
12
|
return resolve(specifier);
|
|
13
13
|
}
|
|
14
14
|
catch {
|
|
15
|
-
debugLog(`Unable to resolve ${specifier} (from ${from})`);
|
|
15
|
+
debugLog('*', `Unable to resolve ${specifier} (from ${from})`);
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
18
|
const resolveSpecifier = (dir, specifier) => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const unwrapFunction: (possibleFunction: unknown) => Promise<any>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { debugLogObject } from './debug.js';
|
|
2
|
+
export const unwrapFunction = async (possibleFunction) => {
|
|
3
|
+
if (typeof possibleFunction === 'function') {
|
|
4
|
+
try {
|
|
5
|
+
return await possibleFunction();
|
|
6
|
+
}
|
|
7
|
+
catch (error) {
|
|
8
|
+
debugLogObject('*', 'Error executing function:', error);
|
|
9
|
+
throw error;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return possibleFunction;
|
|
13
|
+
};
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "2.
|
|
1
|
+
export declare const version = "2.34.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '2.
|
|
1
|
+
export const version = '2.34.0';
|
package/package.json
CHANGED
package/schema.json
CHANGED
|
@@ -224,6 +224,10 @@
|
|
|
224
224
|
"title": "angular plugin configuration (https://github.com/webpro/knip/blob/main/src/plugins/angular/README.md)",
|
|
225
225
|
"$ref": "#/definitions/plugin"
|
|
226
226
|
},
|
|
227
|
+
"astro": {
|
|
228
|
+
"title": "astro plugin configuration (https://github.com/webpro/knip/blob/main/src/plugins/astro/README.md)",
|
|
229
|
+
"$ref": "#/definitions/plugin"
|
|
230
|
+
},
|
|
227
231
|
"ava": {
|
|
228
232
|
"title": "ava plugin configuration (https://github.com/webpro/knip/blob/main/src/plugins/ava/README.md)",
|
|
229
233
|
"$ref": "#/definitions/plugin"
|