knip 6.43.0 → 6.44.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.
Files changed (168) hide show
  1. package/README.md +2 -4
  2. package/dist/CacheConsultant.d.ts +1 -0
  3. package/dist/CacheConsultant.js +2 -0
  4. package/dist/CatalogCounselor.d.ts +1 -3
  5. package/dist/CatalogCounselor.js +18 -15
  6. package/dist/ConfigurationChief.d.ts +24 -0
  7. package/dist/DependencyDeputy.d.ts +2 -1
  8. package/dist/DependencyDeputy.js +11 -6
  9. package/dist/IssueCollector.js +1 -0
  10. package/dist/ProjectPrincipal.d.ts +4 -2
  11. package/dist/ProjectPrincipal.js +32 -10
  12. package/dist/WorkspaceWorker.d.ts +5 -2
  13. package/dist/WorkspaceWorker.js +20 -7
  14. package/dist/binaries/resolvers/bun.js +7 -2
  15. package/dist/binaries/util.js +2 -1
  16. package/dist/cli.js +6 -1
  17. package/dist/compilers/index.d.ts +5 -0
  18. package/dist/compilers/index.js +1 -1
  19. package/dist/constants.d.ts +2 -0
  20. package/dist/constants.js +2 -0
  21. package/dist/graph/analyze.js +3 -2
  22. package/dist/graph/build.d.ts +2 -0
  23. package/dist/graph/build.js +37 -22
  24. package/dist/graph-explorer/cache.d.ts +2 -1
  25. package/dist/graph-explorer/cache.js +5 -1
  26. package/dist/graph-explorer/explorer.d.ts +3 -5
  27. package/dist/graph-explorer/explorer.js +24 -3
  28. package/dist/plugins/babel/index.js +6 -1
  29. package/dist/plugins/biome/index.js +1 -1
  30. package/dist/plugins/cspell/index.js +10 -2
  31. package/dist/plugins/dependency-cruiser/index.js +2 -2
  32. package/dist/plugins/docusaurus/helpers.js +4 -4
  33. package/dist/plugins/electron-vite/index.js +2 -2
  34. package/dist/plugins/eleventy/index.js +2 -2
  35. package/dist/plugins/expressive-code/index.d.ts +1 -1
  36. package/dist/plugins/expressive-code/index.js +2 -2
  37. package/dist/plugins/gatsby/index.js +6 -6
  38. package/dist/plugins/gatsby/types.d.ts +1 -1
  39. package/dist/plugins/github-actions/index.js +1 -1
  40. package/dist/plugins/i18next-parser/index.js +2 -2
  41. package/dist/plugins/index.d.ts +5 -1
  42. package/dist/plugins/index.js +8 -0
  43. package/dist/plugins/jasmine/index.js +2 -2
  44. package/dist/plugins/karma/index.js +4 -4
  45. package/dist/plugins/kysely-codegen/index.d.ts +3 -0
  46. package/dist/plugins/kysely-codegen/index.js +20 -0
  47. package/dist/plugins/lefthook/index.js +2 -2
  48. package/dist/plugins/lingui/index.d.ts +3 -0
  49. package/dist/plugins/lingui/index.js +16 -0
  50. package/dist/plugins/lockfile-lint/index.js +2 -2
  51. package/dist/plugins/lost-pixel/index.js +2 -2
  52. package/dist/plugins/lunaria/index.js +2 -2
  53. package/dist/plugins/marko/index.js +5 -6
  54. package/dist/plugins/mastra/index.d.ts +3 -0
  55. package/dist/plugins/mastra/index.js +57 -0
  56. package/dist/plugins/mcp/index.js +1 -1
  57. package/dist/plugins/mise/index.js +0 -3
  58. package/dist/plugins/mocha/index.js +43 -4
  59. package/dist/plugins/mocha/types.d.ts +1 -0
  60. package/dist/plugins/npm-package-json-lint/index.js +1 -1
  61. package/dist/plugins/npm-package-json-lint/types.d.ts +1 -1
  62. package/dist/plugins/nx/index.js +3 -8
  63. package/dist/plugins/nyc/index.js +1 -1
  64. package/dist/plugins/openapi-ts/index.js +2 -2
  65. package/dist/plugins/oxfmt/index.js +2 -2
  66. package/dist/plugins/playwright/index.js +6 -11
  67. package/dist/plugins/pnpm/index.js +2 -4
  68. package/dist/plugins/purgecss/index.d.ts +3 -0
  69. package/dist/plugins/purgecss/index.js +16 -0
  70. package/dist/plugins/railway/index.js +1 -4
  71. package/dist/plugins/relay/index.js +1 -1
  72. package/dist/plugins/release-it/index.js +1 -1
  73. package/dist/plugins/remix/index.js +1 -1
  74. package/dist/plugins/rsbuild/index.js +29 -1
  75. package/dist/plugins/rsbuild/types.d.ts +8 -0
  76. package/dist/plugins/rstest/index.js +2 -2
  77. package/dist/plugins/serverless-framework/index.js +1 -1
  78. package/dist/plugins/storybook/index.js +5 -5
  79. package/dist/plugins/sveltekit/resolveFromAST.js +1 -1
  80. package/dist/plugins/svgr/index.js +2 -1
  81. package/dist/plugins/swc/index.js +8 -3
  82. package/dist/plugins/syncpack/index.js +2 -2
  83. package/dist/plugins/tanstack-router/index.js +3 -2
  84. package/dist/plugins/taskfile/index.js +4 -7
  85. package/dist/plugins/textlint/helpers.js +2 -2
  86. package/dist/plugins/typescript/index.js +7 -3
  87. package/dist/plugins/unocss/index.js +2 -2
  88. package/dist/plugins/vite-plugin-pwa/index.js +1 -4
  89. package/dist/plugins/vite-plugin-pwa/resolveFromAST.d.ts +0 -2
  90. package/dist/plugins/vite-plugin-pwa/resolveFromAST.js +2 -2
  91. package/dist/plugins/vite-pwa-assets-generator/index.js +2 -2
  92. package/dist/plugins/vitest/helpers.js +4 -7
  93. package/dist/plugins/vitest/index.js +1 -1
  94. package/dist/plugins/webpack/index.d.ts +2 -0
  95. package/dist/plugins/webpack/index.js +11 -6
  96. package/dist/plugins/yarn/index.js +2 -4
  97. package/dist/reporters/codeclimate.d.ts +2 -2
  98. package/dist/reporters/codeclimate.js +2 -4
  99. package/dist/reporters/codeowners.d.ts +2 -2
  100. package/dist/reporters/codeowners.js +9 -9
  101. package/dist/reporters/compact.d.ts +2 -2
  102. package/dist/reporters/compact.js +8 -7
  103. package/dist/reporters/cycles.d.ts +2 -2
  104. package/dist/reporters/cycles.js +7 -6
  105. package/dist/reporters/disclosure.d.ts +2 -2
  106. package/dist/reporters/disclosure.js +6 -4
  107. package/dist/reporters/github-actions.d.ts +2 -2
  108. package/dist/reporters/github-actions.js +7 -5
  109. package/dist/reporters/index.d.ts +10 -10
  110. package/dist/reporters/json.d.ts +2 -2
  111. package/dist/reporters/json.js +2 -4
  112. package/dist/reporters/markdown.d.ts +2 -2
  113. package/dist/reporters/markdown.js +11 -9
  114. package/dist/reporters/sarif.d.ts +2 -2
  115. package/dist/reporters/sarif.js +2 -3
  116. package/dist/reporters/symbols.d.ts +2 -2
  117. package/dist/reporters/symbols.js +6 -4
  118. package/dist/run.d.ts +1 -1
  119. package/dist/run.js +3 -10
  120. package/dist/schema/configuration.d.ts +60 -0
  121. package/dist/schema/plugins.d.ts +20 -0
  122. package/dist/schema/plugins.js +4 -0
  123. package/dist/session/configuration.d.ts +15 -0
  124. package/dist/session/configuration.js +62 -0
  125. package/dist/session/incremental.d.ts +54 -0
  126. package/dist/session/incremental.js +49 -0
  127. package/dist/session/session.d.ts +1 -1
  128. package/dist/session/session.js +63 -27
  129. package/dist/session/watch.d.ts +2 -0
  130. package/dist/session/watch.js +41 -0
  131. package/dist/types/PluginNames.d.ts +2 -2
  132. package/dist/types/PluginNames.js +4 -0
  133. package/dist/types/config.d.ts +1 -0
  134. package/dist/types/issues.d.ts +4 -0
  135. package/dist/types/package-json.d.ts +0 -3
  136. package/dist/typescript/get-imports-and-exports.js +2 -0
  137. package/dist/typescript/visitors/calls.js +15 -11
  138. package/dist/typescript/visitors/imports.d.ts +3 -1
  139. package/dist/typescript/visitors/imports.js +77 -53
  140. package/dist/typescript/visitors/members.js +23 -26
  141. package/dist/typescript/visitors/walk.d.ts +3 -0
  142. package/dist/typescript/visitors/walk.js +43 -2
  143. package/dist/util/cli-arguments.d.ts +2 -1
  144. package/dist/util/cli-arguments.js +3 -0
  145. package/dist/util/create-input-handler.js +1 -1
  146. package/dist/util/create-options.d.ts +43 -2
  147. package/dist/util/create-options.js +17 -4
  148. package/dist/util/file-entry-cache.d.ts +2 -0
  149. package/dist/util/file-entry-cache.js +19 -1
  150. package/dist/util/gitignore-cache.d.ts +1 -0
  151. package/dist/util/gitignore-cache.js +1 -0
  152. package/dist/util/glob-core.js +4 -2
  153. package/dist/util/glob.d.ts +1 -0
  154. package/dist/util/glob.js +6 -0
  155. package/dist/util/input.d.ts +2 -0
  156. package/dist/util/loader.d.ts +1 -0
  157. package/dist/util/loader.js +29 -1
  158. package/dist/util/modules.js +5 -2
  159. package/dist/util/path.d.ts +1 -0
  160. package/dist/util/path.js +1 -0
  161. package/dist/util/reporter.d.ts +1 -1
  162. package/dist/util/reporter.js +53 -9
  163. package/dist/util/watch.d.ts +5 -11
  164. package/dist/util/watch.js +84 -68
  165. package/dist/version.d.ts +1 -1
  166. package/dist/version.js +1 -1
  167. package/package.json +1 -1
  168. package/schema.json +16 -0
