knip 5.1.2 → 5.1.3
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/dist/ConfigurationChief.d.ts +3 -3
- package/dist/ConfigurationValidator.d.ts +21 -21
- package/dist/ProjectPrincipal.d.ts +1 -1
- package/dist/ProjectPrincipal.js +3 -5
- package/dist/WorkspaceWorker.d.ts +2 -2
- package/dist/WorkspaceWorker.js +61 -44
- package/dist/binaries/index.js +2 -2
- package/dist/binaries/resolvers/index.d.ts +12 -12
- package/dist/compilers/index.d.ts +6 -7
- package/dist/compilers/index.js +0 -3
- package/dist/constants.d.ts +1 -2
- package/dist/constants.js +8 -4
- package/dist/plugins/_template/index.d.ts +10 -9
- package/dist/plugins/_template/index.js +16 -30
- package/dist/plugins/angular/index.d.ts +8 -6
- package/dist/plugins/angular/index.js +17 -22
- package/dist/plugins/astro/index.d.ts +7 -7
- package/dist/plugins/astro/index.js +14 -17
- package/dist/plugins/ava/index.d.ts +9 -7
- package/dist/plugins/ava/index.js +19 -21
- package/dist/plugins/babel/helpers.js +1 -1
- package/dist/plugins/babel/index.d.ts +7 -7
- package/dist/plugins/babel/index.js +15 -26
- package/dist/plugins/capacitor/index.d.ts +7 -6
- package/dist/plugins/capacitor/index.js +11 -18
- package/dist/plugins/changesets/index.d.ts +7 -6
- package/dist/plugins/changesets/index.js +14 -21
- package/dist/plugins/changesets/types.d.ts +3 -0
- package/dist/plugins/changesets/types.js +1 -0
- package/dist/plugins/commitizen/index.d.ts +8 -7
- package/dist/plugins/commitizen/index.js +13 -21
- package/dist/plugins/commitlint/index.d.ts +9 -6
- package/dist/plugins/commitlint/index.js +11 -19
- package/dist/plugins/cspell/index.d.ts +7 -6
- package/dist/plugins/cspell/index.js +12 -20
- package/dist/plugins/cypress/index.d.ts +7 -7
- package/dist/plugins/cypress/index.js +13 -21
- package/dist/plugins/drizzle/index.d.ts +7 -6
- package/dist/plugins/drizzle/index.js +13 -16
- package/dist/plugins/eleventy/index.d.ts +11 -9
- package/dist/plugins/eleventy/index.js +35 -41
- package/dist/plugins/eslint/helpers.d.ts +3 -5
- package/dist/plugins/eslint/helpers.js +10 -15
- package/dist/plugins/eslint/index.d.ts +10 -8
- package/dist/plugins/eslint/index.js +15 -29
- package/dist/plugins/gatsby/index.d.ts +8 -7
- package/dist/plugins/gatsby/index.js +15 -22
- package/dist/plugins/github-actions/index.d.ts +6 -6
- package/dist/plugins/github-actions/index.js +15 -25
- package/dist/plugins/graphql-codegen/index.d.ts +8 -7
- package/dist/plugins/graphql-codegen/index.js +15 -23
- package/dist/plugins/husky/index.d.ts +6 -6
- package/dist/plugins/husky/index.js +10 -16
- package/dist/plugins/jest/index.d.ts +9 -7
- package/dist/plugins/jest/index.js +50 -31
- package/dist/plugins/lefthook/index.d.ts +6 -6
- package/dist/plugins/lefthook/index.js +19 -24
- package/dist/plugins/lint-staged/index.d.ts +8 -7
- package/dist/plugins/lint-staged/index.js +16 -23
- package/dist/plugins/linthtml/index.d.ts +8 -7
- package/dist/plugins/linthtml/index.js +16 -24
- package/dist/plugins/markdownlint/index.d.ts +7 -6
- package/dist/plugins/markdownlint/index.js +12 -17
- package/dist/plugins/mocha/index.d.ts +9 -7
- package/dist/plugins/mocha/index.js +19 -22
- package/dist/plugins/msw/index.d.ts +8 -7
- package/dist/plugins/msw/index.js +12 -15
- package/dist/plugins/netlify/index.d.ts +9 -7
- package/dist/plugins/netlify/index.js +23 -27
- package/dist/plugins/next/index.d.ts +6 -7
- package/dist/plugins/next/index.js +10 -18
- package/dist/plugins/node-test-runner/index.d.ts +5 -6
- package/dist/plugins/node-test-runner/index.js +6 -18
- package/dist/plugins/npm-package-json-lint/index.d.ts +8 -7
- package/dist/plugins/npm-package-json-lint/index.js +12 -19
- package/dist/plugins/nx/index.d.ts +7 -6
- package/dist/plugins/nx/index.js +18 -27
- package/dist/plugins/nyc/index.d.ts +7 -6
- package/dist/plugins/nyc/index.js +11 -17
- package/dist/plugins/playwright/index.d.ts +11 -13
- package/dist/plugins/playwright/index.js +23 -30
- package/dist/plugins/playwright-ct/index.d.ts +8 -7
- package/dist/plugins/playwright-ct/index.js +12 -24
- package/dist/plugins/postcss/index.d.ts +7 -6
- package/dist/plugins/postcss/index.js +12 -21
- package/dist/plugins/prettier/index.d.ts +7 -6
- package/dist/plugins/prettier/index.js +14 -20
- package/dist/plugins/release-it/index.d.ts +8 -7
- package/dist/plugins/release-it/index.js +18 -27
- package/dist/plugins/remark/index.d.ts +8 -7
- package/dist/plugins/remark/index.js +13 -28
- package/dist/plugins/remix/index.d.ts +6 -7
- package/dist/plugins/remix/index.js +10 -20
- package/dist/plugins/rollup/index.d.ts +5 -6
- package/dist/plugins/rollup/index.js +8 -16
- package/dist/plugins/semantic-release/index.d.ts +8 -7
- package/dist/plugins/semantic-release/index.js +13 -25
- package/dist/plugins/sentry/index.d.ts +5 -6
- package/dist/plugins/sentry/index.js +8 -16
- package/dist/plugins/storybook/index.d.ts +10 -8
- package/dist/plugins/storybook/index.js +28 -35
- package/dist/plugins/stryker/index.d.ts +7 -6
- package/dist/plugins/stryker/index.js +10 -18
- package/dist/plugins/stylelint/index.d.ts +7 -6
- package/dist/plugins/stylelint/index.js +13 -23
- package/dist/plugins/svelte/index.d.ts +7 -8
- package/dist/plugins/svelte/index.js +13 -23
- package/dist/plugins/tailwind/index.d.ts +5 -6
- package/dist/plugins/tailwind/index.js +8 -14
- package/dist/plugins/tsup/index.d.ts +7 -6
- package/dist/plugins/tsup/index.js +14 -21
- package/dist/plugins/typedoc/index.d.ts +10 -7
- package/dist/plugins/typedoc/index.js +14 -24
- package/dist/plugins/typescript/index.d.ts +8 -7
- package/dist/plugins/typescript/index.js +31 -25
- package/dist/plugins/unbuild/index.d.ts +7 -6
- package/dist/plugins/unbuild/index.js +12 -17
- package/dist/plugins/vercel-og/index.d.ts +5 -6
- package/dist/plugins/vercel-og/index.js +8 -16
- package/dist/plugins/vite/index.d.ts +9 -7
- package/dist/plugins/vite/index.js +13 -18
- package/dist/plugins/vitest/index.d.ts +11 -9
- package/dist/plugins/vitest/index.js +62 -49
- package/dist/plugins/vue/index.d.ts +7 -6
- package/dist/plugins/vue/index.js +14 -26
- package/dist/plugins/webpack/index.d.ts +7 -6
- package/dist/plugins/webpack/index.js +17 -20
- package/dist/plugins/wireit/index.d.ts +8 -7
- package/dist/plugins/wireit/index.js +12 -20
- package/dist/plugins/yorkie/index.d.ts +8 -7
- package/dist/plugins/yorkie/index.js +13 -21
- package/dist/plugins.d.ts +3 -0
- package/dist/plugins.js +14 -0
- package/dist/reporters/index.d.ts +5 -5
- package/dist/types/config.d.ts +1 -1
- package/dist/types/package-json.d.ts +12 -13
- package/dist/types/plugins.d.ts +20 -14
- package/dist/types/util.d.ts +0 -13
- package/dist/typescript/SourceFileManager.js +3 -0
- package/dist/typescript/createHosts.js +4 -3
- package/dist/typescript/resolveModuleNames.js +26 -41
- package/dist/typescript/visitors/dynamic-imports/importCall.d.ts +1 -1
- package/dist/typescript/visitors/dynamic-imports/importType.d.ts +1 -1
- package/dist/typescript/visitors/dynamic-imports/index.d.ts +1 -1
- package/dist/typescript/visitors/dynamic-imports/jsDocType.d.ts +1 -1
- package/dist/typescript/visitors/dynamic-imports/propertyAccessCall.d.ts +1 -1
- package/dist/typescript/visitors/dynamic-imports/requireCall.d.ts +1 -1
- package/dist/typescript/visitors/exports/exportAssignment.d.ts +1 -1
- package/dist/typescript/visitors/exports/exportDeclaration.d.ts +1 -1
- package/dist/typescript/visitors/exports/exportKeyword.d.ts +1 -1
- package/dist/typescript/visitors/exports/index.d.ts +1 -1
- package/dist/typescript/visitors/exports/moduleExportsAccessExpression.d.ts +1 -1
- package/dist/typescript/visitors/imports/importDeclaration.d.ts +1 -1
- package/dist/typescript/visitors/imports/importEqualsDeclaration.d.ts +1 -1
- package/dist/typescript/visitors/imports/index.d.ts +1 -1
- package/dist/typescript/visitors/imports/reExportDeclaration.d.ts +1 -1
- package/dist/typescript/visitors/scripts/bun.d.ts +1 -1
- package/dist/typescript/visitors/scripts/execa.d.ts +1 -1
- package/dist/typescript/visitors/scripts/index.d.ts +1 -1
- package/dist/typescript/visitors/scripts/zx.d.ts +1 -1
- package/dist/util/Performance.d.ts +1 -4
- package/dist/util/Performance.js +5 -1
- package/dist/util/fs.js +0 -3
- package/dist/util/loader.d.ts +0 -2
- package/dist/util/loader.js +8 -16
- package/dist/util/object.d.ts +1 -1
- package/dist/util/path.d.ts +0 -3
- package/dist/util/path.js +0 -1
- package/dist/util/plugin.d.ts +4 -1
- package/dist/util/plugin.js +28 -1
- package/dist/util/require.d.ts +1 -0
- package/dist/util/require.js +13 -0
- package/dist/util/tsconfig-loader.js +1 -2
- package/dist/util/type.d.ts +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +5 -1
- package/dist/plugins/eslint/fallback.d.ts +0 -1
- package/dist/plugins/eslint/fallback.js +0 -18
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => ((node: ts.Node, options: import("
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => ((node: ts.Node, options: import("#p/typescript/getImportsAndExports.ts").GetImportsAndExportsOptions) => import("#p/types/exports.ts").ExportNode | import("#p/types/exports.ts").ExportNode[] | undefined)[];
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("#p/typescript/getImportsAndExports.ts").GetImportsAndExportsOptions) => import("../../../types/exports.js").ExportNode | import("../../../types/exports.js").ExportNode[] | undefined;
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("#p/typescript/getImportsAndExports.ts").GetImportsAndExportsOptions) => import("#p/types/imports.ts").ImportNode | import("#p/types/imports.ts").ImportNode[] | undefined;
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("#p/typescript/getImportsAndExports.ts").GetImportsAndExportsOptions) => import("#p/types/imports.ts").ImportNode | import("#p/types/imports.ts").ImportNode[] | undefined;
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => ((node: ts.Node, options: import("
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => ((node: ts.Node, options: import("#p/typescript/getImportsAndExports.ts").GetImportsAndExportsOptions) => import("#p/types/imports.ts").ImportNode | import("#p/types/imports.ts").ImportNode[] | undefined)[];
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("#p/typescript/getImportsAndExports.ts").GetImportsAndExportsOptions) => import("#p/types/imports.ts").ImportNode | import("#p/types/imports.ts").ImportNode[] | undefined;
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("#p/typescript/getImportsAndExports.ts").GetImportsAndExportsOptions) => string | string[] | undefined;
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("#p/typescript/getImportsAndExports.ts").GetImportsAndExportsOptions) => string | string[] | undefined;
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => ((node: ts.Node, options: import("
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => ((node: ts.Node, options: import("#p/typescript/getImportsAndExports.ts").GetImportsAndExportsOptions) => string | string[] | undefined)[];
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("
|
|
2
|
+
declare const _default: (sourceFile: ts.SourceFile) => (node: ts.Node, options: import("#p/typescript/getImportsAndExports.ts").GetImportsAndExportsOptions) => string | string[] | undefined;
|
|
3
3
|
export default _default;
|
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
/// <reference types="node" resolution-mode="require"/>
|
|
3
3
|
import { PerformanceObserver, PerformanceEntry } from 'node:perf_hooks';
|
|
4
4
|
import { memoryUsage } from 'node:process';
|
|
5
|
-
|
|
6
|
-
type Timerify = <T extends (...params: any[]) => any>(fn: T, options?: TimerifyOptions) => T;
|
|
7
|
-
export declare const timerify: Timerify;
|
|
5
|
+
export declare const timerify: <T extends (...params: any[]) => any>(fn: T, name?: string) => T;
|
|
8
6
|
export declare class Performance {
|
|
9
7
|
isEnabled: boolean;
|
|
10
8
|
startTime: number;
|
|
@@ -26,4 +24,3 @@ export declare class Performance {
|
|
|
26
24
|
finalize(): Promise<void>;
|
|
27
25
|
reset(): void;
|
|
28
26
|
}
|
|
29
|
-
export {};
|
package/dist/util/Performance.js
CHANGED
|
@@ -7,7 +7,11 @@ import Summary from 'summary';
|
|
|
7
7
|
import parsedArgValues from './cli-arguments.js';
|
|
8
8
|
import { debugLog } from './debug.js';
|
|
9
9
|
const { performance: isEnabled = false } = parsedArgValues;
|
|
10
|
-
export const timerify = fn
|
|
10
|
+
export const timerify = (fn, name = fn.name) => {
|
|
11
|
+
if (!isEnabled)
|
|
12
|
+
return fn;
|
|
13
|
+
return performance.timerify(Object.defineProperty(fn, 'name', { get: () => name }));
|
|
14
|
+
};
|
|
11
15
|
export class Performance {
|
|
12
16
|
isEnabled;
|
|
13
17
|
startTime = 0;
|
package/dist/util/fs.js
CHANGED
|
@@ -4,7 +4,6 @@ import yaml from 'js-yaml';
|
|
|
4
4
|
import { parse as parseTOML } from 'smol-toml';
|
|
5
5
|
import stripJsonComments from 'strip-json-comments';
|
|
6
6
|
import { LoaderError } from './errors.js';
|
|
7
|
-
import { FAKE_PATH } from './loader.js';
|
|
8
7
|
import { dirname, join } from './path.js';
|
|
9
8
|
import { timerify } from './Performance.js';
|
|
10
9
|
export const isDirectory = (filePath) => {
|
|
@@ -29,8 +28,6 @@ export const loadFile = async (filePath) => {
|
|
|
29
28
|
}
|
|
30
29
|
};
|
|
31
30
|
export const loadJSON = async (filePath) => {
|
|
32
|
-
if (filePath === FAKE_PATH)
|
|
33
|
-
return;
|
|
34
31
|
const contents = await loadFile(filePath);
|
|
35
32
|
return parseJSON(filePath, contents);
|
|
36
33
|
};
|
package/dist/util/loader.d.ts
CHANGED
package/dist/util/loader.js
CHANGED
|
@@ -2,13 +2,10 @@ import { pathToFileURL } from 'node:url';
|
|
|
2
2
|
import { LoaderError } from './errors.js';
|
|
3
3
|
import { loadJSON, loadYAML, loadTOML, loadFile, parseJSON, parseYAML } from './fs.js';
|
|
4
4
|
import { isTypeModule } from './fs.js';
|
|
5
|
-
import { extname } from './path.js';
|
|
5
|
+
import { extname, isInternal } from './path.js';
|
|
6
6
|
import { timerify } from './Performance.js';
|
|
7
7
|
import { jitiCJS, jitiESM } from './register.js';
|
|
8
|
-
export const FAKE_PATH = '__FAKE__.json';
|
|
9
8
|
const load = async (filePath) => {
|
|
10
|
-
if (filePath === FAKE_PATH)
|
|
11
|
-
return;
|
|
12
9
|
try {
|
|
13
10
|
const ext = extname(filePath);
|
|
14
11
|
if (filePath.endsWith('rc')) {
|
|
@@ -23,6 +20,12 @@ const load = async (filePath) => {
|
|
|
23
20
|
if (ext === '.yaml' || ext === '.yml') {
|
|
24
21
|
return await loadYAML(filePath);
|
|
25
22
|
}
|
|
23
|
+
if (ext === '' && isInternal(filePath)) {
|
|
24
|
+
return await loadFile(filePath);
|
|
25
|
+
}
|
|
26
|
+
if (ext === '' && isInternal(filePath)) {
|
|
27
|
+
return await loadFile(filePath);
|
|
28
|
+
}
|
|
26
29
|
if (ext === '.json' || ext === '.jsonc') {
|
|
27
30
|
return await loadJSON(filePath);
|
|
28
31
|
}
|
|
@@ -38,7 +41,7 @@ const load = async (filePath) => {
|
|
|
38
41
|
const imported = await import(fileUrl.href);
|
|
39
42
|
return imported.default ?? imported;
|
|
40
43
|
}
|
|
41
|
-
if (ext === '.mts' || (ext === '.ts' && isTypeModule(filePath))) {
|
|
44
|
+
if (ext === '.mts' || ((ext === '.ts' || ext === '.tsx') && isTypeModule(filePath))) {
|
|
42
45
|
return await jitiESM(filePath);
|
|
43
46
|
}
|
|
44
47
|
else {
|
|
@@ -49,15 +52,4 @@ const load = async (filePath) => {
|
|
|
49
52
|
throw new LoaderError(`Error loading ${filePath}`, { cause: error });
|
|
50
53
|
}
|
|
51
54
|
};
|
|
52
|
-
const loadFileAsync = async (filePath) => {
|
|
53
|
-
if (filePath === FAKE_PATH)
|
|
54
|
-
return;
|
|
55
|
-
try {
|
|
56
|
-
return await loadFile(filePath);
|
|
57
|
-
}
|
|
58
|
-
catch (error) {
|
|
59
|
-
throw new LoaderError(`Error loading ${filePath}`, { cause: error });
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
55
|
export const _load = timerify(load);
|
|
63
|
-
export const _loadFile = timerify(loadFileAsync);
|
package/dist/util/object.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const getValuesByKeyDeep: (obj: any, key: string) => unknown[];
|
|
2
2
|
export declare const getStringValues: (obj: any) => string[];
|
|
3
3
|
export declare const getKeysByValue: <T>(obj: T, value: unknown) => (keyof T)[];
|
|
4
|
-
export declare const get: (obj:
|
|
4
|
+
export declare const get: <T>(obj: T, path: string) => any;
|
package/dist/util/path.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
import path from 'node:path';
|
|
3
1
|
export declare const isAbsolute: (path: string) => boolean;
|
|
4
2
|
export declare const dirname: (path: string) => string;
|
|
5
3
|
export declare const extname: (path: string) => string;
|
|
6
4
|
export declare const basename: (path: string, suffix?: string | undefined) => string;
|
|
7
|
-
export declare const format: (pathObject: path.FormatInputPathObject) => string;
|
|
8
5
|
export declare const join: (...paths: string[]) => string;
|
|
9
6
|
export declare const toPosix: (value: string) => string;
|
|
10
7
|
export declare const cwd: string;
|
package/dist/util/path.js
CHANGED
|
@@ -5,7 +5,6 @@ export const isAbsolute = path.isAbsolute;
|
|
|
5
5
|
export const dirname = path.posix.dirname;
|
|
6
6
|
export const extname = path.posix.extname;
|
|
7
7
|
export const basename = path.posix.basename;
|
|
8
|
-
export const format = path.posix.format;
|
|
9
8
|
export const join = path.posix.join;
|
|
10
9
|
export const toPosix = (value) => value.split(path.sep).join(path.posix.sep);
|
|
11
10
|
export const cwd = directory ? path.posix.resolve(directory) : toPosix(process.cwd());
|
package/dist/util/plugin.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
export { _load as load
|
|
1
|
+
export { _load as load } from './loader.js';
|
|
2
2
|
export { _loadJSON as loadJSON } from './fs.js';
|
|
3
3
|
export { _tryResolve as tryResolve } from './require.js';
|
|
4
4
|
export { _getDependenciesFromScripts as getDependenciesFromScripts } from '../binaries/index.js';
|
|
5
5
|
import type { RawPluginConfiguration } from '../types/config.js';
|
|
6
|
+
import type { PluginOptions, Plugin } from '../types/plugins.js';
|
|
6
7
|
export declare const toCamelCase: (name: string) => string;
|
|
7
8
|
export declare const hasDependency: (dependencies: Set<string>, values: (string | RegExp)[]) => boolean;
|
|
8
9
|
export declare const normalizePluginConfig: (pluginConfig: RawPluginConfiguration) => boolean | {
|
|
@@ -10,3 +11,5 @@ export declare const normalizePluginConfig: (pluginConfig: RawPluginConfiguratio
|
|
|
10
11
|
entry: string[] | null;
|
|
11
12
|
project: string[] | null;
|
|
12
13
|
};
|
|
14
|
+
export declare const loadConfigForPlugin: (configFilePath: string, plugin: Plugin, options: PluginOptions, pluginName: string) => Promise<any>;
|
|
15
|
+
export declare const getFinalEntryPaths: (plugin: Plugin, options: PluginOptions, configEntryPaths: string[]) => string[];
|
package/dist/util/plugin.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
export { _load as load
|
|
1
|
+
export { _load as load } from './loader.js';
|
|
2
2
|
export { _loadJSON as loadJSON } from './fs.js';
|
|
3
3
|
export { _tryResolve as tryResolve } from './require.js';
|
|
4
4
|
export { _getDependenciesFromScripts as getDependenciesFromScripts } from '../binaries/index.js';
|
|
5
5
|
import { arrayify } from './array.js';
|
|
6
|
+
import { _load as load } from './loader.js';
|
|
7
|
+
import { get } from './object.js';
|
|
8
|
+
import { basename } from './path.js';
|
|
9
|
+
import { toEntryPattern, toProductionEntryPattern } from './protocols.js';
|
|
10
|
+
import { _loadESLintConfig as loadESLintConfig } from './require.js';
|
|
6
11
|
export const toCamelCase = (name) => name.toLowerCase().replace(/(-[a-z])/g, group => group.toUpperCase().replace('-', ''));
|
|
7
12
|
export const hasDependency = (dependencies, values) => values.some(value => {
|
|
8
13
|
if (typeof value === 'string') {
|
|
@@ -34,3 +39,25 @@ export const normalizePluginConfig = (pluginConfig) => {
|
|
|
34
39
|
return { config, entry, project };
|
|
35
40
|
}
|
|
36
41
|
};
|
|
42
|
+
export const loadConfigForPlugin = async (configFilePath, plugin, options, pluginName) => {
|
|
43
|
+
const { packageJsonPath } = plugin;
|
|
44
|
+
const { manifest } = options;
|
|
45
|
+
const localConfig = basename(configFilePath) === 'package.json'
|
|
46
|
+
? get(manifest, packageJsonPath ?? pluginName)
|
|
47
|
+
:
|
|
48
|
+
plugin.title === 'ESLint' && !/(\.(jsonc?|ya?ml)|rc)$/.test(configFilePath)
|
|
49
|
+
? await loadESLintConfig(configFilePath)
|
|
50
|
+
: await load(configFilePath);
|
|
51
|
+
return localConfig;
|
|
52
|
+
};
|
|
53
|
+
export const getFinalEntryPaths = (plugin, options, configEntryPaths) => {
|
|
54
|
+
const { config, isProduction } = options;
|
|
55
|
+
if (plugin.title === 'Storybook')
|
|
56
|
+
return [...(config.entry ?? []).map(toEntryPattern), ...configEntryPaths];
|
|
57
|
+
const toEntryPathProtocol = isProduction && plugin.production && plugin.production.length > 0 ? toProductionEntryPattern : toEntryPattern;
|
|
58
|
+
return config.entry
|
|
59
|
+
? config.entry.map(toEntryPathProtocol)
|
|
60
|
+
: configEntryPaths.length > 0
|
|
61
|
+
? configEntryPaths
|
|
62
|
+
: [...(plugin.entry ?? []).map(toEntryPattern), ...(plugin.production ?? []).map(toProductionEntryPattern)];
|
|
63
|
+
};
|
package/dist/util/require.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
export declare const _require: NodeRequire;
|
|
3
|
+
export declare const _loadESLintConfig: (configFilePath: string) => any;
|
|
3
4
|
export declare const _resolve: (specifier: string) => string;
|
|
4
5
|
export declare const _tryResolve: (specifier: string, from: string) => string | undefined;
|
|
5
6
|
export declare const _resolveSpecifier: (dir: string, specifier: string) => string | undefined;
|
package/dist/util/require.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createRequire as nodeCreateRequire } from 'node:module';
|
|
2
2
|
import { pathToFileURL } from 'node:url';
|
|
3
3
|
import createJITI from 'jiti';
|
|
4
|
+
import transform from 'jiti/dist/babel.js';
|
|
4
5
|
import { debugLog } from './debug.js';
|
|
5
6
|
import { getPackageNameFromModuleSpecifier } from './modules.js';
|
|
6
7
|
import { cwd, toPosix, join } from './path.js';
|
|
@@ -31,6 +32,18 @@ const resolveSpecifier = (dir, specifier) => {
|
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
34
|
};
|
|
35
|
+
const rushstackMatch = /require\(("|')@rushstack\/(eslint-config\/patch|eslint-patch)\/modern-module-resolution("|')\)/;
|
|
36
|
+
const jiti = createJITI(process.cwd(), {
|
|
37
|
+
cache: false,
|
|
38
|
+
transform: (opts) => {
|
|
39
|
+
opts.source = opts.source.replace(rushstackMatch, '');
|
|
40
|
+
return transform(opts);
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
const loadESLintConfig = (configFilePath) => {
|
|
44
|
+
return jiti(configFilePath);
|
|
45
|
+
};
|
|
46
|
+
export const _loadESLintConfig = timerify(loadESLintConfig);
|
|
34
47
|
export const _resolve = timerify(resolve);
|
|
35
48
|
export const _tryResolve = timerify(tryResolve);
|
|
36
49
|
export const _resolveSpecifier = timerify(resolveSpecifier);
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
2
|
import { isFile } from './fs.js';
|
|
3
|
-
import { FAKE_PATH } from './loader.js';
|
|
4
3
|
import { dirname } from './path.js';
|
|
5
4
|
const dtsMatch = /\.d\.(c|m)?ts$/;
|
|
6
5
|
export const loadTSConfig = async (tsConfigFilePath) => {
|
|
7
|
-
if (
|
|
6
|
+
if (isFile(tsConfigFilePath)) {
|
|
8
7
|
const config = ts.readConfigFile(tsConfigFilePath, ts.sys.readFile);
|
|
9
8
|
const parsedConfig = ts.parseJsonConfigFileContent(config.config, ts.sys, dirname(tsConfigFilePath));
|
|
10
9
|
const compilerOptions = parsedConfig.options ?? {};
|
package/dist/util/type.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { SerializableImports } from '../types/imports.js';
|
|
2
2
|
export declare const getHasStrictlyNsReferences: (importsForExport: SerializableImports) => [boolean, string?];
|
|
3
|
-
export declare const getType: (hasOnlyNsReference: boolean, isType: boolean) => "exports" | "
|
|
3
|
+
export declare const getType: (hasOnlyNsReference: boolean, isType: boolean) => "exports" | "types" | "nsExports" | "nsTypes";
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "5.1.
|
|
1
|
+
export declare const version = "5.1.3";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '5.1.
|
|
1
|
+
export const version = '5.1.3';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "knip",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.3",
|
|
4
4
|
"description": "Find unused files, dependencies and exports in your TypeScript and JavaScript projects",
|
|
5
5
|
"homepage": "https://knip.dev",
|
|
6
6
|
"repository": {
|
|
@@ -30,6 +30,10 @@
|
|
|
30
30
|
},
|
|
31
31
|
"type": "module",
|
|
32
32
|
"types": "./dist/index.d.ts",
|
|
33
|
+
"imports": {
|
|
34
|
+
"#p/*.ts": "./src/*.ts",
|
|
35
|
+
"#p/*.js": "./dist/*.js"
|
|
36
|
+
},
|
|
33
37
|
"scripts": {
|
|
34
38
|
"knip": "node ./dist/cli.js --directory ../..",
|
|
35
39
|
"knip:production": "node ./dist/cli.js --directory ../.. --production --strict",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const fallback: (configFilePath: string) => any;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import createJITI from 'jiti';
|
|
2
|
-
import transform from 'jiti/dist/babel.js';
|
|
3
|
-
import { FAKE_PATH } from '../../util/loader.js';
|
|
4
|
-
import { timerify } from '../../util/Performance.js';
|
|
5
|
-
const rushstackMatch = /require\(("|')@rushstack\/(eslint-config\/patch|eslint-patch)\/modern-module-resolution("|')\)/;
|
|
6
|
-
const jiti = createJITI(process.cwd(), {
|
|
7
|
-
cache: false,
|
|
8
|
-
transform: (opts) => {
|
|
9
|
-
opts.source = opts.source.replace(rushstackMatch, '');
|
|
10
|
-
return transform(opts);
|
|
11
|
-
},
|
|
12
|
-
});
|
|
13
|
-
const load = (configFilePath) => {
|
|
14
|
-
if (configFilePath === FAKE_PATH)
|
|
15
|
-
return;
|
|
16
|
-
return jiti(configFilePath);
|
|
17
|
-
};
|
|
18
|
-
export const fallback = timerify(load);
|