knip 5.80.0 → 5.80.1
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/cli.js +5 -2
- package/dist/compilers/scss.d.ts +2 -2
- package/dist/compilers/scss.js +16 -10
- package/dist/plugins/bun/index.js +1 -1
- package/dist/plugins/node/index.js +1 -1
- package/dist/plugins/nx/index.js +24 -2
- package/dist/plugins/nx/types.d.ts +5 -0
- package/dist/plugins/react-router/index.js +3 -3
- package/dist/plugins/size-limit/index.js +2 -5
- package/dist/plugins/tanstack-router/index.js +13 -2
- package/dist/plugins/tanstack-router/types.d.ts +22 -0
- package/dist/plugins/tanstack-router/types.js +1 -0
- package/dist/util/errors.d.ts +1 -0
- package/dist/util/errors.js +1 -0
- package/dist/util/map-workspaces.js +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2,7 +2,7 @@ import { fix } from './IssueFixer.js';
|
|
|
2
2
|
import { run } from './run.js';
|
|
3
3
|
import parseArgs, { helpText } from './util/cli-arguments.js';
|
|
4
4
|
import { createOptions } from './util/create-options.js';
|
|
5
|
-
import { getKnownErrors, hasErrorCause, isConfigurationError, isKnownError } from './util/errors.js';
|
|
5
|
+
import { getKnownErrors, hasErrorCause, isConfigurationError, isKnownError, isModuleNotFoundError, } from './util/errors.js';
|
|
6
6
|
import { logError, logWarning } from './util/log.js';
|
|
7
7
|
import { perfObserver } from './util/Performance.js';
|
|
8
8
|
import { runPreprocessors, runReporters } from './util/reporter.js';
|
|
@@ -88,8 +88,11 @@ const main = async () => {
|
|
|
88
88
|
const knownErrors = getKnownErrors(error);
|
|
89
89
|
for (const knownError of knownErrors)
|
|
90
90
|
logError('ERROR', knownError.message);
|
|
91
|
-
if (hasErrorCause(knownErrors[0]))
|
|
91
|
+
if (hasErrorCause(knownErrors[0])) {
|
|
92
92
|
console.error('Reason:', knownErrors[0].cause.message);
|
|
93
|
+
if (isModuleNotFoundError(knownErrors[0].cause))
|
|
94
|
+
console.log('Module load error? Visit https://knip.dev/reference/known-issues');
|
|
95
|
+
}
|
|
93
96
|
if (isConfigurationError(knownErrors[0]))
|
|
94
97
|
console.log('\nRun `knip --help` or visit https://knip.dev for help');
|
|
95
98
|
process.exit(2);
|
package/dist/compilers/scss.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { HasDependency } from './types.js';
|
|
1
|
+
import type { HasDependency, SyncCompilerFn } from './types.js';
|
|
2
2
|
declare const _default: {
|
|
3
3
|
condition: (hasDependency: HasDependency) => boolean;
|
|
4
|
-
compiler:
|
|
4
|
+
compiler: SyncCompilerFn;
|
|
5
5
|
};
|
|
6
6
|
export default _default;
|
package/dist/compilers/scss.js
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { basename, dirname, join } from '../util/path.js';
|
|
1
3
|
const condition = (hasDependency) => hasDependency('sass') || hasDependency('sass-embedded') || hasDependency('node-sass');
|
|
2
4
|
const importMatcher = /@(?:use|import|forward)\s+['"](pkg:)?([^'"]+)['"]/g;
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return
|
|
5
|
+
const resolvePartial = (specifier, containingFile) => {
|
|
6
|
+
const rel = specifier.startsWith('.') ? specifier : `./${specifier}`;
|
|
7
|
+
const name = basename(rel);
|
|
8
|
+
if (name.startsWith('_'))
|
|
9
|
+
return rel;
|
|
10
|
+
const dir = dirname(rel);
|
|
11
|
+
const partial = name.endsWith('.scss') ? `_${name}` : `_${name}.scss`;
|
|
12
|
+
if (existsSync(join(dirname(containingFile), dir, partial)))
|
|
13
|
+
return `${dir}/_${name}`;
|
|
14
|
+
return rel;
|
|
13
15
|
};
|
|
16
|
+
const compiler = (text, filePath) => [...text.matchAll(importMatcher)]
|
|
17
|
+
.filter(match => match[2] && !match[2].startsWith('sass:'))
|
|
18
|
+
.map((match, i) => `import _$${i} from '${match[1] ? match[2] : resolvePartial(match[2], filePath)}';`)
|
|
19
|
+
.join('\n');
|
|
14
20
|
export default { condition, compiler };
|
|
@@ -5,7 +5,7 @@ const enablers = ['bun'];
|
|
|
5
5
|
const hasBunTest = (scripts) => scripts && Object.values(scripts).some(script => /(?<=^|\s)bun test/.test(script));
|
|
6
6
|
const isEnabled = ({ manifest }) => !!hasBunTest(manifest.scripts);
|
|
7
7
|
const patterns = ['**/*.{test,spec}.{js,jsx,ts,tsx}', '**/*_{test,spec}.{js,jsx,ts,tsx}'];
|
|
8
|
-
const resolve =
|
|
8
|
+
const resolve = options => {
|
|
9
9
|
const scripts = { ...options.rootManifest?.scripts, ...options.manifest.scripts };
|
|
10
10
|
for (const script of Object.values(scripts)) {
|
|
11
11
|
if (/(?<=^|\s)bun test/.test(script)) {
|
|
@@ -9,7 +9,7 @@ const patterns = [
|
|
|
9
9
|
];
|
|
10
10
|
const hasNodeTest = (scripts) => scripts && Object.values(scripts).some(script => /(?<=^|\s)node\s(.*)--test/.test(script));
|
|
11
11
|
const entry = ['server.js'];
|
|
12
|
-
const resolve =
|
|
12
|
+
const resolve = options => {
|
|
13
13
|
const entries = entry.map(id => toProductionEntry(id));
|
|
14
14
|
if (hasNodeTest(options.manifest.scripts) || hasNodeTest(options.rootManifest?.scripts)) {
|
|
15
15
|
entries.push(...patterns.map(toEntry));
|
package/dist/plugins/nx/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { compact } from '../../util/array.js';
|
|
2
|
-
import { toDependency } from '../../util/input.js';
|
|
2
|
+
import { toConfig, toDependency } from '../../util/input.js';
|
|
3
3
|
import { hasDependency } from '../../util/plugin.js';
|
|
4
4
|
const title = 'Nx';
|
|
5
5
|
const enablers = ['nx', /^@nrwl\//, /^@nx\//];
|
|
@@ -46,7 +46,29 @@ const resolveConfig = async (localConfig, options) => {
|
|
|
46
46
|
return [];
|
|
47
47
|
});
|
|
48
48
|
const inputs = options.getInputsFromScripts(scripts);
|
|
49
|
-
|
|
49
|
+
const configInputs = targets.flatMap(target => {
|
|
50
|
+
const opts = target.options;
|
|
51
|
+
if (!opts)
|
|
52
|
+
return [];
|
|
53
|
+
const configs = [];
|
|
54
|
+
if ('eslintConfig' in opts && typeof opts.eslintConfig === 'string') {
|
|
55
|
+
configs.push(toConfig('eslint', opts.eslintConfig));
|
|
56
|
+
}
|
|
57
|
+
if ('jestConfig' in opts && typeof opts.jestConfig === 'string') {
|
|
58
|
+
configs.push(toConfig('jest', opts.jestConfig));
|
|
59
|
+
}
|
|
60
|
+
if ('tsConfig' in opts && typeof opts.tsConfig === 'string') {
|
|
61
|
+
configs.push(toConfig('typescript', opts.tsConfig));
|
|
62
|
+
}
|
|
63
|
+
if ('vitestConfig' in opts && typeof opts.vitestConfig === 'string') {
|
|
64
|
+
configs.push(toConfig('vitest', opts.vitestConfig));
|
|
65
|
+
}
|
|
66
|
+
if ('webpackConfig' in opts && typeof opts.webpackConfig === 'string') {
|
|
67
|
+
configs.push(toConfig('webpack', opts.webpackConfig));
|
|
68
|
+
}
|
|
69
|
+
return configs;
|
|
70
|
+
});
|
|
71
|
+
return compact([...executors, ...inputs, ...configInputs]).map(id => typeof id === 'string' ? toDependency(id) : id);
|
|
50
72
|
};
|
|
51
73
|
const args = {
|
|
52
74
|
fromArgs: (parsed) => (parsed._[0] === 'exec' ? parsed._.slice(1) : []),
|
|
@@ -2,7 +2,7 @@ import { existsSync } from 'node:fs';
|
|
|
2
2
|
import os from 'node:os';
|
|
3
3
|
import { _glob } from '../../util/glob.js';
|
|
4
4
|
import { toEntry, toProductionDependency, toProductionEntry } from '../../util/input.js';
|
|
5
|
-
import { join } from '../../util/path.js';
|
|
5
|
+
import { join, toAbsolute } from '../../util/path.js';
|
|
6
6
|
import { hasDependency, load } from '../../util/plugin.js';
|
|
7
7
|
import vite from '../vite/index.js';
|
|
8
8
|
const isWindows = os.platform() === 'win32';
|
|
@@ -14,7 +14,7 @@ const config = ['react-router.config.{js,ts}', ...viteConfig];
|
|
|
14
14
|
const resolveConfig = async (localConfig, options) => {
|
|
15
15
|
const { configFileDir } = options;
|
|
16
16
|
const appDirectory = localConfig.appDirectory ?? 'app';
|
|
17
|
-
const appDir =
|
|
17
|
+
const appDir = toAbsolute(appDirectory, configFileDir);
|
|
18
18
|
globalThis.__reactRouterAppDirectory = appDir;
|
|
19
19
|
let routeConfig = [];
|
|
20
20
|
const routesPathTs = join(appDir, 'routes.ts');
|
|
@@ -30,7 +30,7 @@ const resolveConfig = async (localConfig, options) => {
|
|
|
30
30
|
};
|
|
31
31
|
const routes = routeConfig
|
|
32
32
|
.flatMap(mapRoute)
|
|
33
|
-
.map(route => (isWindows ? route : route.replace(/[
|
|
33
|
+
.map(route => (isWindows ? route : route.replace(/[\^*?()[\]]/g, '\\$&')));
|
|
34
34
|
const resolved = [
|
|
35
35
|
toEntry(join(appDir, 'routes.{js,ts}')),
|
|
36
36
|
toProductionEntry(join(appDir, 'root.{jsx,tsx}')),
|
|
@@ -4,10 +4,7 @@ import { toLilconfig } from '../../util/plugin-config.js';
|
|
|
4
4
|
const title = 'size-limit';
|
|
5
5
|
const enablers = ['size-limit'];
|
|
6
6
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
7
|
-
const
|
|
8
|
-
'package.json',
|
|
9
|
-
...toLilconfig('size-limit', { configDir: false, additionalExtensions: ['mts', 'cts'], rcSuffix: '' }),
|
|
10
|
-
];
|
|
7
|
+
const entry = [...toLilconfig('size-limit', { configDir: false, additionalExtensions: ['mts', 'cts'], rcSuffix: '' })];
|
|
11
8
|
const resolve = options => {
|
|
12
9
|
const allDeps = [
|
|
13
10
|
...Object.keys(options.manifest.dependencies || {}),
|
|
@@ -20,7 +17,7 @@ const plugin = {
|
|
|
20
17
|
title,
|
|
21
18
|
enablers,
|
|
22
19
|
isEnabled,
|
|
23
|
-
|
|
20
|
+
entry,
|
|
24
21
|
resolve,
|
|
25
22
|
};
|
|
26
23
|
export default plugin;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { toProductionEntry } from '../../util/input.js';
|
|
2
|
+
import { toAbsolute } from '../../util/path.js';
|
|
1
3
|
import { hasDependency } from '../../util/plugin.js';
|
|
2
4
|
const title = 'TanStack Router';
|
|
3
5
|
const enablers = [
|
|
@@ -9,11 +11,20 @@ const enablers = [
|
|
|
9
11
|
'@tanstack/router-plugin',
|
|
10
12
|
];
|
|
11
13
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
12
|
-
const
|
|
14
|
+
const config = ['tsr.config.json'];
|
|
15
|
+
const production = ['src/routeTree.gen.{ts,js}'];
|
|
16
|
+
const resolveConfig = async (localConfig, options) => {
|
|
17
|
+
const { configFileDir } = options;
|
|
18
|
+
const generatedRouteTree = localConfig.generatedRouteTree ?? './src/routeTree.gen.ts';
|
|
19
|
+
const routeTreePath = toAbsolute(generatedRouteTree, configFileDir);
|
|
20
|
+
return [toProductionEntry(routeTreePath)];
|
|
21
|
+
};
|
|
13
22
|
const plugin = {
|
|
14
23
|
title,
|
|
15
24
|
enablers,
|
|
16
25
|
isEnabled,
|
|
17
|
-
|
|
26
|
+
config,
|
|
27
|
+
production,
|
|
28
|
+
resolveConfig,
|
|
18
29
|
};
|
|
19
30
|
export default plugin;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface TanStackRouterConfig {
|
|
2
|
+
routesDirectory?: string;
|
|
3
|
+
generatedRouteTree?: string;
|
|
4
|
+
quoteStyle?: 'single' | 'double';
|
|
5
|
+
semicolons?: boolean;
|
|
6
|
+
disableTypes?: boolean;
|
|
7
|
+
addExtensions?: boolean;
|
|
8
|
+
disableLogging?: boolean;
|
|
9
|
+
disableManifestGeneration?: boolean;
|
|
10
|
+
apiBase?: string;
|
|
11
|
+
routeFilePrefix?: string;
|
|
12
|
+
routeFileIgnorePrefix?: string;
|
|
13
|
+
routeFileIgnorePattern?: string;
|
|
14
|
+
routeToken?: string;
|
|
15
|
+
routeTreeFileHeader?: string[];
|
|
16
|
+
routeTreeFileFooter?: string[];
|
|
17
|
+
indexToken?: string;
|
|
18
|
+
autoCodeSplitting?: boolean;
|
|
19
|
+
experimental?: {
|
|
20
|
+
enableCodeSplitting?: boolean;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/util/errors.d.ts
CHANGED
|
@@ -9,5 +9,6 @@ export declare class LoaderError extends Error {
|
|
|
9
9
|
export declare const isKnownError: (error: Error) => error is core.$ZodError<any> | ConfigurationError | LoaderError;
|
|
10
10
|
export declare const hasErrorCause: (error: Error) => error is ErrorWithCause;
|
|
11
11
|
export declare const isConfigurationError: (error: Error) => error is ConfigurationError;
|
|
12
|
+
export declare const isModuleNotFoundError: (error: Error) => boolean;
|
|
12
13
|
export declare const getKnownErrors: (error: Error) => Error[];
|
|
13
14
|
export {};
|
package/dist/util/errors.js
CHANGED
|
@@ -7,6 +7,7 @@ export class LoaderError extends Error {
|
|
|
7
7
|
export const isKnownError = (error) => error instanceof ConfigurationError || error instanceof LoaderError || isZodErrorLike(error);
|
|
8
8
|
export const hasErrorCause = (error) => !isZodErrorLike(error) && error.cause instanceof Error;
|
|
9
9
|
export const isConfigurationError = (error) => error instanceof ConfigurationError;
|
|
10
|
+
export const isModuleNotFoundError = (error) => 'code' in error && error.code === 'MODULE_NOT_FOUND';
|
|
10
11
|
export const getKnownErrors = (error) => {
|
|
11
12
|
if (isZodErrorLike(error))
|
|
12
13
|
return [...error.issues].map(error => {
|
|
@@ -15,7 +15,7 @@ export default async function mapWorkspaces(cwd, workspaces) {
|
|
|
15
15
|
cwd,
|
|
16
16
|
ignore: ['**/node_modules/**', ...negatedPatterns.map(p => p.slice(1))],
|
|
17
17
|
});
|
|
18
|
-
for (const match of matches) {
|
|
18
|
+
for (const match of matches.sort()) {
|
|
19
19
|
const name = match === 'package.json' ? '.' : match.replace(/\/package\.json$/, '');
|
|
20
20
|
const dir = join(cwd, name);
|
|
21
21
|
const manifestPath = join(cwd, match);
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "5.80.
|
|
1
|
+
export declare const version = "5.80.1";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '5.80.
|
|
1
|
+
export const version = '5.80.1';
|