@@ -1,5 +1,5 @@
1
1
  import { toEntry } from '../../util/input.js';
2
- import { isAbsolute, join } from '../../util/path.js';
2
+ import { toAbsolute } from '../../util/path.js';
3
3
  import { hasDependency } from '../../util/plugin.js';
4
4
  import { configFiles, inputsFromFrameworks, inputsFromPlugins, loadConfig } from './helpers.js';
5
5
  const title = 'Karma';
@@ -15,17 +15,17 @@ const resolveConfig = async (localConfig, options) => {
15
15
  inputsFromFrameworks(config.frameworks).forEach(inputs.add, inputs);
16
16
  }
17
17
  inputsFromPlugins(config.plugins, options.manifest.devDependencies).forEach(inputs.add, inputs);
18
- const basePath = config.basePath ?? '';
18
+ const basePath = toAbsolute(config.basePath ?? '', options.configFileDir);
19
19
  if (config.files) {
20
20
  for (const fileOrPatternObj of config.files) {
21
21
  const fileOrPattern = typeof fileOrPatternObj === 'string' ? fileOrPatternObj : fileOrPatternObj.pattern;
22
- const absPath = isAbsolute(fileOrPattern) ? fileOrPattern : join(options.configFileDir, basePath, fileOrPattern);
22
+ const absPath = toAbsolute(fileOrPattern, basePath);
23
23
  inputs.add(toEntry(absPath));
24
24
  }
25
25
  }
