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.
Files changed (146) hide show
  1. package/dist/CacheConsultant.d.ts +3 -9
  2. package/dist/CacheConsultant.js +5 -5
  3. package/dist/ConfigurationChief.d.ts +597 -38
  4. package/dist/ConfigurationChief.js +33 -122
  5. package/dist/ConsoleStreamer.d.ts +2 -3
  6. package/dist/ConsoleStreamer.js +2 -2
  7. package/dist/DependencyDeputy.d.ts +2 -6
  8. package/dist/DependencyDeputy.js +3 -2
  9. package/dist/IssueCollector.d.ts +4 -12
  10. package/dist/IssueCollector.js +9 -9
  11. package/dist/IssueFixer.d.ts +3 -14
  12. package/dist/IssueFixer.js +14 -22
  13. package/dist/PrincipalFactory.d.ts +3 -2
  14. package/dist/PrincipalFactory.js +11 -11
  15. package/dist/ProjectPrincipal.d.ts +4 -3
  16. package/dist/ProjectPrincipal.js +8 -8
  17. package/dist/WorkspaceWorker.d.ts +4 -9
  18. package/dist/WorkspaceWorker.js +8 -12
  19. package/dist/binaries/bash-parser.d.ts +1 -0
  20. package/dist/binaries/bash-parser.js +4 -1
  21. package/dist/binaries/fallback.js +3 -2
  22. package/dist/binaries/package-manager/bun.js +1 -0
  23. package/dist/binaries/package-manager/pnpm.js +6 -1
  24. package/dist/binaries/plugins.js +3 -1
  25. package/dist/cli.js +43 -61
  26. package/dist/compilers/index.d.ts +34 -4
  27. package/dist/constants.js +2 -0
  28. package/dist/graph/analyze.d.ts +3 -8
  29. package/dist/graph/analyze.js +31 -31
  30. package/dist/graph/build.d.ts +3 -17
  31. package/dist/graph/build.js +49 -46
  32. package/dist/index.d.ts +3 -7
  33. package/dist/index.js +22 -62
  34. package/dist/plugins/angular/index.js +2 -3
  35. package/dist/plugins/bumpp/index.d.ts +8 -0
  36. package/dist/plugins/bumpp/index.js +11 -0
  37. package/dist/plugins/eslint/index.d.ts +7 -0
  38. package/dist/plugins/eslint/index.js +12 -0
  39. package/dist/plugins/glob/index.d.ts +0 -1
  40. package/dist/plugins/glob/index.js +0 -1
  41. package/dist/plugins/index.d.ts +24 -7
  42. package/dist/plugins/index.js +6 -0
  43. package/dist/plugins/karma/helpers.js +1 -1
  44. package/dist/plugins/node-modules-inspector/index.d.ts +0 -1
  45. package/dist/plugins/node-modules-inspector/index.js +0 -1
  46. package/dist/plugins/nuxt/index.js +10 -3
  47. package/dist/plugins/nuxt/types.d.ts +3 -2
  48. package/dist/plugins/oxlint/index.d.ts +0 -1
  49. package/dist/plugins/oxlint/index.js +0 -1
  50. package/dist/plugins/playwright/index.d.ts +0 -1
  51. package/dist/plugins/playwright/index.js +0 -1
  52. package/dist/plugins/playwright-test/index.d.ts +0 -1
  53. package/dist/plugins/playwright-test/index.js +0 -1
  54. package/dist/plugins/pnpm/index.d.ts +8 -0
  55. package/dist/plugins/pnpm/index.js +12 -0
  56. package/dist/plugins/prisma/index.d.ts +0 -1
  57. package/dist/plugins/prisma/index.js +0 -1
  58. package/dist/plugins/rsbuild/index.js +23 -6
  59. package/dist/plugins/rsbuild/types.d.ts +3 -0
  60. package/dist/plugins/rslib/index.js +1 -1
  61. package/dist/plugins/rstest/index.d.ts +10 -0
  62. package/dist/plugins/rstest/index.js +29 -0
  63. package/dist/plugins/rstest/types.d.ts +6 -0
  64. package/dist/plugins/ts-node/index.d.ts +0 -1
  65. package/dist/plugins/ts-node/index.js +0 -1
  66. package/dist/plugins.js +3 -2
  67. package/dist/reporters/codeclimate.d.ts +1 -1
  68. package/dist/reporters/codeclimate.js +10 -10
  69. package/dist/reporters/codeowners.d.ts +1 -1
  70. package/dist/reporters/codeowners.js +5 -5
  71. package/dist/reporters/compact.d.ts +1 -1
  72. package/dist/reporters/compact.js +7 -7
  73. package/dist/reporters/disclosure.d.ts +1 -1
  74. package/dist/reporters/disclosure.js +2 -2
  75. package/dist/reporters/githubActions.d.ts +3 -0
  76. package/dist/reporters/githubActions.js +94 -0
  77. package/dist/reporters/index.d.ts +7 -6
  78. package/dist/reporters/index.js +2 -0
  79. package/dist/reporters/json.d.ts +1 -1
  80. package/dist/reporters/json.js +4 -4
  81. package/dist/reporters/markdown.d.ts +1 -1
  82. package/dist/reporters/markdown.js +4 -4
  83. package/dist/reporters/symbols.js +1 -1
  84. package/dist/reporters/util/configuration-hints.d.ts +14 -2
  85. package/dist/reporters/util/configuration-hints.js +7 -7
  86. package/dist/reporters/util/util.d.ts +2 -2
  87. package/dist/reporters/util/util.js +4 -4
  88. package/dist/reporters/watch.d.ts +3 -4
  89. package/dist/reporters/watch.js +5 -5
  90. package/dist/schema/configuration.d.ts +176 -8
  91. package/dist/schema/plugins.d.ts +69 -0
  92. package/dist/schema/plugins.js +3 -0
  93. package/dist/types/PluginNames.d.ts +2 -2
  94. package/dist/types/PluginNames.js +3 -0
  95. package/dist/types/args.d.ts +2 -0
  96. package/dist/types/config.d.ts +4 -10
  97. package/dist/types/exports.d.ts +1 -1
  98. package/dist/types/imports.d.ts +1 -1
  99. package/dist/types/issues.d.ts +1 -2
  100. package/dist/types/module-graph.d.ts +5 -4
  101. package/dist/types/{cli.d.ts → options.d.ts} +2 -2
  102. package/dist/types/options.js +1 -0
  103. package/dist/types/package-json.d.ts +1 -0
  104. package/dist/types/project.d.ts +1 -7
  105. package/dist/typescript/SourceFile.d.ts +2 -2
  106. package/dist/typescript/ast-helpers.d.ts +4 -0
  107. package/dist/typescript/ast-helpers.js +29 -0
  108. package/dist/typescript/find-internal-references.js +10 -1
  109. package/dist/typescript/get-imports-and-exports.d.ts +2 -2
  110. package/dist/typescript/get-imports-and-exports.js +32 -23
  111. package/dist/typescript/visitors/dynamic-imports/importCall.js +6 -1
  112. package/dist/util/Performance.js +16 -6
  113. package/dist/util/cli-arguments.d.ts +3 -3
  114. package/dist/util/cli-arguments.js +4 -14
  115. package/dist/util/create-options.d.ts +1238 -0
  116. package/dist/util/create-options.js +112 -0
  117. package/dist/util/debug.js +3 -4
  118. package/dist/util/errors.d.ts +1 -1
  119. package/dist/util/file-entry-cache.js +3 -3
  120. package/dist/util/get-included-issue-types.d.ts +9 -13
  121. package/dist/util/get-included-issue-types.js +10 -16
  122. package/dist/util/get-referenced-inputs.js +1 -1
  123. package/dist/util/input.d.ts +1 -1
  124. package/dist/util/input.js +1 -1
  125. package/dist/util/is-identifier-referenced.d.ts +1 -1
  126. package/dist/util/is-identifier-referenced.js +2 -2
  127. package/dist/util/load-config.d.ts +2 -0
  128. package/dist/util/load-config.js +24 -0
  129. package/dist/util/modules.js +18 -7
  130. package/dist/util/path.d.ts +4 -4
  131. package/dist/util/path.js +5 -7
  132. package/dist/util/require.js +1 -2
  133. package/dist/util/tag.d.ts +1 -1
  134. package/dist/util/to-source-path.d.ts +1 -1
  135. package/dist/util/to-source-path.js +5 -5
  136. package/dist/util/trace.d.ts +6 -6
  137. package/dist/util/trace.js +18 -22
  138. package/dist/util/watch.d.ts +2 -5
  139. package/dist/util/watch.js +3 -3
  140. package/dist/version.d.ts +1 -1
  141. package/dist/version.js +1 -1
  142. package/package.json +4 -4
  143. package/schema.json +12 -0
  144. package/dist/util/unwrap-function.d.ts +0 -1
  145. package/dist/util/unwrap-function.js +0 -13
  146. /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
  };
