knip 5.63.0 → 5.64.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/dist/CacheConsultant.d.ts +3 -9
- package/dist/CacheConsultant.js +5 -5
- package/dist/ConfigurationChief.d.ts +597 -38
- package/dist/ConfigurationChief.js +33 -122
- package/dist/ConsoleStreamer.d.ts +2 -3
- package/dist/ConsoleStreamer.js +2 -2
- package/dist/DependencyDeputy.d.ts +2 -6
- package/dist/DependencyDeputy.js +3 -2
- package/dist/IssueCollector.d.ts +4 -12
- package/dist/IssueCollector.js +9 -9
- package/dist/IssueFixer.d.ts +3 -14
- package/dist/IssueFixer.js +14 -22
- package/dist/PrincipalFactory.d.ts +3 -2
- package/dist/PrincipalFactory.js +11 -11
- package/dist/ProjectPrincipal.d.ts +4 -3
- package/dist/ProjectPrincipal.js +8 -8
- package/dist/WorkspaceWorker.d.ts +4 -9
- package/dist/WorkspaceWorker.js +8 -12
- package/dist/binaries/bash-parser.d.ts +1 -0
- package/dist/binaries/bash-parser.js +4 -1
- package/dist/binaries/fallback.js +3 -2
- package/dist/binaries/package-manager/bun.js +1 -0
- package/dist/binaries/package-manager/pnpm.js +6 -1
- package/dist/binaries/plugins.js +3 -1
- package/dist/cli.js +43 -61
- package/dist/compilers/index.d.ts +34 -4
- package/dist/constants.js +2 -0
- package/dist/graph/analyze.d.ts +3 -8
- package/dist/graph/analyze.js +31 -31
- package/dist/graph/build.d.ts +3 -17
- package/dist/graph/build.js +49 -46
- package/dist/index.d.ts +3 -7
- package/dist/index.js +22 -62
- package/dist/plugins/angular/index.js +2 -3
- package/dist/plugins/bumpp/index.d.ts +8 -0
- package/dist/plugins/bumpp/index.js +11 -0
- package/dist/plugins/eslint/index.d.ts +7 -0
- package/dist/plugins/eslint/index.js +12 -0
- package/dist/plugins/glob/index.d.ts +0 -1
- package/dist/plugins/glob/index.js +0 -1
- package/dist/plugins/index.d.ts +24 -7
- package/dist/plugins/index.js +6 -0
- package/dist/plugins/karma/helpers.js +1 -1
- package/dist/plugins/node-modules-inspector/index.d.ts +0 -1
- package/dist/plugins/node-modules-inspector/index.js +0 -1
- package/dist/plugins/nuxt/index.js +10 -3
- package/dist/plugins/nuxt/types.d.ts +3 -2
- package/dist/plugins/oxlint/index.d.ts +0 -1
- package/dist/plugins/oxlint/index.js +0 -1
- package/dist/plugins/playwright/index.d.ts +0 -1
- package/dist/plugins/playwright/index.js +0 -1
- package/dist/plugins/playwright-test/index.d.ts +0 -1
- package/dist/plugins/playwright-test/index.js +0 -1
- package/dist/plugins/pnpm/index.d.ts +8 -0
- package/dist/plugins/pnpm/index.js +12 -0
- package/dist/plugins/prisma/index.d.ts +0 -1
- package/dist/plugins/prisma/index.js +0 -1
- package/dist/plugins/rsbuild/index.js +23 -6
- package/dist/plugins/rsbuild/types.d.ts +3 -0
- package/dist/plugins/rslib/index.js +1 -1
- package/dist/plugins/rstest/index.d.ts +10 -0
- package/dist/plugins/rstest/index.js +29 -0
- package/dist/plugins/rstest/types.d.ts +6 -0
- package/dist/plugins/ts-node/index.d.ts +0 -1
- package/dist/plugins/ts-node/index.js +0 -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/githubActions.d.ts +3 -0
- package/dist/reporters/githubActions.js +94 -0
- package/dist/reporters/index.d.ts +7 -6
- package/dist/reporters/index.js +2 -0
- package/dist/reporters/json.d.ts +1 -1
- package/dist/reporters/json.js +4 -4
- package/dist/reporters/markdown.d.ts +1 -1
- package/dist/reporters/markdown.js +4 -4
- package/dist/reporters/symbols.js +1 -1
- package/dist/reporters/util/configuration-hints.d.ts +14 -2
- package/dist/reporters/util/configuration-hints.js +7 -7
- package/dist/reporters/util/util.d.ts +2 -2
- package/dist/reporters/util/util.js +4 -4
- 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/args.d.ts +2 -0
- package/dist/types/config.d.ts +4 -10
- package/dist/types/exports.d.ts +1 -1
- package/dist/types/imports.d.ts +1 -1
- package/dist/types/issues.d.ts +1 -2
- package/dist/types/module-graph.d.ts +5 -4
- 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 +1 -0
- package/dist/types/project.d.ts +1 -7
- package/dist/typescript/SourceFile.d.ts +2 -2
- package/dist/typescript/ast-helpers.d.ts +4 -0
- package/dist/typescript/ast-helpers.js +29 -0
- package/dist/typescript/find-internal-references.js +10 -1
- package/dist/typescript/get-imports-and-exports.d.ts +2 -2
- package/dist/typescript/get-imports-and-exports.js +32 -23
- package/dist/typescript/visitors/dynamic-imports/importCall.js +6 -1
- package/dist/util/Performance.js +16 -6
- package/dist/util/cli-arguments.d.ts +3 -3
- package/dist/util/cli-arguments.js +4 -14
- package/dist/util/create-options.d.ts +1238 -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/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/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 +2 -2
- package/dist/util/load-config.d.ts +2 -0
- package/dist/util/load-config.js +24 -0
- package/dist/util/modules.js +18 -7
- package/dist/util/path.d.ts +4 -4
- package/dist/util/path.js +5 -7
- package/dist/util/require.js +1 -2
- 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 +4 -4
- 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/rstest/types.js} +0 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { hasDependency } from '../../util/plugin.js';
|
|
2
|
+
const title = 'bumpp';
|
|
3
|
+
const enablers = ['bumpp'];
|
|
4
|
+
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
5
|
+
const entry = ['bump.config.{mjs,ts,js,cjs,mts,cts}'];
|
|
6
|
+
export default {
|
|
7
|
+
title,
|
|
8
|
+
enablers,
|
|
9
|
+
isEnabled,
|
|
10
|
+
entry,
|
|
11
|
+
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import type { ParsedArgs } from 'minimist';
|
|
1
2
|
import type { IsLoadConfig, IsPluginEnabled, ResolveConfig } from '../../types/config.js';
|
|
3
|
+
import { type Input } from '../../util/input.js';
|
|
2
4
|
import type { ESLintConfigDeprecated } from './types.js';
|
|
3
5
|
export declare const docs: {
|
|
4
6
|
note: string;
|
|
@@ -9,6 +11,11 @@ declare const _default: {
|
|
|
9
11
|
isEnabled: IsPluginEnabled;
|
|
10
12
|
packageJsonPath: string;
|
|
11
13
|
config: string[];
|
|
14
|
+
args: {
|
|
15
|
+
config: boolean;
|
|
16
|
+
boolean: string[];
|
|
17
|
+
resolveInputs: (parsed: ParsedArgs) => Input[];
|
|
18
|
+
};
|
|
12
19
|
isLoadConfig: IsLoadConfig;
|
|
13
20
|
resolveConfig: ResolveConfig<ESLintConfigDeprecated>;
|
|
14
21
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { toDependency } from '../../util/input.js';
|
|
1
2
|
import { hasDependency } from '../../util/plugin.js';
|
|
2
3
|
import { getInputs } from './helpers.js';
|
|
3
4
|
const title = 'ESLint';
|
|
@@ -41,12 +42,23 @@ consider using an extended glob pattern like this:
|
|
|
41
42
|
\`\`\`
|
|
42
43
|
`;
|
|
43
44
|
export const docs = { note };
|
|
45
|
+
const args = {
|
|
46
|
+
config: true,
|
|
47
|
+
boolean: ['inspect-config'],
|
|
48
|
+
resolveInputs: (parsed) => {
|
|
49
|
+
const inputs = [];
|
|
50
|
+
if (parsed['inspect-config'])
|
|
51
|
+
inputs.push(toDependency('@eslint/config-inspector', { optional: true }));
|
|
52
|
+
return inputs;
|
|
53
|
+
},
|
|
54
|
+
};
|
|
44
55
|
export default {
|
|
45
56
|
title,
|
|
46
57
|
enablers,
|
|
47
58
|
isEnabled,
|
|
48
59
|
packageJsonPath,
|
|
49
60
|
config,
|
|
61
|
+
args,
|
|
50
62
|
isLoadConfig,
|
|
51
63
|
resolveConfig,
|
|
52
64
|
};
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -39,6 +39,12 @@ export declare const Plugins: {
|
|
|
39
39
|
config: string[];
|
|
40
40
|
resolveConfig: import("../types/config.js").ResolveConfig<import("./biome/types.js").BiomeConfig>;
|
|
41
41
|
};
|
|
42
|
+
bumpp: {
|
|
43
|
+
title: string;
|
|
44
|
+
enablers: string[];
|
|
45
|
+
isEnabled: import("../types/config.js").IsPluginEnabled;
|
|
46
|
+
entry: string[];
|
|
47
|
+
};
|
|
42
48
|
bun: {
|
|
43
49
|
title: string;
|
|
44
50
|
enablers: string[];
|
|
@@ -181,6 +187,11 @@ export declare const Plugins: {
|
|
|
181
187
|
isEnabled: import("../types/config.js").IsPluginEnabled;
|
|
182
188
|
packageJsonPath: string;
|
|
183
189
|
config: string[];
|
|
190
|
+
args: {
|
|
191
|
+
config: boolean;
|
|
192
|
+
boolean: string[];
|
|
193
|
+
resolveInputs: (parsed: import("minimist").ParsedArgs) => import("../util/input.js").Input[];
|
|
194
|
+
};
|
|
184
195
|
isLoadConfig: import("../types/config.js").IsLoadConfig;
|
|
185
196
|
resolveConfig: import("../types/config.js").ResolveConfig<import("./eslint/types.js").ESLintConfigDeprecated>;
|
|
186
197
|
};
|
|
@@ -218,7 +229,6 @@ export declare const Plugins: {
|
|
|
218
229
|
glob: {
|
|
219
230
|
title: string;
|
|
220
231
|
args: {
|
|
221
|
-
binaries: string[];
|
|
222
232
|
positional: boolean;
|
|
223
233
|
alias: {
|
|
224
234
|
cmd: string[];
|
|
@@ -412,7 +422,6 @@ export declare const Plugins: {
|
|
|
412
422
|
isEnabled: import("../types/config.js").IsPluginEnabled;
|
|
413
423
|
config: string[];
|
|
414
424
|
args: {
|
|
415
|
-
binaries: string[];
|
|
416
425
|
config: boolean;
|
|
417
426
|
};
|
|
418
427
|
};
|
|
@@ -472,7 +481,6 @@ export declare const Plugins: {
|
|
|
472
481
|
isEnabled: import("../types/config.js").IsPluginEnabled;
|
|
473
482
|
config: string[];
|
|
474
483
|
args: {
|
|
475
|
-
binaries: string[];
|
|
476
484
|
config: boolean;
|
|
477
485
|
};
|
|
478
486
|
};
|
|
@@ -484,7 +492,6 @@ export declare const Plugins: {
|
|
|
484
492
|
entry: string[];
|
|
485
493
|
resolveConfig: import("../types/config.js").ResolveConfig<import("./playwright/types.js").PlaywrightTestConfig>;
|
|
486
494
|
args: {
|
|
487
|
-
binaries: string[];
|
|
488
495
|
positional: boolean;
|
|
489
496
|
args: (args: string[]) => string[];
|
|
490
497
|
config: boolean;
|
|
@@ -503,7 +510,6 @@ export declare const Plugins: {
|
|
|
503
510
|
enablers: string[];
|
|
504
511
|
isEnabled: import("../types/config.js").IsPluginEnabled;
|
|
505
512
|
args: {
|
|
506
|
-
binaries: string[];
|
|
507
513
|
positional: boolean;
|
|
508
514
|
args: (args: string[]) => string[];
|
|
509
515
|
config: boolean;
|
|
@@ -515,6 +521,12 @@ export declare const Plugins: {
|
|
|
515
521
|
isEnabled: import("../types/config.js").IsPluginEnabled;
|
|
516
522
|
config: string[];
|
|
517
523
|
};
|
|
524
|
+
pnpm: {
|
|
525
|
+
title: string;
|
|
526
|
+
isEnabled: import("../types/config.js").IsPluginEnabled;
|
|
527
|
+
isRootOnly: true;
|
|
528
|
+
config: string[];
|
|
529
|
+
};
|
|
518
530
|
postcss: {
|
|
519
531
|
title: string;
|
|
520
532
|
enablers: string[];
|
|
@@ -542,7 +554,6 @@ export declare const Plugins: {
|
|
|
542
554
|
isEnabled: import("../types/config.js").IsPluginEnabled;
|
|
543
555
|
config: string[];
|
|
544
556
|
args: {
|
|
545
|
-
binaries: string[];
|
|
546
557
|
config: boolean;
|
|
547
558
|
};
|
|
548
559
|
resolveConfig: import("../types/config.js").ResolveConfig<import("./prisma/types.js").PrismaConfig>;
|
|
@@ -624,6 +635,13 @@ export declare const Plugins: {
|
|
|
624
635
|
config: string[];
|
|
625
636
|
resolveConfig: import("../types/config.js").ResolveConfig<import("./webpack/types.js").WebpackConfig>;
|
|
626
637
|
};
|
|
638
|
+
rstest: {
|
|
639
|
+
title: string;
|
|
640
|
+
enablers: string[];
|
|
641
|
+
isEnabled: import("../types/config.js").IsPluginEnabled;
|
|
642
|
+
config: string[];
|
|
643
|
+
resolveConfig: import("../types/config.js").ResolveConfig<import("./rstest/types.js").RstestConfig>;
|
|
644
|
+
};
|
|
627
645
|
'semantic-release': {
|
|
628
646
|
title: string;
|
|
629
647
|
enablers: string[];
|
|
@@ -727,7 +745,6 @@ export declare const Plugins: {
|
|
|
727
745
|
'ts-node': {
|
|
728
746
|
title: string;
|
|
729
747
|
args: {
|
|
730
|
-
binaries: string[];
|
|
731
748
|
positional: boolean;
|
|
732
749
|
nodeImportArgs: boolean;
|
|
733
750
|
boolean: string[];
|
package/dist/plugins/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { default as astro } from './astro/index.js';
|
|
|
3
3
|
import { default as ava } from './ava/index.js';
|
|
4
4
|
import { default as babel } from './babel/index.js';
|
|
5
5
|
import { default as biome } from './biome/index.js';
|
|
6
|
+
import { default as bumpp } from './bumpp/index.js';
|
|
6
7
|
import { default as bun } from './bun/index.js';
|
|
7
8
|
import { default as c8 } from './c8/index.js';
|
|
8
9
|
import { default as capacitor } from './capacitor/index.js';
|
|
@@ -61,6 +62,7 @@ import { default as playwrightCt } from './playwright-ct/index.js';
|
|
|
61
62
|
import { default as playwrightTest } from './playwright-test/index.js';
|
|
62
63
|
import { default as playwright } from './playwright/index.js';
|
|
63
64
|
import { default as plop } from './plop/index.js';
|
|
65
|
+
import { default as pnpm } from './pnpm/index.js';
|
|
64
66
|
import { default as postcss } from './postcss/index.js';
|
|
65
67
|
import { default as preconstruct } from './preconstruct/index.js';
|
|
66
68
|
import { default as prettier } from './prettier/index.js';
|
|
@@ -75,6 +77,7 @@ import { default as rollup } from './rollup/index.js';
|
|
|
75
77
|
import { default as rsbuild } from './rsbuild/index.js';
|
|
76
78
|
import { default as rslib } from './rslib/index.js';
|
|
77
79
|
import { default as rspack } from './rspack/index.js';
|
|
80
|
+
import { default as rstest } from './rstest/index.js';
|
|
78
81
|
import { default as semanticRelease } from './semantic-release/index.js';
|
|
79
82
|
import { default as sentry } from './sentry/index.js';
|
|
80
83
|
import { default as simpleGitHooks } from './simple-git-hooks/index.js';
|
|
@@ -115,6 +118,7 @@ export const Plugins = {
|
|
|
115
118
|
ava,
|
|
116
119
|
babel,
|
|
117
120
|
biome,
|
|
121
|
+
bumpp,
|
|
118
122
|
bun,
|
|
119
123
|
c8,
|
|
120
124
|
capacitor,
|
|
@@ -173,6 +177,7 @@ export const Plugins = {
|
|
|
173
177
|
'playwright-ct': playwrightCt,
|
|
174
178
|
'playwright-test': playwrightTest,
|
|
175
179
|
plop,
|
|
180
|
+
pnpm,
|
|
176
181
|
postcss,
|
|
177
182
|
preconstruct,
|
|
178
183
|
prettier,
|
|
@@ -187,6 +192,7 @@ export const Plugins = {
|
|
|
187
192
|
rsbuild,
|
|
188
193
|
rslib,
|
|
189
194
|
rspack,
|
|
195
|
+
rstest,
|
|
190
196
|
'semantic-release': semanticRelease,
|
|
191
197
|
sentry,
|
|
192
198
|
'simple-git-hooks': simpleGitHooks,
|
|
@@ -15,7 +15,7 @@ export const inputsFromPlugins = (plugins, devDependencies) => {
|
|
|
15
15
|
return;
|
|
16
16
|
return isInternal(plugin) ? toDeferResolveEntry(plugin) : toDependency(plugin);
|
|
17
17
|
})
|
|
18
|
-
.filter(input => !!input);
|
|
18
|
+
.filter((input) => !!input);
|
|
19
19
|
};
|
|
20
20
|
export const loadConfig = (configFile) => {
|
|
21
21
|
if (typeof configFile !== 'function')
|
|
@@ -5,7 +5,6 @@ const enablers = ['node-modules-inspector'];
|
|
|
5
5
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
6
6
|
const config = [...toUnconfig('node-modules-inspector.config')];
|
|
7
7
|
const args = {
|
|
8
|
-
binaries: ['node-modules-inspector'],
|
|
9
8
|
config: true,
|
|
10
9
|
};
|
|
11
10
|
export default {
|
|
@@ -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,15 @@ 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?.reduce((acc, id) => {
|
|
38
|
+
if (Array.isArray(id) && typeof id[0] === 'string')
|
|
39
|
+
acc.push(toDependency(id[0]));
|
|
40
|
+
if (typeof id === 'string')
|
|
41
|
+
acc.push(toDependency(id));
|
|
42
|
+
return acc;
|
|
43
|
+
}, []) ?? [];
|
|
44
|
+
return [...deps, ...patterns];
|
|
38
45
|
};
|
|
39
46
|
const note = `Knip works best with [explicit imports](https://nuxt.com/docs/guide/concepts/auto-imports#explicit-imports).
|
|
40
47
|
Nuxt allows to [disable auto-imports](https://nuxt.com/docs/guide/concepts/auto-imports#disabling-auto-imports).`;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface NuxtConfig {
|
|
2
2
|
srcDir?: string;
|
|
3
3
|
dir?: {
|
|
4
4
|
pages?: string;
|
|
5
5
|
layouts?: string;
|
|
6
6
|
middleware?: string;
|
|
7
7
|
};
|
|
8
|
-
|
|
8
|
+
modules?: Array<string | ((inlineOptions: any, nuxt: any) => any) | [string, Record<string, any>]>;
|
|
9
|
+
}
|
|
@@ -3,7 +3,6 @@ const title = 'playwright-test';
|
|
|
3
3
|
const enablers = ['playwright-test'];
|
|
4
4
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
5
5
|
const args = {
|
|
6
|
-
binaries: ['playwright-test'],
|
|
7
6
|
positional: true,
|
|
8
7
|
args: (args) => args.filter(arg => arg !== 'install' && arg !== 'test'),
|
|
9
8
|
config: true,
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { _firstGlob } from '../../util/glob.js';
|
|
2
|
+
const title = 'pnpm';
|
|
3
|
+
const isEnabled = async ({ cwd, manifest }) => Boolean(manifest.packageManager?.startsWith('pnpm@') ||
|
|
4
|
+
(await _firstGlob({ cwd, patterns: ['pnpm-lock.yaml', 'pnpm-workspace.yaml'] })));
|
|
5
|
+
const isRootOnly = true;
|
|
6
|
+
const config = ['.pnpmfile.cjs'];
|
|
7
|
+
export default {
|
|
8
|
+
title,
|
|
9
|
+
isEnabled,
|
|
10
|
+
isRootOnly,
|
|
11
|
+
config,
|
|
12
|
+
};
|
|
@@ -6,12 +6,29 @@ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
|
6
6
|
const config = ['rsbuild*.config.{mjs,ts,js,cjs,mts,cts}'];
|
|
7
7
|
const resolveConfig = async (config) => {
|
|
8
8
|
const inputs = new Set();
|
|
9
|
-
|
|
10
|
-
if (
|
|
11
|
-
for (const entry of
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
+
}
|
|
15
32
|
}
|
|
16
33
|
return Array.from(inputs);
|
|
17
34
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { hasDependency } from '../../util/plugin.js';
|
|
2
2
|
const title = 'Rslib';
|
|
3
|
-
const enablers = ['rslib'];
|
|
3
|
+
const enablers = ['@rslib/core'];
|
|
4
4
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
5
5
|
const entry = ['rslib*.config.{mjs,ts,js,cjs,mts,cts}'];
|
|
6
6
|
const resolveConfig = () => {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IsPluginEnabled, ResolveConfig } from '../../types/config.js';
|
|
2
|
+
import type { RstestConfig } from './types.js';
|
|
3
|
+
declare const _default: {
|
|
4
|
+
title: string;
|
|
5
|
+
enablers: string[];
|
|
6
|
+
isEnabled: IsPluginEnabled;
|
|
7
|
+
config: string[];
|
|
8
|
+
resolveConfig: ResolveConfig<RstestConfig>;
|
|
9
|
+
};
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { toDeferResolve, toEntry } from '../../util/input.js';
|
|
2
|
+
import { hasDependency } from '../../util/plugin.js';
|
|
3
|
+
const title = 'Rstest';
|
|
4
|
+
const enablers = ['@rstest/core'];
|
|
5
|
+
const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
|
|
6
|
+
const config = ['rstest.config.{js,cjs,mjs,ts,cts,mts}'];
|
|
7
|
+
const mocks = ['**/__mocks__/**/*.?(c|m)[jt]s?(x)'];
|
|
8
|
+
const entry = ['**/*.{test,spec}.?(c|m)[jt]s?(x)'];
|
|
9
|
+
function testEnvironment(config) {
|
|
10
|
+
if (!config.testEnvironment || config.testEnvironment === 'node')
|
|
11
|
+
return [];
|
|
12
|
+
return [config.testEnvironment];
|
|
13
|
+
}
|
|
14
|
+
const resolveConfig = async (config) => {
|
|
15
|
+
const entries = (config.include ?? entry)
|
|
16
|
+
.concat(...mocks)
|
|
17
|
+
.map(toEntry)
|
|
18
|
+
.concat(...(config.exclude ?? []).map(id => toEntry(`!${id}`)));
|
|
19
|
+
const environments = testEnvironment(config);
|
|
20
|
+
const setupFiles = config.setupFiles ?? [];
|
|
21
|
+
return [...environments, ...setupFiles, ...entries].map(id => (typeof id === 'string' ? toDeferResolve(id) : id));
|
|
22
|
+
};
|
|
23
|
+
export default {
|
|
24
|
+
title,
|
|
25
|
+
enablers,
|
|
26
|
+
isEnabled,
|
|
27
|
+
config,
|
|
28
|
+
resolveConfig,
|
|
29
|
+
};
|
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
|
}
|