26
26
  if (config.exclude) {
27
27
  for (const fileOrPattern of config.exclude) {
28
- const absPath = isAbsolute(fileOrPattern) ? fileOrPattern : join(options.configFileDir, basePath, fileOrPattern);
28
+ const absPath = toAbsolute(fileOrPattern, basePath);
29
29
  inputs.add(toEntry(`!${absPath}`));
30
30
  }
31
31
  }
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from '../../types/config.ts';
2
+ declare const plugin: Plugin;
3
+ export default plugin;
@@ -0,0 +1,20 @@
1
+ import { hasDependency } from '../../util/plugin.js';
2
+ const title = 'kysely-codegen';
3
+ const enablers = ['kysely-codegen'];
4
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
5
+ const entry = [
6
+ '.kysely-codegenrc.{js,ts,cjs}',
7
+ '.config/kysely-codegenrc.{js,ts,cjs}',
8
+ 'kysely-codegen.config.{js,ts,cjs}',
9
+ ];
10
+ const args = {
11
+ config: ['config-file'],
12
+ };
13
+ const plugin = {
14
+ title,
15
+ enablers,
16
+ isEnabled,
17
+ entry,
18
+ args,
19
+ };
20
+ export default plugin;
@@ -1,7 +1,7 @@
1
1
  import { getGitHookPaths } from '../../util/git.js';
2
2
  import { fromBinary, toDependency } from '../../util/input.js';
3
3
  import { findByKeyDeep } from '../../util/object.js';
4
- import { extname } from '../../util/path.js';
4
+ import { extname, toAbsolute } from '../../util/path.js';
5
5
  import { hasDependency } from '../../util/plugin.js';
6
6
  const title = 'Lefthook';
7
7
  const enablers = ['lefthook', '@arkweid/lefthook', '@evilmartians/lefthook'];
