knip 5.62.0 → 5.63.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/README.md +22 -24
- package/dist/CacheConsultant.d.ts +3 -9
- package/dist/CacheConsultant.js +5 -5
- package/dist/ConfigurationChief.d.ts +588 -38
- package/dist/ConfigurationChief.js +43 -124
- package/dist/ConsoleStreamer.d.ts +2 -3
- package/dist/ConsoleStreamer.js +2 -2
- package/dist/DependencyDeputy.d.ts +2 -6
- package/dist/IssueCollector.d.ts +4 -12
- package/dist/IssueCollector.js +10 -10
- package/dist/IssueFixer.d.ts +3 -14
- package/dist/IssueFixer.js +11 -21
- package/dist/PrincipalFactory.d.ts +3 -2
- package/dist/PrincipalFactory.js +11 -11
- package/dist/ProjectPrincipal.d.ts +5 -3
- package/dist/ProjectPrincipal.js +17 -11
- package/dist/WorkspaceWorker.d.ts +4 -9
- package/dist/WorkspaceWorker.js +8 -12
- package/dist/binaries/bash-parser.js +1 -1
- package/dist/binaries/fallback.js +4 -2
- package/dist/binaries/package-manager/pnpm.js +6 -1
- package/dist/cli.js +43 -60
- package/dist/compilers/index.d.ts +34 -4
- package/dist/graph/analyze.d.ts +3 -8
- package/dist/graph/analyze.js +24 -27
- package/dist/graph/build.d.ts +3 -17
- package/dist/graph/build.js +60 -47
- package/dist/index.d.ts +3 -6
- package/dist/index.js +23 -62
- package/dist/plugins/astro/index.d.ts +1 -0
- package/dist/plugins/astro/index.js +4 -0
- package/dist/plugins/index.d.ts +24 -1
- package/dist/plugins/index.js +6 -0
- package/dist/plugins/lefthook/index.js +2 -0
- package/dist/plugins/node-modules-inspector/index.d.ts +12 -0
- package/dist/plugins/node-modules-inspector/index.js +17 -0
- package/dist/plugins/nuxt/index.js +4 -3
- package/dist/plugins/nuxt/types.d.ts +3 -2
- package/dist/plugins/playwright/index.js +8 -1
- package/dist/plugins/playwright/types.d.ts +20 -14
- package/dist/plugins/pnpm/index.d.ts +7 -0
- package/dist/plugins/pnpm/index.js +8 -0
- package/dist/plugins/preconstruct/index.js +2 -1
- package/dist/plugins/react-router/index.js +18 -8
- package/dist/plugins/rsbuild/index.js +28 -2
- package/dist/plugins/rsbuild/types.d.ts +11 -0
- package/dist/plugins/rslib/index.d.ts +10 -0
- package/dist/plugins/rslib/index.js +15 -0
- package/dist/plugins/rslib/types.d.ts +1 -0
- package/dist/plugins/rspack/index.js +1 -1
- package/dist/plugins/typescript/index.d.ts +1 -1
- package/dist/plugins.js +3 -2
- package/dist/reporters/codeclimate.d.ts +1 -1
- package/dist/reporters/codeclimate.js +10 -10
- package/dist/reporters/codeowners.d.ts +1 -1
- package/dist/reporters/codeowners.js +5 -5
- package/dist/reporters/compact.d.ts +1 -1
- package/dist/reporters/compact.js +7 -7
- package/dist/reporters/disclosure.d.ts +1 -1
- package/dist/reporters/disclosure.js +2 -2
- package/dist/reporters/index.d.ts +6 -6
- package/dist/reporters/json.d.ts +1 -1
- package/dist/reporters/json.js +3 -3
- package/dist/reporters/markdown.d.ts +1 -1
- package/dist/reporters/markdown.js +4 -4
- package/dist/reporters/symbols.js +4 -2
- package/dist/reporters/util/configuration-hints.d.ts +1 -1
- package/dist/reporters/util/configuration-hints.js +58 -23
- package/dist/reporters/util/util.d.ts +2 -4
- package/dist/reporters/util/util.js +6 -6
- package/dist/reporters/watch.d.ts +3 -4
- package/dist/reporters/watch.js +5 -5
- package/dist/schema/configuration.d.ts +176 -8
- package/dist/schema/plugins.d.ts +69 -0
- package/dist/schema/plugins.js +3 -0
- package/dist/types/PluginNames.d.ts +2 -2
- package/dist/types/PluginNames.js +3 -0
- package/dist/types/config.d.ts +4 -10
- package/dist/types/entries.d.ts +3 -0
- package/dist/types/entries.js +1 -0
- package/dist/types/issues.d.ts +4 -3
- package/dist/types/{cli.d.ts → options.d.ts} +2 -2
- package/dist/types/options.js +1 -0
- package/dist/types/package-json.d.ts +5 -0
- package/dist/types/project.d.ts +1 -7
- package/dist/types/tsconfig-json.d.ts +14 -0
- package/dist/types/tsconfig-json.js +1 -0
- package/dist/typescript/ast-helpers.js +1 -1
- package/dist/typescript/get-imports-and-exports.d.ts +2 -2
- package/dist/typescript/get-imports-and-exports.js +9 -10
- package/dist/util/Performance.js +16 -6
- package/dist/util/cli-arguments.d.ts +1 -2
- package/dist/util/cli-arguments.js +3 -13
- package/dist/util/create-options.d.ts +1219 -0
- package/dist/util/create-options.js +112 -0
- package/dist/util/debug.js +3 -4
- package/dist/util/errors.d.ts +1 -1
- package/dist/util/file-entry-cache.js +3 -3
- package/dist/util/fs.d.ts +1 -1
- package/dist/util/get-included-issue-types.d.ts +9 -13
- package/dist/util/get-included-issue-types.js +10 -16
- package/dist/util/get-referenced-inputs.js +1 -1
- package/dist/util/glob-core.d.ts +1 -1
- package/dist/util/glob-core.js +8 -7
- package/dist/util/glob.d.ts +1 -0
- package/dist/util/glob.js +1 -1
- package/dist/util/input.d.ts +1 -1
- package/dist/util/input.js +1 -1
- package/dist/util/is-identifier-referenced.d.ts +1 -1
- package/dist/util/is-identifier-referenced.js +19 -19
- package/dist/util/load-config.d.ts +1 -0
- package/dist/util/load-config.js +24 -0
- package/dist/util/package-json.d.ts +2 -1
- package/dist/util/package-json.js +24 -12
- package/dist/util/parse-and-convert-gitignores.js +2 -0
- package/dist/util/path.d.ts +4 -4
- package/dist/util/path.js +5 -7
- package/dist/util/reporter.js +3 -3
- package/dist/util/require.js +1 -2
- package/dist/util/table.js +1 -3
- package/dist/util/tag.d.ts +1 -1
- package/dist/util/to-source-path.d.ts +1 -1
- package/dist/util/to-source-path.js +5 -5
- package/dist/util/trace.d.ts +6 -6
- package/dist/util/trace.js +18 -22
- package/dist/util/watch.d.ts +2 -5
- package/dist/util/watch.js +3 -3
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +10 -15
- package/schema.json +12 -0
- package/dist/util/unwrap-function.d.ts +0 -1
- package/dist/util/unwrap-function.js +0 -13
- /package/dist/{types/cli.js → plugins/rslib/types.js} +0 -0
package/dist/plugins/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export declare const Plugins: {
|
|
|
15
15
|
production: string[];
|
|
16
16
|
resolveFromAST: import("../types/config.js").ResolveFromAST;
|
|
17
17
|
resolve: import("../types/config.js").Resolve;
|
|
18
|
+
project: string[];
|
|
18
19
|
};
|
|
19
20
|
ava: {
|
|
20
21
|
title: string;
|
|
@@ -405,6 +406,16 @@ export declare const Plugins: {
|
|
|
405
406
|
args: (args: string[]) => string[];
|
|
406
407
|
};
|
|
407
408
|
};
|
|
409
|
+
'node-modules-inspector': {
|
|
410
|
+
title: string;
|
|
411
|
+
enablers: string[];
|
|
412
|
+
isEnabled: import("../types/config.js").IsPluginEnabled;
|
|
413
|
+
config: string[];
|
|
414
|
+
args: {
|
|
415
|
+
binaries: string[];
|
|
416
|
+
config: boolean;
|
|
417
|
+
};
|
|
418
|
+
};
|
|
408
419
|
nodemon: {
|
|
409
420
|
title: string;
|
|
410
421
|
args: {
|
|
@@ -504,6 +515,11 @@ export declare const Plugins: {
|
|
|
504
515
|
isEnabled: import("../types/config.js").IsPluginEnabled;
|
|
505
516
|
config: string[];
|
|
506
517
|
};
|
|
518
|
+
pnpm: {
|
|
519
|
+
title: string;
|
|
520
|
+
isEnabled: import("../types/config.js").IsPluginEnabled;
|
|
521
|
+
config: string[];
|
|
522
|
+
};
|
|
507
523
|
postcss: {
|
|
508
524
|
title: string;
|
|
509
525
|
enablers: string[];
|
|
@@ -599,6 +615,13 @@ export declare const Plugins: {
|
|
|
599
615
|
config: string[];
|
|
600
616
|
resolveConfig: import("../types/config.js").ResolveConfig<import("./rsbuild/types.js").RsbuildConfig>;
|
|
601
617
|
};
|
|
618
|
+
rslib: {
|
|
619
|
+
title: string;
|
|
620
|
+
enablers: string[];
|
|
621
|
+
isEnabled: import("../types/config.js").IsPluginEnabled;
|
|
622
|
+
entry: string[];
|
|
623
|
+
resolveConfig: import("../types/config.js").ResolveConfig<import("./rslib/types.js").RslibConfig>;
|
|
624
|
+
};
|
|
602
625
|
rspack: {
|
|
603
626
|
title: string;
|
|
604
627
|
enablers: string[];
|
|
@@ -770,7 +793,7 @@ export declare const Plugins: {
|
|
|
770
793
|
enablers: string[];
|
|
771
794
|
isEnabled: import("../types/config.js").IsPluginEnabled;
|
|
772
795
|
config: string[];
|
|
773
|
-
resolveConfig: import("../types/config.js").ResolveConfig<import("
|
|
796
|
+
resolveConfig: import("../types/config.js").ResolveConfig<import("../types/tsconfig-json.js").TsConfigJson>;
|
|
774
797
|
args: {
|
|
775
798
|
binaries: string[];
|
|
776
799
|
string: string[];
|
package/dist/plugins/index.js
CHANGED
|
@@ -48,6 +48,7 @@ import { default as nanoStaged } from './nano-staged/index.js';
|
|
|
48
48
|
import { default as nest } from './nest/index.js';
|
|
49
49
|
import { default as netlify } from './netlify/index.js';
|
|
50
50
|
import { default as next } from './next/index.js';
|
|
51
|
+
import { default as nodeModulesInspector } from './node-modules-inspector/index.js';
|
|
51
52
|
import { default as node } from './node/index.js';
|
|
52
53
|
import { default as nodemon } from './nodemon/index.js';
|
|
53
54
|
import { default as npmPackageJsonLint } from './npm-package-json-lint/index.js';
|
|
@@ -60,6 +61,7 @@ import { default as playwrightCt } from './playwright-ct/index.js';
|
|
|
60
61
|
import { default as playwrightTest } from './playwright-test/index.js';
|
|
61
62
|
import { default as playwright } from './playwright/index.js';
|
|
62
63
|
import { default as plop } from './plop/index.js';
|
|
64
|
+
import { default as pnpm } from './pnpm/index.js';
|
|
63
65
|
import { default as postcss } from './postcss/index.js';
|
|
64
66
|
import { default as preconstruct } from './preconstruct/index.js';
|
|
65
67
|
import { default as prettier } from './prettier/index.js';
|
|
@@ -72,6 +74,7 @@ import { default as remark } from './remark/index.js';
|
|
|
72
74
|
import { default as remix } from './remix/index.js';
|
|
73
75
|
import { default as rollup } from './rollup/index.js';
|
|
74
76
|
import { default as rsbuild } from './rsbuild/index.js';
|
|
77
|
+
import { default as rslib } from './rslib/index.js';
|
|
75
78
|
import { default as rspack } from './rspack/index.js';
|
|
76
79
|
import { default as semanticRelease } from './semantic-release/index.js';
|
|
77
80
|
import { default as sentry } from './sentry/index.js';
|
|
@@ -159,6 +162,7 @@ export const Plugins = {
|
|
|
159
162
|
netlify,
|
|
160
163
|
next,
|
|
161
164
|
node,
|
|
165
|
+
'node-modules-inspector': nodeModulesInspector,
|
|
162
166
|
nodemon,
|
|
163
167
|
'npm-package-json-lint': npmPackageJsonLint,
|
|
164
168
|
nuxt,
|
|
@@ -170,6 +174,7 @@ export const Plugins = {
|
|
|
170
174
|
'playwright-ct': playwrightCt,
|
|
171
175
|
'playwright-test': playwrightTest,
|
|
172
176
|
plop,
|
|
177
|
+
pnpm,
|
|
173
178
|
postcss,
|
|
174
179
|
preconstruct,
|
|
175
180
|
prettier,
|
|
@@ -182,6 +187,7 @@ export const Plugins = {
|
|
|
182
187
|
remix,
|
|
183
188
|
rollup,
|
|
184
189
|
rsbuild,
|
|
190
|
+
rslib,
|
|
185
191
|
rspack,
|
|
186
192
|
'semantic-release': semanticRelease,
|
|
187
193
|
sentry,
|
|
@@ -9,6 +9,8 @@ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
|
9
9
|
const gitHookPaths = getGitHookPaths();
|
|
10
10
|
const config = ['lefthook.yml', ...gitHookPaths];
|
|
11
11
|
const resolveConfig = async (localConfig, options) => {
|
|
12
|
+
if (options.isProduction)
|
|
13
|
+
return [];
|
|
12
14
|
const { manifest, configFileName, cwd, getInputsFromScripts } = options;
|
|
13
15
|
const inputs = manifest.devDependencies ? Object.keys(manifest.devDependencies).map(id => toDependency(id)) : [];
|
|
14
16
|
if (extname(configFileName) === '.yml') {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { IsPluginEnabled } from '../../types/config.js';
|
|
2
|
+
declare const _default: {
|
|
3
|
+
title: string;
|
|
4
|
+
enablers: string[];
|
|
5
|
+
isEnabled: IsPluginEnabled;
|
|
6
|
+
config: string[];
|
|
7
|
+
args: {
|
|
8
|
+
binaries: string[];
|
|
9
|
+
config: boolean;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { toUnconfig } from '../../util/plugin-config.js';
|
|
2
|
+
import { hasDependency } from '../../util/plugin.js';
|
|
3
|
+
const title = 'node-modules-inspector';
|
|
4
|
+
const enablers = ['node-modules-inspector'];
|
|
5
|
+
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
6
|
+
const config = [...toUnconfig('node-modules-inspector.config')];
|
|
7
|
+
const args = {
|
|
8
|
+
binaries: ['node-modules-inspector'],
|
|
9
|
+
config: true,
|
|
10
|
+
};
|
|
11
|
+
export default {
|
|
12
|
+
title,
|
|
13
|
+
enablers,
|
|
14
|
+
isEnabled,
|
|
15
|
+
config,
|
|
16
|
+
args,
|
|
17
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { toProductionEntry } from '../../util/input.js';
|
|
1
|
+
import { toDependency, toProductionEntry } from '../../util/input.js';
|
|
2
2
|
import { join } from '../../util/path.js';
|
|
3
3
|
import { hasDependency } from '../../util/plugin.js';
|
|
4
4
|
const title = 'Nuxt';
|
|
@@ -33,8 +33,9 @@ const resolveConfig = async (localConfig) => {
|
|
|
33
33
|
'server/routes/**/*.ts',
|
|
34
34
|
'server/middleware/**/*.ts',
|
|
35
35
|
'server/plugins/**/*.ts',
|
|
36
|
-
];
|
|
37
|
-
|
|
36
|
+
].map(pattern => toProductionEntry(join(srcDir, pattern)));
|
|
37
|
+
const deps = localConfig.modules?.map(id => toDependency(id)) ?? [];
|
|
38
|
+
return [...deps, ...patterns];
|
|
38
39
|
};
|
|
39
40
|
const note = `Knip works best with [explicit imports](https://nuxt.com/docs/guide/concepts/auto-imports#explicit-imports).
|
|
40
41
|
Nuxt allows to [disable auto-imports](https://nuxt.com/docs/guide/concepts/auto-imports#disabling-auto-imports).`;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { arrayify } from '../../util/array.js';
|
|
1
2
|
import { toDeferResolve, toEntry } from '../../util/input.js';
|
|
2
3
|
import { join, relative } from '../../util/path.js';
|
|
3
4
|
import { hasDependency } from '../../util/plugin.js';
|
|
@@ -15,6 +16,11 @@ const toEntryPatterns = (testMatch, cwd, configDir, localConfig, rootConfig) =>
|
|
|
15
16
|
const builtinReporters = ['dot', 'line', 'list', 'junit', 'html', 'blob', 'json', 'github'];
|
|
16
17
|
export const resolveConfig = async (localConfig, options) => {
|
|
17
18
|
const { cwd, configFileDir } = options;
|
|
19
|
+
const inputs = [];
|
|
20
|
+
for (const id of arrayify(localConfig.globalSetup))
|
|
21
|
+
inputs.push(toEntry(id));
|
|
22
|
+
for (const id of arrayify(localConfig.globalTeardown))
|
|
23
|
+
inputs.push(toEntry(id));
|
|
18
24
|
const projects = localConfig.projects ? [localConfig, ...localConfig.projects] : [localConfig];
|
|
19
25
|
const reporters = [localConfig.reporter].flat().flatMap(reporter => {
|
|
20
26
|
const name = typeof reporter === 'string' ? reporter : reporter?.[0];
|
|
@@ -24,7 +30,8 @@ export const resolveConfig = async (localConfig, options) => {
|
|
|
24
30
|
});
|
|
25
31
|
return projects
|
|
26
32
|
.flatMap(config => toEntryPatterns(config.testMatch ?? entry, cwd, configFileDir, config, localConfig))
|
|
27
|
-
.concat(reporters.map(id => toDeferResolve(id)))
|
|
33
|
+
.concat(reporters.map(id => toDeferResolve(id)))
|
|
34
|
+
.concat(inputs);
|
|
28
35
|
};
|
|
29
36
|
const args = {
|
|
30
37
|
binaries: ['playwright'],
|
|
@@ -1,27 +1,31 @@
|
|
|
1
1
|
type LiteralUnion<T extends U, U = string> = T | (U & {
|
|
2
2
|
zz_IGNORE_ME?: never;
|
|
3
3
|
});
|
|
4
|
-
type
|
|
4
|
+
type BlobReporterOptions = {
|
|
5
5
|
outputDir?: string;
|
|
6
6
|
fileName?: string;
|
|
7
|
-
}
|
|
7
|
+
};
|
|
8
|
+
type ListReporterOptions = {
|
|
8
9
|
printSteps?: boolean;
|
|
9
|
-
}
|
|
10
|
+
};
|
|
11
|
+
type JUnitReporterOptions = {
|
|
10
12
|
outputFile?: string;
|
|
11
13
|
stripANSIControlSequences?: boolean;
|
|
12
14
|
includeProjectInTestName?: boolean;
|
|
13
|
-
}
|
|
15
|
+
};
|
|
16
|
+
type JsonReporterOptions = {
|
|
14
17
|
outputFile?: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
};
|
|
19
|
+
type HtmlReporterOptions = {
|
|
20
|
+
outputFolder?: string;
|
|
21
|
+
open?: 'always' | 'never' | 'on-failure';
|
|
22
|
+
host?: string;
|
|
23
|
+
port?: number;
|
|
24
|
+
attachmentsBaseURL?: string;
|
|
25
|
+
title?: string;
|
|
26
|
+
noSnippets?: boolean;
|
|
27
|
+
};
|
|
28
|
+
type ReporterDescription = Readonly<['blob'] | ['blob', BlobReporterOptions] | ['dot'] | ['line'] | ['list'] | ['list', ListReporterOptions] | ['github'] | ['junit'] | ['junit', JUnitReporterOptions] | ['json'] | ['json', JsonReporterOptions] | ['html'] | ['html', HtmlReporterOptions] | ['null'] | [string] | [string, any]>;
|
|
25
29
|
type Project = {
|
|
26
30
|
name: string;
|
|
27
31
|
use: string;
|
|
@@ -32,5 +36,7 @@ export type PlaywrightTestConfig = {
|
|
|
32
36
|
testMatch?: string | RegExp | (string | RegExp)[];
|
|
33
37
|
testDir?: string;
|
|
34
38
|
reporter?: LiteralUnion<'dot' | 'line' | 'list' | 'junit' | 'html' | 'json' | 'github' | 'null', string> | ReporterDescription[];
|
|
39
|
+
globalSetup?: string | Array<string>;
|
|
40
|
+
globalTeardown?: string | Array<string>;
|
|
35
41
|
};
|
|
36
42
|
export {};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { toProductionEntry } from '../../util/input.js';
|
|
2
|
+
import { join } from '../../util/path.js';
|
|
2
3
|
import { hasDependency } from '../../util/plugin.js';
|
|
3
4
|
const title = 'Preconstruct';
|
|
4
5
|
const enablers = ['@preconstruct/cli'];
|
|
5
6
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
6
7
|
const config = ['package.json'];
|
|
7
8
|
const resolveConfig = async (config) => {
|
|
8
|
-
return (config.entrypoints ?? []).map(id => toProductionEntry(id, { allowIncludeExports: true }));
|
|
9
|
+
return (config.entrypoints ?? []).map(id => toProductionEntry(join('src', id), { allowIncludeExports: true }));
|
|
9
10
|
};
|
|
10
11
|
export default {
|
|
11
12
|
title,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { existsSync } from 'node:fs';
|
|
2
2
|
import os from 'node:os';
|
|
3
|
-
import {
|
|
3
|
+
import { _glob } from '../../util/glob.js';
|
|
4
|
+
import { toEntry, toProductionDependency, toProductionEntry } from '../../util/input.js';
|
|
4
5
|
import { join } from '../../util/path.js';
|
|
5
6
|
import { hasDependency, load } from '../../util/plugin.js';
|
|
6
7
|
import vite from '../vite/index.js';
|
|
@@ -28,13 +29,22 @@ const resolveConfig = async (localConfig, options) => {
|
|
|
28
29
|
};
|
|
29
30
|
const routes = routeConfig
|
|
30
31
|
.flatMap(mapRoute)
|
|
31
|
-
.map(route => (isWindows ? route : route.replace(/[
|
|
32
|
-
|
|
33
|
-
join(appDir, 'routes.{js,ts}'),
|
|
34
|
-
join(appDir, 'root.{jsx,tsx}'),
|
|
35
|
-
join(appDir, 'entry.{client,server}.{js,jsx,ts,tsx}'),
|
|
36
|
-
...routes,
|
|
37
|
-
]
|
|
32
|
+
.map(route => (isWindows ? route : route.replace(/[\^*+?()\[\]]/g, '\\$&')));
|
|
33
|
+
const resolved = [
|
|
34
|
+
toEntry(join(appDir, 'routes.{js,ts}')),
|
|
35
|
+
toProductionEntry(join(appDir, 'root.{jsx,tsx}')),
|
|
36
|
+
toProductionEntry(join(appDir, 'entry.{client,server}.{js,jsx,ts,tsx}')),
|
|
37
|
+
...routes.map(id => toProductionEntry(id)),
|
|
38
|
+
];
|
|
39
|
+
const serverEntries = await _glob({
|
|
40
|
+
cwd: appDir,
|
|
41
|
+
patterns: ['entry.server.{js,ts,jsx,tsx}'],
|
|
42
|
+
});
|
|
43
|
+
if (serverEntries.length === 0) {
|
|
44
|
+
resolved.push(toProductionDependency('@react-router/node'));
|
|
45
|
+
resolved.push(toProductionDependency('isbot'));
|
|
46
|
+
}
|
|
47
|
+
return resolved;
|
|
38
48
|
};
|
|
39
49
|
export default {
|
|
40
50
|
title,
|
|
@@ -1,10 +1,36 @@
|
|
|
1
|
+
import { toEntry } from '../../util/input.js';
|
|
1
2
|
import { hasDependency } from '../../util/plugin.js';
|
|
2
3
|
const title = 'Rsbuild';
|
|
3
4
|
const enablers = ['@rsbuild/core'];
|
|
4
5
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
5
6
|
const config = ['rsbuild*.config.{mjs,ts,js,cjs,mts,cts}'];
|
|
6
|
-
const resolveConfig = async () => {
|
|
7
|
-
|
|
7
|
+
const resolveConfig = async (config) => {
|
|
8
|
+
const inputs = new Set();
|
|
9
|
+
const checkSource = (source) => {
|
|
10
|
+
if (source?.entry) {
|
|
11
|
+
for (const entry of Object.values(source.entry)) {
|
|
12
|
+
if (typeof entry === 'string')
|
|
13
|
+
inputs.add(toEntry(entry));
|
|
14
|
+
else if (Array.isArray(entry))
|
|
15
|
+
for (const e of entry)
|
|
16
|
+
inputs.add(toEntry(e));
|
|
17
|
+
else {
|
|
18
|
+
if (typeof entry.import === 'string')
|
|
19
|
+
inputs.add(toEntry(entry.import));
|
|
20
|
+
else if (Array.isArray(entry.import))
|
|
21
|
+
for (const e of entry.import)
|
|
22
|
+
inputs.add(toEntry(e));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
checkSource(config.source);
|
|
28
|
+
if (config.environments) {
|
|
29
|
+
for (const environment of Object.values(config.environments)) {
|
|
30
|
+
checkSource(environment.source);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return Array.from(inputs);
|
|
8
34
|
};
|
|
9
35
|
export default {
|
|
10
36
|
title,
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
type EntryDescription = Record<string, unknown>;
|
|
2
|
+
type Entry = Record<string, string | string[] | (EntryDescription & {
|
|
3
|
+
html?: boolean;
|
|
4
|
+
})>;
|
|
1
5
|
export type RsbuildConfig = {
|
|
2
6
|
plugins?: unknown[];
|
|
7
|
+
source?: {
|
|
8
|
+
entry?: Entry;
|
|
9
|
+
};
|
|
10
|
+
environments?: {
|
|
11
|
+
[k: string]: Pick<RsbuildConfig, 'plugins' | 'source'>;
|
|
12
|
+
};
|
|
3
13
|
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IsPluginEnabled, ResolveConfig } from '../../types/config.js';
|
|
2
|
+
import type { RslibConfig } from './types.js';
|
|
3
|
+
declare const _default: {
|
|
4
|
+
title: string;
|
|
5
|
+
enablers: string[];
|
|
6
|
+
isEnabled: IsPluginEnabled;
|
|
7
|
+
entry: string[];
|
|
8
|
+
resolveConfig: ResolveConfig<RslibConfig>;
|
|
9
|
+
};
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { hasDependency } from '../../util/plugin.js';
|
|
2
|
+
const title = 'Rslib';
|
|
3
|
+
const enablers = ['rslib'];
|
|
4
|
+
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
5
|
+
const entry = ['rslib*.config.{mjs,ts,js,cjs,mts,cts}'];
|
|
6
|
+
const resolveConfig = () => {
|
|
7
|
+
return [];
|
|
8
|
+
};
|
|
9
|
+
export default {
|
|
10
|
+
title,
|
|
11
|
+
enablers,
|
|
12
|
+
isEnabled,
|
|
13
|
+
entry,
|
|
14
|
+
resolveConfig,
|
|
15
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type RslibConfig = {};
|
|
@@ -3,7 +3,7 @@ import { findWebpackDependenciesFromConfig } from '../webpack/index.js';
|
|
|
3
3
|
const title = 'Rspack';
|
|
4
4
|
const enablers = ['@rspack/core'];
|
|
5
5
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
6
|
-
const config = ['rspack.config*.{js,ts,mjs,cjs}'];
|
|
6
|
+
const config = ['rspack.config*.{js,ts,mjs,mts,cjs,cts}'];
|
|
7
7
|
const resolveConfig = async (localConfig, options) => {
|
|
8
8
|
const inputs = await findWebpackDependenciesFromConfig(localConfig, options);
|
|
9
9
|
return inputs.filter(input => !input.specifier.startsWith('builtin:'));
|
package/dist/plugins.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { parseArgs } from 'node:util';
|
|
1
2
|
import { Plugins } from './plugins/index.js';
|
|
2
3
|
import { timerify } from './util/Performance.js';
|
|
3
|
-
import parsedArgValues from './util/cli-arguments.js';
|
|
4
4
|
const PMap = Plugins;
|
|
5
|
-
const {
|
|
5
|
+
const { values } = parseArgs({ strict: false, options: { performance: { type: 'boolean' } } });
|
|
6
|
+
const isEnabled = !!values.performance;
|
|
6
7
|
const timerifyMethods = ['resolve', 'resolveConfig', 'resolveAST'];
|
|
7
8
|
const PluginEntries = Object.entries(PMap);
|
|
8
9
|
if (isEnabled) {
|
|
@@ -2,7 +2,7 @@ import { createHash } from 'node:crypto';
|
|
|
2
2
|
import { ISSUE_TYPE_TITLE } from '../constants.js';
|
|
3
3
|
import { toRelative } from '../util/path.js';
|
|
4
4
|
import { getIssueTypeTitle } from './util/util.js';
|
|
5
|
-
export default async ({ report, issues }) => {
|
|
5
|
+
export default async ({ report, issues, cwd }) => {
|
|
6
6
|
const entries = [];
|
|
7
7
|
for (const [type, isReportType] of Object.entries(report)) {
|
|
8
8
|
if (!isReportType) {
|
|
@@ -17,9 +17,9 @@ export default async ({ report, issues }) => {
|
|
|
17
17
|
check_name: getIssueTypeTitle(fixedType),
|
|
18
18
|
description: getSymbolDescription({ type: issue.type, symbol, parentSymbol: issue.parentSymbol }),
|
|
19
19
|
categories: ['Duplication'],
|
|
20
|
-
location: createLocation(filePath, symbol.line, symbol.col),
|
|
20
|
+
location: createLocation(filePath, cwd, symbol.line, symbol.col),
|
|
21
21
|
severity: convertSeverity(issue.severity),
|
|
22
|
-
fingerprint: createFingerprint(filePath, symbol.symbol),
|
|
22
|
+
fingerprint: createFingerprint(filePath, cwd, symbol.symbol),
|
|
23
23
|
})));
|
|
24
24
|
}
|
|
25
25
|
else {
|
|
@@ -28,9 +28,9 @@ export default async ({ report, issues }) => {
|
|
|
28
28
|
check_name: getIssueTypeTitle(fixedType),
|
|
29
29
|
description: getIssueDescription(issue),
|
|
30
30
|
categories: ['Bug Risk'],
|
|
31
|
-
location: createLocation(filePath, issue.line, issue.col),
|
|
31
|
+
location: createLocation(filePath, cwd, issue.line, issue.col),
|
|
32
32
|
severity: convertSeverity(issue.severity),
|
|
33
|
-
fingerprint: createFingerprint(filePath, issue.symbol),
|
|
33
|
+
fingerprint: createFingerprint(filePath, cwd, issue.symbol),
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
}
|
|
@@ -62,10 +62,10 @@ function getIssueDescription({ type, symbol, symbols, parentSymbol }) {
|
|
|
62
62
|
function getSymbolDescription({ type, symbol, parentSymbol, }) {
|
|
63
63
|
return `${getPrefix(type)}: ${symbol.symbol}${parentSymbol ? ` (${parentSymbol})` : ''}`;
|
|
64
64
|
}
|
|
65
|
-
function createLocation(filePath, line, col) {
|
|
65
|
+
function createLocation(filePath, cwd, line, col) {
|
|
66
66
|
if (col !== undefined) {
|
|
67
67
|
return {
|
|
68
|
-
path: toRelative(filePath),
|
|
68
|
+
path: toRelative(filePath, cwd),
|
|
69
69
|
positions: {
|
|
70
70
|
begin: {
|
|
71
71
|
line: line ?? 0,
|
|
@@ -79,16 +79,16 @@ function createLocation(filePath, line, col) {
|
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
81
|
return {
|
|
82
|
-
path: toRelative(filePath),
|
|
82
|
+
path: toRelative(filePath, cwd),
|
|
83
83
|
lines: {
|
|
84
84
|
begin: line ?? 0,
|
|
85
85
|
end: line ?? 0,
|
|
86
86
|
},
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
|
-
function createFingerprint(filePath, message) {
|
|
89
|
+
function createFingerprint(filePath, cwd, message) {
|
|
90
90
|
const md5 = createHash('md5');
|
|
91
|
-
md5.update(toRelative(filePath));
|
|
91
|
+
md5.update(toRelative(filePath, cwd));
|
|
92
92
|
md5.update(message);
|
|
93
93
|
return md5.digest('hex');
|
|
94
94
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ReporterOptions } from '../types/issues.js';
|
|
2
|
-
declare const _default: ({ report, issues, isShowProgress, options }: ReporterOptions) => void;
|
|
2
|
+
declare const _default: ({ report, issues, isShowProgress, options, cwd }: ReporterOptions) => void;
|
|
3
3
|
export default _default;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { createOwnershipEngine } from '../util/codeowners.js';
|
|
2
2
|
import { relative, resolve } from '../util/path.js';
|
|
3
3
|
import { getColoredTitle, getIssueLine, getIssueTypeTitle } from './util/util.js';
|
|
4
|
-
const logIssueRecord = (issues) => {
|
|
4
|
+
const logIssueRecord = (issues, cwd) => {
|
|
5
5
|
const sortedByFilePath = issues.sort((a, b) => (a.owner < b.owner ? -1 : 1));
|
|
6
6
|
for (const { filePath, symbols, owner, parentSymbol } of sortedByFilePath) {
|
|
7
|
-
console.log(getIssueLine({ owner, filePath, symbols, parentSymbol }));
|
|
7
|
+
console.log(getIssueLine({ owner, filePath, symbols, parentSymbol }, cwd));
|
|
8
8
|
}
|
|
9
9
|
};
|
|
10
|
-
export default ({ report, issues, isShowProgress, options }) => {
|
|
10
|
+
export default ({ report, issues, isShowProgress, options, cwd }) => {
|
|
11
11
|
let opts = {};
|
|
12
12
|
try {
|
|
13
13
|
opts = options ? JSON.parse(options) : opts;
|
|
@@ -20,7 +20,7 @@ export default ({ report, issues, isShowProgress, options }) => {
|
|
|
20
20
|
const reportMultipleGroups = Object.values(report).filter(Boolean).length > 1;
|
|
21
21
|
const [dependenciesOwner = '[no-owner]'] = findOwners('package.json');
|
|
22
22
|
let totalIssues = 0;
|
|
23
|
-
const calcFileOwnership = (filePath) => findOwners(relative(filePath))[0] ?? dependenciesOwner;
|
|
23
|
+
const calcFileOwnership = (filePath) => findOwners(relative(cwd, filePath))[0] ?? dependenciesOwner;
|
|
24
24
|
const addOwner = (issue) => ({
|
|
25
25
|
...issue,
|
|
26
26
|
owner: calcFileOwnership(issue.filePath),
|
|
@@ -40,7 +40,7 @@ export default ({ report, issues, isShowProgress, options }) => {
|
|
|
40
40
|
if (totalIssues)
|
|
41
41
|
console.log();
|
|
42
42
|
title && console.log(getColoredTitle(title, issuesForType.length));
|
|
43
|
-
logIssueRecord(issuesForType);
|
|
43
|
+
logIssueRecord(issuesForType, cwd);
|
|
44
44
|
}
|
|
45
45
|
totalIssues = totalIssues + issuesForType.length;
|
|
46
46
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { toRelative } from '../util/path.js';
|
|
2
2
|
import { getColoredTitle, getIssueLine, getIssueTypeTitle } from './util/util.js';
|
|
3
|
-
const logIssueSet = (issues) => {
|
|
3
|
+
const logIssueSet = (issues, cwd) => {
|
|
4
4
|
for (const filePath of issues.sort())
|
|
5
|
-
console.log(toRelative(filePath));
|
|
5
|
+
console.log(toRelative(filePath, cwd));
|
|
6
6
|
};
|
|
7
|
-
const logIssueRecord = (issues) => {
|
|
7
|
+
const logIssueRecord = (issues, cwd) => {
|
|
8
8
|
const sortedByFilePath = issues.sort((a, b) => (a.filePath > b.filePath ? 1 : -1));
|
|
9
9
|
for (const issue of sortedByFilePath)
|
|
10
|
-
console.log(getIssueLine(issue));
|
|
10
|
+
console.log(getIssueLine(issue, cwd));
|
|
11
11
|
};
|
|
12
|
-
export default ({ report, issues, isShowProgress }) => {
|
|
12
|
+
export default ({ report, issues, isShowProgress, cwd }) => {
|
|
13
13
|
const reportMultipleGroups = Object.values(report).filter(Boolean).length > 1;
|
|
14
14
|
let totalIssues = 0;
|
|
15
15
|
for (const [reportType, isReportType] of Object.entries(report)) {
|
|
@@ -27,10 +27,10 @@ export default ({ report, issues, isShowProgress }) => {
|
|
|
27
27
|
if (issuesForType.length > 0) {
|
|
28
28
|
title && console.log(getColoredTitle(title, issuesForType.length));
|
|
29
29
|
if (isSet) {
|
|
30
|
-
logIssueSet(Array.from(issues[reportType]));
|
|
30
|
+
logIssueSet(Array.from(issues[reportType]), cwd);
|
|
31
31
|
}
|
|
32
32
|
else {
|
|
33
|
-
logIssueRecord(issuesForType);
|
|
33
|
+
logIssueRecord(issuesForType, cwd);
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
totalIssues = totalIssues + issuesForType.length;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getIssueTypeTitle, getTableForType } from './util/util.js';
|
|
2
|
-
export default ({ report, issues }) => {
|
|
2
|
+
export default ({ report, issues, cwd }) => {
|
|
3
3
|
const reportMultipleGroups = Object.values(report).filter(Boolean).length > 1;
|
|
4
4
|
for (let [reportType, isReportType] of Object.entries(report)) {
|
|
5
5
|
if (reportType === 'files')
|
|
@@ -9,7 +9,7 @@ export default ({ report, issues }) => {
|
|
|
9
9
|
const issuesForType = Object.values(issues[reportType]).flatMap(Object.values);
|
|
10
10
|
if (issuesForType.length > 0) {
|
|
11
11
|
console.log(`<details>\n${title ? `<summary>${title} (${issuesForType.length})</summary>\n` : ''}\n\`\`\``);
|
|
12
|
-
console.log(getTableForType(issuesForType, { isUseColors: false }).toString());
|
|
12
|
+
console.log(getTableForType(issuesForType, cwd, { isUseColors: false }).toString());
|
|
13
13
|
console.log('```\n\n</details>\n');
|
|
14
14
|
}
|
|
15
15
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
2
|
symbols: (options: import("../index.js").ReporterOptions) => void;
|
|
3
|
-
compact: ({ report, issues, isShowProgress }: import("../index.js").ReporterOptions) => void;
|
|
4
|
-
codeowners: ({ report, issues, isShowProgress, options }: import("../index.js").ReporterOptions) => void;
|
|
5
|
-
disclosure: ({ report, issues }: import("../index.js").ReporterOptions) => void;
|
|
6
|
-
codeclimate: ({ report, issues }: import("../index.js").ReporterOptions) => Promise<void>;
|
|
7
|
-
json: ({ report, issues, options }: import("../index.js").ReporterOptions) => Promise<void>;
|
|
8
|
-
markdown: ({ report, issues }: import("../index.js").ReporterOptions) => void;
|
|
3
|
+
compact: ({ report, issues, isShowProgress, cwd }: import("../index.js").ReporterOptions) => void;
|
|
4
|
+
codeowners: ({ report, issues, isShowProgress, options, cwd }: import("../index.js").ReporterOptions) => void;
|
|
5
|
+
disclosure: ({ report, issues, cwd }: import("../index.js").ReporterOptions) => void;
|
|
6
|
+
codeclimate: ({ report, issues, cwd }: import("../index.js").ReporterOptions) => Promise<void>;
|
|
7
|
+
json: ({ report, issues, options, cwd }: import("../index.js").ReporterOptions) => Promise<void>;
|
|
8
|
+
markdown: ({ report, issues, cwd }: import("../index.js").ReporterOptions) => void;
|
|
9
9
|
};
|
|
10
10
|
export default _default;
|