@@ -1,7 +1,6 @@
1
1
  declare const _default: {
2
2
  title: string;
3
3
  args: {
4
- binaries: string[];
5
4
  positional: boolean;
6
5
  alias: {
7
6
  cmd: string[];
@@ -1,6 +1,5 @@
1
1
  const title = 'glob';
2
2
  const args = {
3
- binaries: ['glob'],
4
3
  positional: true,
5
4
  alias: { cmd: ['c'] },
6
5
  fromArgs: ['cmd'],
@@ -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[];
@@ -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 @@ declare const _default: {
5
5
  isEnabled: IsPluginEnabled;
6
6
  config: string[];
7
7
  args: {
8
- binaries: string[];
9
8
  config: boolean;
10
9
  };
11
10
  };
@@ -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
- return patterns.map(pattern => toProductionEntry(join(srcDir, pattern)));
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 type NuxtConfig = {
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
+ }
@@ -5,7 +5,6 @@ declare const _default: {
5
5
  isEnabled: IsPluginEnabled;
6
6
  config: string[];
7
7
  args: {
8
- binaries: string[];
9
8
  config: boolean;
10
9
  };
11
10
  };
@@ -4,7 +4,6 @@ const enablers = ['oxlint'];
4
4
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
5
5
  const config = ['.oxlintrc.json'];
6
6
  const args = {
7
- binaries: ['oxlint'],
8
7
  config: true,
9
8
  };
10
9
  export default {
@@ -10,7 +10,6 @@ declare const _default: {
10
10
  entry: string[];
11
11
  resolveConfig: ResolveConfig<PlaywrightTestConfig>;
12
12
  args: {
13
- binaries: string[];
14
13
  positional: boolean;
15
14
  args: (args: string[]) => string[];
16
15
  config: boolean;
@@ -34,7 +34,6 @@ export const resolveConfig = async (localConfig, options) => {
34
34
  .concat(inputs);
35
35
  };
36
36
  const args = {
37
- binaries: ['playwright'],
38
37
  positional: true,
39
38
  args: (args) => args.filter(arg => arg !== 'install' && arg !== 'test'),
40
39
  config: true,
@@ -4,7 +4,6 @@ declare const _default: {
4
4
  enablers: string[];
5
5
  isEnabled: IsPluginEnabled;
6
6
  args: {
7
- binaries: string[];
8
7
  positional: boolean;
9
8
  args: (args: string[]) => string[];
10
9
  config: boolean;
@@ -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,8 @@
1
+ import type { IsPluginEnabled } from '../../types/config.js';
2
+ declare const _default: {
3
+ title: string;
4
+ isEnabled: IsPluginEnabled;
5
+ isRootOnly: true;
6
+ config: string[];
7
+ };
8
+ export default _default;
@@ -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,7 +6,6 @@ declare const _default: {
6
6
  isEnabled: IsPluginEnabled;
7
7
  config: string[];
8
8
  args: {
9
- binaries: string[];
10
9
  config: boolean;
11
10
  };
12
11
  resolveConfig: ResolveConfig<PrismaConfig>;
@@ -10,7 +10,6 @@ const resolveConfig = async (config, options) => {
10
10
  return [];
11
11
  };
12
12
  const args = {
13
- binaries: ['prisma'],
14
13
  config: true,
15
14
  };
16
15
  export default {
@@ -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
- if (config.source?.entry) {
10
- if (Array.isArray(config.source.entry))
11
- for (const entry of config.source.entry)
12
- inputs.add(toEntry(entry));
13
- if (typeof config.source.entry === 'string')
14
- inputs.add(toEntry(config.source.entry));
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
  };
@@ -7,5 +7,8 @@ export type RsbuildConfig = {
7
7
  source?: {
8
8
  entry?: Entry;
9
9
  };
10
+ environments?: {
11
+ [k: string]: Pick<RsbuildConfig, 'plugins' | 'source'>;
12
+ };
10
13
  };
11
14
  export {};
@@ -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
+ };
@@ -0,0 +1,6 @@
1
+ export type RstestConfig = {
2
+ include?: string[];
3
+ exclude?: string[];
4
+ testEnvironment?: 'node' | 'jsdom' | 'happy-dom';
5
+ setupFiles?: string[];
6
+ };
@@ -1,7 +1,6 @@
1
1
  declare const _default: {
2
2
  title: string;
3
3
  args: {
4
- binaries: string[];
5
4
  positional: boolean;
6
5
  nodeImportArgs: boolean;
7
6
  boolean: string[];
@@ -1,6 +1,5 @@
1
1
  const title = 'ts-node';
2
2
  const args = {
3
- binaries: [title],
4
3
  positional: true,
5
4
  nodeImportArgs: true,
6
5
  boolean: ['transpileOnly', 'compilerHost', 'ignoreDiagnostics', 'swc', 'preferTsExts'],
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 { performance: isEnabled = false } = parsedArgValues;
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) {
@@ -1,3 +1,3 @@
1
1
  import type { ReporterOptions } from '../types/issues.js';
2
- declare const _default: ({ report, issues }: ReporterOptions) => Promise<void>;
2
+ declare const _default: ({ report, issues, cwd }: ReporterOptions) => Promise<void>;
3
3
  export default _default;
@@ -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,3 +1,3 @@
1
1
  import type { ReporterOptions } from '../types/issues.js';
2
- declare const _default: ({ report, issues, isShowProgress }: ReporterOptions) => void;
2
+ declare const _default: ({ report, issues, isShowProgress, cwd }: ReporterOptions) => void;
3
3
  export default _default;