@@ -22,7 +22,7 @@ const resolveConfig = async (localConfig, options) => {
22
22
  if (extname(configFileName) !== '') {
23
23
  const scripts = findByKeyDeep(localConfig, 'run').flatMap(command => {
24
24
  const deps = getInputsFromScripts([command.run], { ...options, optionalBinaries: true });
25
- const dir = command.root ?? cwd;
25
+ const dir = command.root ? toAbsolute(command.root, options.rootCwd) : cwd;
26
26
  return deps.flatMap(dependency => ({ ...dependency, dir }));
27
27
  });
28
28
  const lefthook = process.env.CI
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from '../../types/config.ts';
2
+ declare const plugin: Plugin;
3
+ export default plugin;
@@ -0,0 +1,16 @@
1
+ import { hasDependency } from '../../util/plugin.js';
2
+ const title = 'Lingui';
3
+ const enablers = ['@lingui/cli'];
4
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
5
+ const entry = ['lingui.config.{js,cjs,ts,mjs}', '.linguirc.{js,ts}'];
6
+ const args = {
7
+ config: ['config'],
8
+ };
9
+ const plugin = {
10
+ title,
11
+ enablers,
12
+ isEnabled,
13
+ entry,
14
+ args,
15
+ };
16
+ export default plugin;
@@ -3,11 +3,11 @@ import { toCosmiconfig } from '../../util/plugin-config.js';
3
3
  const title = 'lockfile-lint';
4
4
  const enablers = ['lockfile-lint'];
5
5
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
6
- const config = ['package.json', ...toCosmiconfig('lockfile-lint', { additionalExtensions: ['toml'] })];
6
+ const entry = ['package.json', ...toCosmiconfig('lockfile-lint', { additionalExtensions: ['toml'] })];
7
7
  const plugin = {
8
8
  title,
9
9
  enablers,
10
10
  isEnabled,
11
- config,
11
+ entry,
12
12
  };
13
13
  export default plugin;
@@ -2,11 +2,11 @@ import { hasDependency } from '../../util/plugin.js';
2
2
  const title = 'Lost Pixel';
3
3
  const enablers = ['lost-pixel'];
4
4
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
5
- const config = ['lostpixel.config.{js,ts}'];
5
+ const entry = ['lostpixel.config.{js,ts}'];
6
6
  const plugin = {
7
7
  title,
8
8
  enablers,
9
9
  isEnabled,
10
- config,
10
+ entry,
11
11
  };
12
12
  export default plugin;
@@ -1,4 +1,4 @@
1
- import { isAbsolute, join } from '../../util/path.js';
1
+ import { toAbsolute } from '../../util/path.js';
2
2
  import { toProductionEntry } from '../../util/input.js';
3
3
  import { hasDependency } from '../../util/plugin.js';
4
4
  const title = 'Lunaria';
@@ -13,7 +13,7 @@ const resolveConfig = async (localConfig, options) => {
13
13
  const customCss = localConfig.dashboard?.customCss ?? [];
14
14
  const favicon = localConfig.dashboard?.favicon?.inline ? [localConfig.dashboard.favicon.inline] : [];
15
15
  const baseDir = options.configFileDir;
16
- return [...files, ...renderer, ...customCss, ...favicon].map(id => toProductionEntry(isAbsolute(id) ? id : join(baseDir, id)));
16
+ return [...files, ...renderer, ...customCss, ...favicon].map(id => toProductionEntry(toAbsolute(id, baseDir)));
17
17
  };
18
18
  const args = {
19
19
  binaries: ['lunaria'],
@@ -1,5 +1,5 @@
1
1
  import { toDeferResolve, toProductionEntry } from '../../util/input.js';
2
- import { join, relative } from '../../util/path.js';
2
+ import { join } from '../../util/path.js';
3
3
  import { hasDependency } from '../../util/plugin.js';
4
4
  import { createCompiler } from './compiler.js';
5
5
  import { getTaglibDependencies } from './taglibs.js';
@@ -29,18 +29,17 @@ const tagDefFields = [
29
29
  'translate',
30
30
  ];
31
31
  const resolveConfig = (localConfig, options) => {
32
- const { configFileName, configFileDir, cwd } = options;
33
- const inputs = [];
32
+ const { configFileName, configFileDir } = options;
33
+ const inputs = production.map(pattern => toProductionEntry(pattern));
34
34
  if (!localConfig)
35
35
  return inputs;
36
36
  if (configFileName === 'marko.json') {
37
- const dir = relative(cwd, configFileDir);
38
- return tagProduction.map(pattern => toProductionEntry(join(dir, pattern)));
37
+ return tagProduction.map(pattern => toProductionEntry(join(configFileDir, pattern)));
39
38
  }
40
39
  for (const field of tagDefFields) {
41
40
  for (const id of [localConfig[field]].flat()) {
42
41
  if (typeof id === 'string')
43
- inputs.push(toDeferResolve(join(configFileDir, id)));
42
+ inputs.push(toDeferResolve(id));
44
43
  }
45
44
  }
46
45
  return inputs;
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from '../../types/config.ts';
2
+ declare const plugin: Plugin;
3
+ export default plugin;
@@ -0,0 +1,57 @@
1
+ import { join } from '../../util/path.js';
2
+ import { isDirectory } from '../../util/fs.js';
3
+ import { toProductionEntry } from '../../util/input.js';
4
+ import { hasDependency } from '../../util/plugin.js';
5
+ const title = 'Mastra';
6
+ const enablers = ['mastra'];
7
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
8
+ const extensions = '{js,ts}';
9
+ const defaultDir = 'src/mastra';
10
+ const discoveryCommands = new Set(['dev', 'build']);
11
+ const getProductionPatterns = (dir) => {
12
+ const agentRoots = `${dir}/agents/*/*(subagents/*/)`;
13
+ return [
14
+ `${dir}/index.${extensions}`,
15
+ `${dir}/{storage,observability,logger,server,studio}.{js,ts,mjs,mts}`,
16
+ `${dir}/workflows/*.${extensions}`,
17
+ `${dir}/{,agents/*/}tools/**/*.${extensions}`,
18
+ `${agentRoots}{config,instructions,memory,workspace}.${extensions}`,
19
+ `${agentRoots}{tools,scorers,skills,processors/input,processors/output}/*.${extensions}`,
20
+ `${agentRoots}schedules/**/*.${extensions}`,
21
+ `!${dir}/**/*.{test,spec}.${extensions}`,
22
+ `!${dir}/**/__tests__/**`,
23
+ ];
24
+ };
25
+ const production = getProductionPatterns(defaultDir);
26
+ const args = {
27
+ binaries: ['mastra'],
28
+ string: ['dir', 'tools'],
29
+ alias: { dir: ['d'], tools: ['t'] },
30
+ resolveInputs: (parsed, { cwd }) => {
31
+ if (!discoveryCommands.has(parsed._[0]))
32
+ return [];
33
+ const inputs = [];
34
+ if (parsed.dir) {
35
+ for (const pattern of getProductionPatterns(parsed.dir))
36
+ inputs.push(toProductionEntry(pattern));
37
+ }
38
+ if (parsed.tools) {
39
+ for (const tool of String(parsed.tools).split(',')) {
40
+ const specifier = tool.trim();
41
+ if (!specifier)
42
+ continue;
43
+ const pattern = isDirectory(join(cwd, specifier)) ? `${specifier}/index.${extensions}` : specifier;
44
+ inputs.push(toProductionEntry(pattern));
45
+ }
46
+ }
47
+ return inputs;
48
+ },
49
+ };
50
+ const plugin = {
51
+ title,
52
+ enablers,
53
+ isEnabled,
54
+ production,
55
+ args,
56
+ };
57
+ export default plugin;
@@ -15,7 +15,7 @@ const resolveConfig = async (localConfig, options) => {
15
15
  continue;
16
16
  const script = [server.command, ...(server.args ?? [])].join(' ').replace(PROJECT_DIR_VAR, '.');
17
17
  const dir = server.cwd ? toAbsolute(server.cwd.replace(PROJECT_DIR_VAR, '.'), cwd) : cwd;
18
- for (const input of getInputsFromScripts(script, { optionalBinaries: true })) {
18
+ for (const input of getInputsFromScripts(script, { optionalBinaries: true, cwd: dir })) {
19
19
  input.dir = dir;
20
20
  inputs.push(input);
21
21
  }
@@ -1,5 +1,4 @@
1
1
  import { isFile } from '../../util/fs.js';
2
- import { isEntry } from '../../util/input.js';
3
2
  import { basename, dirname, join, toAbsolute } from '../../util/path.js';
4
3
  const title = 'mise';
5
4
  const enablers = 'This plugin is enabled when `mise.toml` or `.mise.toml` is found.';
@@ -64,8 +63,6 @@ const resolveConfig = async (localConfig, options) => {
64
63
  if (isProduction)
65
64
  input.optional = true;
66
65
  input.dir ??= dir;
67
- if (isEntry(input))
68
- input.specifier = toAbsolute(input.specifier, input.dir);
69
66
  inputs.push(input);
70
67
  }
71
68
  }
@@ -4,17 +4,54 @@ import { hasDependency } from '../../util/plugin.js';
4
4
  const title = 'Mocha';
5
5
  const enablers = ['mocha'];
6
6
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
7
- const config = ['.mocharc.{js,cjs,json,jsonc,yml,yaml}', 'package.json'];
7
+ const config = ['.mocharc.{js,cjs,mjs,json,jsonc,yml,yaml}', 'package.json'];
8
8
  const entry = ['**/test/*.{js,cjs,mjs}'];
9
9
  const defaultExtensions = ['js', 'cjs', 'mjs'];
10
- const resolveConfig = localConfig => {
10
+ const builtInReporters = new Set([
11
+ 'Base',
12
+ 'base',
13
+ 'Dot',
14
+ 'dot',
15
+ 'Doc',
16
+ 'doc',
17
+ 'TAP',
18
+ 'tap',
19
+ 'JSON',
20
+ 'json',
21
+ 'HTML',
22
+ 'html',
23
+ 'List',
24
+ 'list',
25
+ 'Min',
26
+ 'min',
27
+ 'Spec',
28
+ 'spec',
29
+ 'Nyan',
30
+ 'nyan',
31
+ 'XUnit',
32
+ 'xunit',
33
+ 'Markdown',
34
+ 'markdown',
35
+ 'Progress',
36
+ 'progress',
37
+ 'Landing',
38
+ 'landing',
39
+ 'JSONStream',
40
+ 'json-stream',
41
+ 'GithubActions',
42
+ 'github-actions',
43
+ ]);
44
+ const isExternalReporter = (reporter) => typeof reporter === 'string' && !builtInReporters.has(reporter);
45
+ const resolveConfig = (localConfig, options) => {
11
46
  const entryPatterns = localConfig.spec ? [localConfig.spec].flat() : entry;
12
47
  const files = localConfig.file ? [localConfig.file].flat() : [];
13
48
  const require = localConfig.require ? [localConfig.require].flat() : [];
14
49
  const inputs = [];
15
50
  inputs.push(...entryPatterns.map(id => toEntry(id)));
16
- inputs.push(...files.map(id => toDeferResolveEntry(id)));
17
- inputs.push(...require.map(id => toDeferResolve(id)));
51
+ inputs.push(...files.map(id => toDeferResolveEntry(id, { dir: options.cwd })));
52
+ inputs.push(...require.map(id => toDeferResolve(id, { dir: options.cwd })));
53
+ if (isExternalReporter(localConfig.reporter))
54
+ inputs.push(toDeferResolve(localConfig.reporter, { dir: options.cwd }));
18
55
  return inputs;
19
56
  };
20
57
  const args = {
@@ -74,6 +111,8 @@ const args = {
74
111
  }
75
112
  for (const value of [parsed.ignore ?? []].flat())
76
113
  inputs.push(toEntry(`!${String(value)}`));
114
+ if (isExternalReporter(parsed.reporter))
115
+ inputs.push(toDeferResolve(parsed.reporter));
77
116
  return inputs;
78
117
  },
79
118
  };
@@ -1,5 +1,6 @@
1
1
  export interface MochaConfig {
2
2
  file?: string | string[];
3
+ reporter?: string;
3
4
  require?: string | string[];
4
5
  spec?: string | string[];
5
6
  }
@@ -7,7 +7,7 @@ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
7
7
  const packageJsonPath = 'npmpackagejsonlint';
8
8
  const config = ['package.json', ...toCosmiconfig('npmpackagejsonlint')];
9
9
  const resolveConfig = localConfig => {
10
- return localConfig?.extends ? [localConfig.extends].map(id => toDependency(id)) : [];
10
+ return localConfig?.extends ? [localConfig.extends].flat().map(id => toDependency(id)) : [];
11
11
  };
12
12
  const plugin = {
13
13
  title,
@@ -1,3 +1,3 @@
1
1
  export type NpmPkgJsonLintConfig = {
2
- extends?: string;
2
+ extends?: string | string[];
3
3
  };
@@ -2,7 +2,7 @@ import { compact } from '../../util/array.js';
2
2
  import { isFile, loadJSON } from '../../util/fs.js';
3
3
  import { toConfig, toDeferResolveEntry, toDependency } from '../../util/input.js';
4
4
  import { get } from '../../util/object.js';
5
- import { dirname, join, relative } from '../../util/path.js';
5
+ import { dirname, join, relative, toAbsolute } from '../../util/path.js';
6
6
  import { hasDependency } from '../../util/plugin.js';
7
7
  import { substringBefore } from '../../util/string.js';
8
8
  const title = 'Nx';
@@ -39,12 +39,7 @@ const resolveConfig = async (localConfig, options) => {
39
39
  .filter(executor => executor && !executor.startsWith('.'))
40
40
  .map(executor => executor && substringBefore(executor, ':'));
41
41
  const expand = (value) => value.replaceAll('{projectRoot}', options.configFileDir).replaceAll('{workspaceRoot}', options.rootCwd);
42
- const resolveTargetCwd = (targetCwd) => {
43
- if (!targetCwd)
44
- return options.cwd;
45
- const expanded = expand(targetCwd);
46
- return expanded === targetCwd ? join(options.cwd, targetCwd) : expanded;
47
- };
42
+ const resolveTargetCwd = (targetCwd) => targetCwd ? toAbsolute(expand(targetCwd), options.rootCwd) : options.cwd;
48
43
  const inputs = targets
49
44
  .filter(target => target.executor === 'nx:run-commands' || target.command)
50
45
  .flatMap(target => {
@@ -112,7 +107,7 @@ const resolve = async (options) => {
112
107
  continue;
113
108
  for (const id of [entry.implementation || entry.factory, entry.batchImplementation]) {
114
109
  if (typeof id === 'string' && id.length > 0) {
115
- inputs.push(toDeferResolveEntry(join(dirname(filePath), substringBefore(id, '#'))));
110
+ inputs.push(toDeferResolveEntry(substringBefore(id, '#'), { dir: dirname(filePath) }));
116
111
  }
117
112
  }
118
113
  }
@@ -3,7 +3,7 @@ import { hasDependency } from '../../util/plugin.js';
3
3
  const title = 'nyc';
4
4
  const enablers = ['nyc'];
5
5
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
6
- const config = ['.nycrc', '.nycrc.{json,yml,yaml}', 'nyc.config.js', 'package.json'];
6
+ const config = ['.nycrc', '.nycrc.{json,yml,yaml}', 'nyc.config.{js,cjs,mjs}', 'package.json'];
7
7
  const resolveConfig = config => {
8
8
  const extend = config?.extends ?? [];
9
9
  const requires = config?.require ?? [];
@@ -3,11 +3,11 @@ import { toC12config } from '../../util/plugin-config.js';
3
3
  const title = 'openapi-ts';
4
4
  const enablers = ['@hey-api/openapi-ts'];
5
5
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
6
- const config = ['package.json', ...toC12config('openapi-ts')];
6
+ const entry = ['package.json', ...toC12config('openapi-ts')];
7
7
  const plugin = {
8
8
  title,
9
9
  enablers,
10
10
  isEnabled,
11
- config,
11
+ entry,
12
12
  };
13
13
  export default plugin;
@@ -2,7 +2,7 @@ import { hasDependency } from '../../util/plugin.js';
2
2
  const title = 'Oxfmt';
3
3
  const enablers = ['oxfmt'];
4
4
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
5
- const config = ['.oxfmtrc.json', '.oxfmtrc.jsonc', 'oxfmt.config.{ts,mts}'];
5
+ const entry = ['.oxfmtrc.json', '.oxfmtrc.jsonc', 'oxfmt.config.{ts,mts}'];
6
6
  const args = {
7
7
  config: true,
8
8
  };
@@ -10,7 +10,7 @@ const plugin = {
10
10
  title,
11
11
  enablers,
12
12
  isEnabled,
13
- config,
13
+ entry,
14
14
  args,
15
15
  };
16
16
  export default plugin;
@@ -1,21 +1,21 @@
1
1
  import { arrayify } from '../../util/array.js';
2
2
  import { toDeferResolve, toEntry } from '../../util/input.js';
3
- import { join, relative, toAbsolute } from '../../util/path.js';
3
+ import { join, toAbsolute } from '../../util/path.js';
4
4
  import { hasDependency } from '../../util/plugin.js';
5
5
  const title = 'Playwright';
6
6
  const enablers = ['@playwright/test'];
7
7
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
8
8
  const config = ['playwright.config.{js,cjs,mjs,ts,cts,mts}'];
9
9
  export const entry = ['**/*.@(spec|test).?(c|m)[jt]s?(x)'];
10
- const toEntryPatterns = (testMatch, cwd, configDir, localConfig, rootConfig) => {
10
+ const toEntryPatterns = (testMatch, configDir, localConfig, rootConfig) => {
11
11
  const testDir = localConfig.testDir ?? rootConfig.testDir;
12
- const dir = relative(cwd, testDir ? join(configDir, testDir) : configDir);
12
+ const dir = testDir ? toAbsolute(testDir, configDir) : configDir;
13
13
  const patterns = [testMatch].flat().filter((p) => typeof p === 'string');
14
14
  return patterns.map(pattern => toEntry(join(dir, pattern)));
15
15
  };
16
16
  const builtinReporters = ['dot', 'line', 'list', 'junit', 'html', 'blob', 'json', 'github', 'null'];
17
17
  export const resolveConfig = async (localConfig, options) => {
18
- const { cwd, configFileDir } = options;
18
+ const { configFileDir } = options;
19
19
  const inputs = [];
20
20
  for (const id of arrayify(localConfig.globalSetup))
21
21
  inputs.push(toEntry(toAbsolute(id, configFileDir)));
@@ -30,12 +30,7 @@ export const resolveConfig = async (localConfig, options) => {
30
30
  cwd: dir,
31
31
  manifest: options.getManifest(dir) ?? options.manifest,
32
32
  })) {
33
- const inputDir = input.dir ?? dir;
34
- inputs.push({
35
- ...input,
36
- ...(input.type === 'entry' ? { specifier: toAbsolute(input.specifier, inputDir) } : {}),
37
- dir: inputDir,
38
- });
33
+ inputs.push({ ...input, dir: input.dir ?? dir });
39
34
  }
40
35
  }
41
36
  const projects = localConfig.projects ? [localConfig, ...localConfig.projects] : [localConfig];
@@ -46,7 +41,7 @@ export const resolveConfig = async (localConfig, options) => {
46
41
  return [name];
47
42
  });
48
43
  return projects
49
- .flatMap(config => toEntryPatterns(config.testMatch ?? entry, cwd, configFileDir, config, localConfig))
44
+ .flatMap(config => toEntryPatterns(config.testMatch ?? entry, configFileDir, config, localConfig))
50
45
  .concat(reporters.map(id => toDeferResolve(id)))
51
46
  .concat(inputs);
52
47
  };
@@ -12,10 +12,8 @@ const resolveConfig = config => {
12
12
  if (packageExtensions) {
13
13
  for (const extension of Object.values(packageExtensions)) {
14
14
  if (extension.peerDependencies) {
15
- for (const dep of Object.keys(extension.peerDependencies)) {
16
- const optional = extension.peerDependenciesMeta?.[dep]?.optional === true;
17
- inputs.push(optional ? toDependency(dep, { optional: true }) : toDependency(dep));
18
- }
15
+ for (const dep of Object.keys(extension.peerDependencies))
16
+ inputs.push(toDependency(dep, { optional: true }));
19
17
  }
20
18
  }
21
19
  }
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from '../../types/config.ts';
2
+ declare const plugin: Plugin;
3
+ export default plugin;
@@ -0,0 +1,16 @@
1
+ import { hasDependency } from '../../util/plugin.js';
2
+ const title = 'PurgeCSS';
3
+ const enablers = ['purgecss', '@fullhuman/postcss-purgecss'];
4
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
5
+ const entry = ['purgecss.config.js'];
6
+ const args = {
7
+ config: true,
8
+ };
9
+ const plugin = {
10
+ title,
11
+ enablers,
12
+ isEnabled,
13
+ entry,
14
+ args,
15
+ };
16
+ export default plugin;
@@ -2,8 +2,7 @@ import { Visitor } from 'oxc-parser';
2
2
  import { findProperty, getFirstPropertyValue, getStringValues } from '../../typescript/ast-helpers.js';
3
3
  import { getStringValue } from '../../typescript/ast-nodes.js';
4
4
  import { getGitRemoteUrls } from '../../util/git.js';
5
- import { isEntry } from '../../util/input.js';
6
- import { join, toAbsolute } from '../../util/path.js';
5
+ import { join } from '../../util/path.js';
7
6
  import { hasDependency } from '../../util/plugin.js';
8
7
  const title = 'Railway';
9
8
  const enablers = ['railway'];
@@ -109,8 +108,6 @@ const resolveFromAST = (program, options) => {
109
108
  ...getCommands(findProperty(findProperty(serviceConfig, 'deploy'), 'preDeployCommand')),
110
109
  ];
111
110
  for (const input of options.getInputsFromScripts(commands, { optionalBinaries: true, cwd, manifest })) {
112
- if (isEntry(input))
113
- input.specifier = toAbsolute(input.specifier, cwd);
114
111
  inputs.push({ ...input, dir: cwd });
115
112
  }
116
113
  },
@@ -5,7 +5,7 @@ import { hasDependency } from '../../util/plugin.js';
5
5
  const title = 'Relay';
6
6
  const enablers = ['vite-plugin-relay', '@swc/plugin-relay', 'babel-plugin-relay'];
7
7
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
8
- const config = ['relay.config.json', 'relay.config.js'];
8
+ const config = ['package.json', 'relay.config.json', 'relay.config.js'];
9
9
  const resolveConfig = async (config) => {
10
10
  const projects = 'projects' in config ? Object.values(config.projects) : [config];
11
11
  return projects.map(project => {
@@ -3,7 +3,7 @@ import { hasDependency } from '../../util/plugin.js';
3
3
  const title = 'Release It!';
4
4
  const enablers = ['release-it'];
5
5
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
6
- const config = ['.release-it.{json,js,cjs,ts,yml,yaml,toml}', 'package.json'];
6
+ const config = ['.release-it.{json,jsonc,json5,js,mjs,cjs,ts,mts,cts,yml,yaml,toml}', 'package.json'];
7
7
  const resolveConfig = (config, options) => {
8
8
  const plugins = config.plugins ? Object.keys(config.plugins) : [];
9
9
  const scripts = config.hooks ? Object.values(config.hooks).flat() : [];
@@ -1,6 +1,6 @@
1
1
  import { hasDependency } from '../../util/plugin.js';
2
2
  const title = 'Remix';
3
- const enablers = [/^@remix-run\//];
3
+ const enablers = ['@remix-run/dev'];
4
4
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
5
5
  const entry = ['remix.config.js', 'remix.init/index.js'];
6
6
  const production = [
@@ -1,6 +1,7 @@
1
- import { toProductionEntry } from '../../util/input.js';
1
+ import { toDeferResolve, toProductionEntry } from '../../util/input.js';
2
2
  import { hasDependency } from '../../util/plugin.js';
3
3
  import { resolveConfig as resolveRspackConfig } from '../rspack/index.js';
4
+ import { getSwcPluginSpecifiers } from '../webpack/index.js';
4
5
  const title = 'Rsbuild';
5
6
  const enablers = ['@rsbuild/core'];
6
7
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
@@ -17,6 +18,22 @@ const getConfigs = async (configOrFn) => {
17
18
  configs.push(await configOrFn(params));
18
19
  return configs;
19
20
  };
21
+ const getAliases = (chain) => {
22
+ const aliases = {};
23
+ for (const item of [chain].flat()) {
24
+ if (typeof item === 'function')
25
+ continue;
26
+ for (const key in item) {
27
+ const targets = [];
28
+ for (const target of [item[key]].flat())
29
+ if (typeof target === 'string')
30
+ targets.push(target);
31
+ if (targets.length > 0)
32
+ aliases[key] = targets;
33
+ }
34
+ }
35
+ return aliases;
36
+ };
20
37
  const resolveConfig = async (configOrFn, options) => {
21
38
  const entries = new Set();
22
39
  const inputs = [];
@@ -48,6 +65,17 @@ const resolveConfig = async (configOrFn, options) => {
48
65
  };
49
66
  const checkConfig = async (localConfig, config) => {
50
67
  checkSource(localConfig.source);
68
+ const alias = localConfig.resolve?.alias;
69
+ if (alias) {
70
+ for (const input of await resolveRspackConfig({ resolve: { alias: getAliases(alias) } }, options)) {
71
+ inputs.push(input);
72
+ }
73
+ }
74
+ const swc = localConfig.tools?.swc;
75
+ if (swc && typeof swc === 'object') {
76
+ for (const specifier of getSwcPluginSpecifiers(swc))
77
+ inputs.push(toDeferResolve(specifier));
78
+ }
51
79
  if (!localConfig.tools?.rspack)
52
80
  return;
53
81
  const target = localConfig.output?.target ?? config.output?.target ?? 'web';
@@ -1,4 +1,5 @@
1
1
  import type { Configuration } from 'webpack';
2
+ import type { SWCConfig } from '../swc/types.ts';
2
3
  type EntryDescription = Record<string, unknown>;
3
4
  type Entry = Record<string, string | string[] | (EntryDescription & {
4
5
  html?: boolean;
@@ -12,18 +13,25 @@ type RspackConfigUtils = {
12
13
  isWebWorker: boolean;
13
14
  };
14
15
  type RspackConfig = Configuration | ((config: Configuration, utils: RspackConfigUtils) => Configuration | void | Promise<Configuration | void>);
16
+ type AliasObject = Record<string, string | false | (string | false)[]>;
17
+ type Alias = AliasObject | ((aliases: AliasObject) => AliasObject | void);
18
+ export type AliasChain = Alias | Alias[];
15
19
  export type RsbuildConfig = {
16
20
  plugins?: unknown[];
17
21
  mode?: 'development' | 'production' | 'none';
18
22
  output?: {
19
23
  target?: RspackConfigUtils['target'];
20
24
  };
25
+ resolve?: {
26
+ alias?: AliasChain;
27
+ };
21
28
  source?: {
22
29
  entry?: Entry;
23
30
  preEntry?: string | string[];
24
31
  };
25
32
  tools?: {
26
33
  rspack?: RspackConfig | RspackConfig[];
34
+ swc?: SWCConfig | ((config: SWCConfig) => SWCConfig | void);
27
35
  };
28
36
  environments?: {
29
37
  [k: string]: Omit<RsbuildConfig, 'environments'>;