knip 2.31.0 → 2.32.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 (100) hide show
  1. package/README.md +15 -24
  2. package/dist/ConfigurationValidator.d.ts +56 -0
  3. package/dist/ConfigurationValidator.js +1 -0
  4. package/dist/WorkspaceWorker.d.ts +8 -6
  5. package/dist/WorkspaceWorker.js +33 -59
  6. package/dist/binaries/index.js +1 -1
  7. package/dist/binaries/resolvers/c8.js +2 -1
  8. package/dist/binaries/resolvers/dotenv.js +2 -1
  9. package/dist/binaries/resolvers/fallback.js +2 -1
  10. package/dist/binaries/resolvers/nodemon.js +2 -1
  11. package/dist/binaries/resolvers/npx.js +2 -1
  12. package/dist/binaries/resolvers/nx.js +1 -1
  13. package/dist/binaries/resolvers/pnpm.js +1 -1
  14. package/dist/binaries/resolvers/rollup.js +2 -1
  15. package/dist/binaries/resolvers/yarn.js +1 -1
  16. package/dist/binaries/util.d.ts +0 -3
  17. package/dist/binaries/util.js +1 -3
  18. package/dist/constants.d.ts +0 -1
  19. package/dist/constants.js +0 -4
  20. package/dist/index.js +19 -18
  21. package/dist/plugins/ava/index.d.ts +1 -1
  22. package/dist/plugins/ava/index.js +23 -5
  23. package/dist/plugins/ava/types.d.ts +1 -0
  24. package/dist/plugins/babel/index.js +3 -1
  25. package/dist/plugins/capacitor/index.js +3 -1
  26. package/dist/plugins/changesets/index.js +3 -1
  27. package/dist/plugins/commitizen/index.d.ts +1 -0
  28. package/dist/plugins/commitizen/index.js +4 -1
  29. package/dist/plugins/commitlint/index.js +3 -1
  30. package/dist/plugins/cspell/index.js +3 -1
  31. package/dist/plugins/cypress/index.d.ts +3 -1
  32. package/dist/plugins/cypress/index.js +14 -4
  33. package/dist/plugins/drizzle/index.js +3 -5
  34. package/dist/plugins/eslint/helpers.js +2 -1
  35. package/dist/plugins/eslint/index.d.ts +1 -0
  36. package/dist/plugins/eslint/index.js +4 -1
  37. package/dist/plugins/gatsby/index.js +10 -2
  38. package/dist/plugins/github-actions/index.js +3 -1
  39. package/dist/plugins/husky/index.js +3 -1
  40. package/dist/plugins/index.d.ts +1 -0
  41. package/dist/plugins/index.js +1 -0
  42. package/dist/plugins/jest/index.d.ts +1 -1
  43. package/dist/plugins/jest/index.js +16 -7
  44. package/dist/plugins/lefthook/index.js +4 -2
  45. package/dist/plugins/lint-staged/index.d.ts +1 -0
  46. package/dist/plugins/lint-staged/index.js +4 -1
  47. package/dist/plugins/markdownlint/index.js +3 -1
  48. package/dist/plugins/mocha/index.d.ts +1 -0
  49. package/dist/plugins/mocha/index.js +10 -6
  50. package/dist/plugins/next/index.d.ts +2 -1
  51. package/dist/plugins/next/index.js +4 -0
  52. package/dist/plugins/node-test-runner/index.d.ts +6 -0
  53. package/dist/plugins/node-test-runner/index.js +17 -0
  54. package/dist/plugins/npm-package-json-lint/index.d.ts +1 -0
  55. package/dist/plugins/npm-package-json-lint/index.js +5 -2
  56. package/dist/plugins/nx/index.js +3 -1
  57. package/dist/plugins/nyc/index.js +3 -1
  58. package/dist/plugins/playwright/index.d.ts +3 -1
  59. package/dist/plugins/playwright/index.js +22 -2
  60. package/dist/plugins/playwright-ct/index.d.ts +3 -1
  61. package/dist/plugins/playwright-ct/index.js +13 -2
  62. package/dist/plugins/postcss/index.js +8 -6
  63. package/dist/plugins/prettier/index.js +3 -1
  64. package/dist/plugins/release-it/index.d.ts +1 -0
  65. package/dist/plugins/release-it/index.js +5 -2
  66. package/dist/plugins/remark/index.d.ts +1 -0
  67. package/dist/plugins/remark/index.js +10 -3
  68. package/dist/plugins/remix/index.d.ts +2 -1
  69. package/dist/plugins/remix/index.js +10 -0
  70. package/dist/plugins/rollup/index.d.ts +2 -1
  71. package/dist/plugins/rollup/index.js +7 -0
  72. package/dist/plugins/semantic-release/index.d.ts +1 -0
  73. package/dist/plugins/semantic-release/index.js +7 -2
  74. package/dist/plugins/sentry/index.d.ts +2 -1
  75. package/dist/plugins/sentry/index.js +7 -0
  76. package/dist/plugins/storybook/index.js +6 -2
  77. package/dist/plugins/stryker/index.js +9 -8
  78. package/dist/plugins/stylelint/index.js +3 -1
  79. package/dist/plugins/svelte/index.d.ts +2 -1
  80. package/dist/plugins/svelte/index.js +6 -0
  81. package/dist/plugins/typedoc/index.d.ts +1 -0
  82. package/dist/plugins/typedoc/index.js +5 -2
  83. package/dist/plugins/typescript/index.js +3 -1
  84. package/dist/plugins/vite/index.js +2 -2
  85. package/dist/plugins/vitest/index.d.ts +3 -3
  86. package/dist/plugins/vitest/index.js +16 -23
  87. package/dist/plugins/vitest/types.d.ts +1 -0
  88. package/dist/plugins/webpack/index.js +3 -1
  89. package/dist/types/config.d.ts +3 -2
  90. package/dist/types/plugins.d.ts +3 -3
  91. package/dist/util/compilers.d.ts +10 -0
  92. package/dist/util/object.d.ts +1 -0
  93. package/dist/util/object.js +1 -0
  94. package/dist/util/plugin.d.ts +1 -1
  95. package/dist/util/protocols.d.ts +9 -0
  96. package/dist/util/protocols.js +9 -0
  97. package/dist/version.d.ts +1 -1
  98. package/dist/version.js +1 -1
  99. package/package.json +2 -1
  100. package/schema.json +4 -0
@@ -1,6 +1,7 @@
1
1
  import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
2
2
  export declare const NAME = "npm-package-json-lint";
3
3
  export declare const ENABLERS: string[];
4
+ export declare const PACKAGE_JSON_PATH = "npmpackagejsonlint";
4
5
  export declare const isEnabled: IsPluginEnabledCallback;
5
6
  export declare const CONFIG_FILE_PATTERNS: string[];
6
7
  export declare const findDependencies: GenericPluginCallback;
@@ -2,11 +2,14 @@ import { timerify } from '../../util/Performance.js';
2
2
  import { hasDependency, load } from '../../util/plugin.js';
3
3
  export const NAME = 'npm-package-json-lint';
4
4
  export const ENABLERS = ['npm-package-json-lint'];
5
+ export const PACKAGE_JSON_PATH = 'npmpackagejsonlint';
5
6
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
6
7
  export const CONFIG_FILE_PATTERNS = ['.npmpackagejsonlintrc.json', 'npmpackagejsonlint.config.js', 'package.json'];
7
- const findNpmPkgJsonLintConfigDependencies = async (configFilePath, { manifest }) => {
8
+ const findNpmPkgJsonLintConfigDependencies = async (configFilePath, { manifest, isProduction }) => {
9
+ if (isProduction)
10
+ return [];
8
11
  const config = configFilePath.endsWith('package.json')
9
- ? manifest.npmpackagejsonlint
12
+ ? manifest[PACKAGE_JSON_PATH]
10
13
  : await load(configFilePath);
11
14
  return config?.extends ? [config.extends] : [];
12
15
  };
@@ -6,7 +6,9 @@ export const NAME = 'Nx';
6
6
  export const ENABLERS = ['nx', /^@nrwl\//];
7
7
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
8
8
  export const CONFIG_FILE_PATTERNS = ['project.json', '{apps,libs}/**/project.json'];
9
- const findNxDependencies = async (configFilePath, { cwd, manifest }) => {
9
+ const findNxDependencies = async (configFilePath, { cwd, manifest, isProduction }) => {
10
+ if (isProduction)
11
+ return [];
10
12
  const config = await load(configFilePath);
11
13
  if (!config)
12
14
  return [];
@@ -4,7 +4,9 @@ export const NAME = 'nyc';
4
4
  export const ENABLERS = ['nyc'];
5
5
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
6
6
  export const CONFIG_FILE_PATTERNS = ['.nycrc', '.nycrc.json', '.nycrc.{yml,yaml}', 'nyc.config.js'];
7
- const findNycDependencies = async (configFilePath) => {
7
+ const findNycDependencies = async (configFilePath, { isProduction }) => {
8
+ if (isProduction)
9
+ return [];
8
10
  const config = await load(configFilePath);
9
11
  return config.extends ? [config.extends].flat() : [];
10
12
  };
@@ -1,5 +1,7 @@
1
- import type { IsPluginEnabledCallback } from '../../types/plugins.js';
1
+ import type { GenericPluginCallback, IsPluginEnabledCallback } from '../../types/plugins.js';
2
2
  export declare const NAME = "Playwright";
3
3
  export declare const ENABLERS: string[];
4
4
  export declare const isEnabled: IsPluginEnabledCallback;
5
5
  export declare const ENTRY_FILE_PATTERNS: string[];
6
+ export declare const CONFIG_FILE_PATTERNS: string[];
7
+ export declare const findDependencies: GenericPluginCallback;
@@ -1,5 +1,25 @@
1
- import { hasDependency } from '../../util/plugin.js';
1
+ import { dirname, join, relative } from '../../util/path.js';
2
+ import { timerify } from '../../util/Performance.js';
3
+ import { hasDependency, load } from '../../util/plugin.js';
4
+ import { toEntryPattern } from '../../util/protocols.js';
2
5
  export const NAME = 'Playwright';
3
6
  export const ENABLERS = ['@playwright/test'];
4
7
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
5
- export const ENTRY_FILE_PATTERNS = ['playwright.config.{js,ts}'];
8
+ export const ENTRY_FILE_PATTERNS = ['**/*.@(spec|test).?(c|m)[jt]s?(x)'];
9
+ export const CONFIG_FILE_PATTERNS = ['playwright.config.{js,ts}'];
10
+ const toEntryPatterns = (testMatch, cwd, configFilePath, config) => {
11
+ if (!testMatch)
12
+ return [];
13
+ const dir = relative(cwd, config.testDir ? join(dirname(configFilePath), config.testDir) : dirname(configFilePath));
14
+ const patterns = [testMatch].flat().filter((p) => typeof p === 'string');
15
+ return patterns.map(pattern => toEntryPattern(join(dir, pattern)));
16
+ };
17
+ const findPlaywrightDependencies = async (configFilePath, { cwd }) => {
18
+ const config = await load(configFilePath);
19
+ const projects = config.projects ? [config, ...config.projects] : [config];
20
+ const patterns = projects.flatMap(config => toEntryPatterns(config.testMatch, cwd, configFilePath, config));
21
+ if (patterns.length > 0)
22
+ return patterns;
23
+ return toEntryPatterns(ENTRY_FILE_PATTERNS, cwd, configFilePath, config);
24
+ };
25
+ export const findDependencies = timerify(findPlaywrightDependencies);
@@ -1,5 +1,7 @@
1
- import type { IsPluginEnabledCallback } from '../../types/plugins.js';
1
+ import type { GenericPluginCallback, IsPluginEnabledCallback } from '../../types/plugins.js';
2
2
  export declare const NAME = "Playwright for components";
3
3
  export declare const ENABLERS: RegExp[];
4
4
  export declare const isEnabled: IsPluginEnabledCallback;
5
+ export declare const CONFIG_FILE_PATTERNS: string[];
5
6
  export declare const ENTRY_FILE_PATTERNS: string[];
7
+ export declare const findDependencies: GenericPluginCallback;
@@ -1,5 +1,16 @@
1
- import { hasDependency } from '../../util/plugin.js';
1
+ import { dirname, join } from '../../util/path.js';
2
+ import { timerify } from '../../util/Performance.js';
3
+ import { hasDependency, load } from '../../util/plugin.js';
4
+ import { toEntryPattern } from '../../util/protocols.js';
2
5
  export const NAME = 'Playwright for components';
3
6
  export const ENABLERS = [/^@playwright\/experimental-ct-/];
4
7
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
5
- export const ENTRY_FILE_PATTERNS = ['playwright-ct.config.{js,ts}', 'playwright/index.{js,ts,jsx,tsx}'];
8
+ export const CONFIG_FILE_PATTERNS = ['playwright-ct.config.{js,ts}', 'playwright/index.{js,ts,jsx,tsx}'];
9
+ export const ENTRY_FILE_PATTERNS = ['**/*.@(spec|test).?(c|m)[jt]s?(x)'];
10
+ const findPlaywrightCTDependencies = async (configFilePath) => {
11
+ const cfg = await load(configFilePath);
12
+ const dir = cfg.testDir ? join(dirname(configFilePath), cfg.testDir) : dirname(configFilePath);
13
+ const entryPatterns = (cfg.testMatch ? [cfg.testMatch] : ENTRY_FILE_PATTERNS).map(p => toEntryPattern(join(dir, p)));
14
+ return entryPatterns;
15
+ };
16
+ export const findDependencies = timerify(findPlaywrightCTDependencies);
@@ -4,18 +4,20 @@ export const NAME = 'PostCSS';
4
4
  export const ENABLERS = ['postcss', 'next'];
5
5
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
6
6
  export const CONFIG_FILE_PATTERNS = ['postcss.config.js', 'postcss.config.json', 'package.json'];
7
- const findPostCSSDependencies = async (configFilePath, { manifest }) => {
7
+ const findPostCSSDependencies = async (configFilePath, { manifest, isProduction }) => {
8
+ if (isProduction)
9
+ return [];
8
10
  const config = configFilePath.endsWith('package.json')
9
11
  ? manifest?.postcss
10
12
  : await load(configFilePath);
11
- return config?.plugins
13
+ if (!config)
14
+ return [];
15
+ return config.plugins
12
16
  ? (Array.isArray(config.plugins) ? config.plugins : Object.keys(config.plugins)).flatMap(plugin => {
13
- if (typeof plugin === 'string') {
17
+ if (typeof plugin === 'string')
14
18
  return plugin;
15
- }
16
- if (Array.isArray(plugin) && typeof plugin[0] === 'string') {
19
+ if (Array.isArray(plugin) && typeof plugin[0] === 'string')
17
20
  return plugin[0];
18
- }
19
21
  return [];
20
22
  })
21
23
  : [];
@@ -9,7 +9,9 @@ export const CONFIG_FILE_PATTERNS = [
9
9
  'prettier.config.{js,cjs}',
10
10
  'package.json',
11
11
  ];
12
- const findPrettierDependencies = async (configFilePath, { manifest }) => {
12
+ const findPrettierDependencies = async (configFilePath, { manifest, isProduction }) => {
13
+ if (isProduction)
14
+ return [];
13
15
  const config = configFilePath.endsWith('package.json')
14
16
  ? manifest.prettier
15
17
  : await load(configFilePath);
@@ -1,6 +1,7 @@
1
1
  import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
2
2
  export declare const NAME = "Release It";
3
3
  export declare const ENABLERS: string[];
4
+ export declare const PACKAGE_JSON_PATH = "release-it";
4
5
  export declare const isEnabled: IsPluginEnabledCallback;
5
6
  export declare const CONFIG_FILE_PATTERNS: string[];
6
7
  export declare const findDependencies: GenericPluginCallback;
@@ -3,6 +3,7 @@ import { timerify } from '../../util/Performance.js';
3
3
  import { hasDependency, load } from '../../util/plugin.js';
4
4
  export const NAME = 'Release It';
5
5
  export const ENABLERS = ['release-it'];
6
+ export const PACKAGE_JSON_PATH = 'release-it';
6
7
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
7
8
  export const CONFIG_FILE_PATTERNS = [
8
9
  '.release-it.json',
@@ -10,9 +11,11 @@ export const CONFIG_FILE_PATTERNS = [
10
11
  '.release-it.{yml,yaml}',
11
12
  'package.json',
12
13
  ];
13
- const findReleaseItDependencies = async (configFilePath, { cwd, manifest }) => {
14
+ const findReleaseItDependencies = async (configFilePath, { cwd, manifest, isProduction }) => {
15
+ if (isProduction)
16
+ return [];
14
17
  const config = configFilePath.endsWith('package.json')
15
- ? manifest['release-it']
18
+ ? manifest[PACKAGE_JSON_PATH]
16
19
  : await load(configFilePath);
17
20
  if (!config)
18
21
  return [];
@@ -1,6 +1,7 @@
1
1
  import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
2
2
  export declare const NAME = "Remark";
3
3
  export declare const ENABLERS: string[];
4
+ export declare const PACKAGE_JSON_PATH = "remarkConfig";
4
5
  export declare const isEnabled: IsPluginEnabledCallback;
5
6
  export declare const CONFIG_FILE_PATTERNS: string[];
6
7
  export declare const findDependencies: GenericPluginCallback;
@@ -2,6 +2,7 @@ import { timerify } from '../../util/Performance.js';
2
2
  import { hasDependency, load } from '../../util/plugin.js';
3
3
  export const NAME = 'Remark';
4
4
  export const ENABLERS = ['remark-cli'];
5
+ export const PACKAGE_JSON_PATH = 'remarkConfig';
5
6
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
6
7
  export const CONFIG_FILE_PATTERNS = [
7
8
  'package.json',
@@ -10,9 +11,15 @@ export const CONFIG_FILE_PATTERNS = [
10
11
  '.remarkrc.{js,cjs,mjs}',
11
12
  '.remarkrc.{yml,yaml}',
12
13
  ];
13
- const findRemarkDependencies = async (configFilePath, { manifest }) => {
14
- const config = configFilePath.endsWith('package.json') ? manifest.remarkConfig : await load(configFilePath);
15
- const plugins = config?.plugins?.map(plugin => `remark-${plugin}`) ?? [];
14
+ const findRemarkDependencies = async (configFilePath, { manifest, isProduction }) => {
15
+ if (isProduction)
16
+ return [];
17
+ const config = configFilePath.endsWith('package.json')
18
+ ? manifest[PACKAGE_JSON_PATH]
19
+ : await load(configFilePath);
20
+ if (!config)
21
+ return [];
22
+ const plugins = config.plugins?.map(plugin => `remark-${plugin}`) ?? [];
16
23
  return [...plugins];
17
24
  };
18
25
  export const findDependencies = timerify(findRemarkDependencies);
@@ -1,6 +1,7 @@
1
- import type { IsPluginEnabledCallback } from '../../types/plugins.js';
1
+ import type { GenericPluginCallback, IsPluginEnabledCallback } from '../../types/plugins.js';
2
2
  export declare const NAME = "Remix";
3
3
  export declare const ENABLERS: RegExp[];
4
4
  export declare const isEnabled: IsPluginEnabledCallback;
5
5
  export declare const ENTRY_FILE_PATTERNS: string[];
6
6
  export declare const PRODUCTION_ENTRY_FILE_PATTERNS: string[];
7
+ export declare const findDependencies: GenericPluginCallback;
@@ -1,4 +1,6 @@
1
+ import { timerify } from '../../util/Performance.js';
1
2
  import { hasDependency } from '../../util/plugin.js';
3
+ import { toEntryPattern, toProductionEntryPattern } from '../../util/protocols.js';
2
4
  export const NAME = 'Remix';
3
5
  export const ENABLERS = [/^@remix-run\//];
4
6
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
@@ -9,3 +11,11 @@ export const PRODUCTION_ENTRY_FILE_PATTERNS = [
9
11
  'app/routes/**/*.{js,ts,tsx}',
10
12
  'server.{js,ts}',
11
13
  ];
14
+ const findRemixDependencies = async () => {
15
+ const entryPatterns = [
16
+ ...ENTRY_FILE_PATTERNS.map(toEntryPattern),
17
+ ...PRODUCTION_ENTRY_FILE_PATTERNS.map(toProductionEntryPattern),
18
+ ];
19
+ return entryPatterns;
20
+ };
21
+ export const findDependencies = timerify(findRemixDependencies);
@@ -1,5 +1,6 @@
1
- import type { IsPluginEnabledCallback } from '../../types/plugins.js';
1
+ import type { GenericPluginCallback, IsPluginEnabledCallback } from '../../types/plugins.js';
2
2
  export declare const NAME = "Rollup";
3
3
  export declare const ENABLERS: string[];
4
4
  export declare const isEnabled: IsPluginEnabledCallback;
5
5
  export declare const ENTRY_FILE_PATTERNS: string[];
6
+ export declare const findDependencies: GenericPluginCallback;
@@ -1,5 +1,12 @@
1
+ import { timerify } from '../../util/Performance.js';
1
2
  import { hasDependency } from '../../util/plugin.js';
3
+ import { toEntryPattern } from '../../util/protocols.js';
2
4
  export const NAME = 'Rollup';
3
5
  export const ENABLERS = ['rollup'];
4
6
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
5
7
  export const ENTRY_FILE_PATTERNS = ['rollup.config.{js,mjs,ts}'];
8
+ const findRollupDependencies = async () => {
9
+ const entryPatterns = ENTRY_FILE_PATTERNS.map(toEntryPattern);
10
+ return entryPatterns;
11
+ };
12
+ export const findDependencies = timerify(findRollupDependencies);
@@ -1,6 +1,7 @@
1
1
  import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
2
2
  export declare const NAME = "Semantic Release";
3
3
  export declare const ENABLERS: string[];
4
+ export declare const PACKAGE_JSON_PATH = "release";
4
5
  export declare const isEnabled: IsPluginEnabledCallback;
5
6
  export declare const CONFIG_FILE_PATTERNS: string[];
6
7
  export declare const findDependencies: GenericPluginCallback;
@@ -2,6 +2,7 @@ import { timerify } from '../../util/Performance.js';
2
2
  import { hasDependency, load } from '../../util/plugin.js';
3
3
  export const NAME = 'Semantic Release';
4
4
  export const ENABLERS = ['semantic-release'];
5
+ export const PACKAGE_JSON_PATH = 'release';
5
6
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
6
7
  export const CONFIG_FILE_PATTERNS = [
7
8
  '.releaserc',
@@ -9,8 +10,12 @@ export const CONFIG_FILE_PATTERNS = [
9
10
  'release.config.{js,cjs}',
10
11
  'package.json',
11
12
  ];
12
- const findSemanticReleaseDependencies = async (configFilePath, { manifest }) => {
13
- const config = configFilePath.endsWith('package.json') ? manifest.release : await load(configFilePath);
13
+ const findSemanticReleaseDependencies = async (configFilePath, { manifest, isProduction }) => {
14
+ if (isProduction)
15
+ return [];
16
+ const config = configFilePath.endsWith('package.json')
17
+ ? manifest[PACKAGE_JSON_PATH]
18
+ : await load(configFilePath);
14
19
  const plugins = config?.plugins ?? [];
15
20
  return plugins.map(plugin => (Array.isArray(plugin) ? plugin[0] : plugin));
16
21
  };
@@ -1,5 +1,6 @@
1
- import type { IsPluginEnabledCallback } from '../../types/plugins.js';
1
+ import type { GenericPluginCallback, IsPluginEnabledCallback } from '../../types/plugins.js';
2
2
  export declare const NAME = "Sentry";
3
3
  export declare const ENABLERS: RegExp[];
4
4
  export declare const isEnabled: IsPluginEnabledCallback;
5
5
  export declare const ENTRY_FILE_PATTERNS: string[];
6
+ export declare const findDependencies: GenericPluginCallback;
@@ -1,5 +1,12 @@
1
+ import { timerify } from '../../util/Performance.js';
1
2
  import { hasDependency } from '../../util/plugin.js';
3
+ import { toEntryPattern } from '../../util/protocols.js';
2
4
  export const NAME = 'Sentry';
3
5
  export const ENABLERS = [/^@sentry\//];
4
6
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
5
7
  export const ENTRY_FILE_PATTERNS = ['sentry.{client,server,edge}.config.{js,ts}'];
8
+ const findSentryDependencies = async () => {
9
+ const entryPatterns = ENTRY_FILE_PATTERNS.map(toEntryPattern);
10
+ return entryPatterns;
11
+ };
12
+ export const findDependencies = timerify(findSentryDependencies);
@@ -1,12 +1,16 @@
1
1
  import { timerify } from '../../util/Performance.js';
2
2
  import { hasDependency, load } from '../../util/plugin.js';
3
+ import { toEntryPattern } from '../../util/protocols.js';
3
4
  export const NAME = 'Storybook';
4
5
  export const ENABLERS = [/^@storybook\//, '@nrwl/storybook'];
5
6
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
6
7
  export const CONFIG_FILE_PATTERNS = ['.storybook/{main,manager,test-runner}.{js,ts}'];
7
8
  export const ENTRY_FILE_PATTERNS = ['.storybook/preview.{js,jsx,ts,tsx}', '**/*.stories.{js,jsx,ts,tsx}'];
8
9
  export const PROJECT_FILE_PATTERNS = ['.storybook/**/*.{js,jsx,ts,tsx}'];
9
- const findStorybookDependencies = async (configFilePath) => {
10
+ const findStorybookDependencies = async (configFilePath, { isProduction }) => {
11
+ const entryPatterns = ENTRY_FILE_PATTERNS.map(toEntryPattern);
12
+ if (isProduction)
13
+ return entryPatterns;
10
14
  const config = await load(configFilePath);
11
15
  if (!config)
12
16
  return [];
@@ -14,6 +18,6 @@ const findStorybookDependencies = async (configFilePath) => {
14
18
  const builder = config?.core?.builder;
15
19
  const builderPackages = builder && /webpack/.test(builder) ? [`@storybook/builder-${builder}`, `@storybook/manager-${builder}`] : [];
16
20
  const frameworks = config.framework?.name ? [config.framework.name] : [];
17
- return [...addons, ...builderPackages, ...frameworks];
21
+ return [...entryPatterns, ...addons, ...builderPackages, ...frameworks];
18
22
  };
19
23
  export const findDependencies = timerify(findStorybookDependencies);
@@ -4,14 +4,15 @@ export const NAME = 'Stryker';
4
4
  export const ENABLERS = ['@stryker-mutator/core'];
5
5
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
6
6
  export const CONFIG_FILE_PATTERNS = ['?(.)stryker.{conf,config}.{js,mjs,cjs,json}'];
7
- const findStrykerDependencies = async (configFilePath) => {
7
+ const findStrykerDependencies = async (configFilePath, { isProduction }) => {
8
+ if (isProduction)
9
+ return [];
8
10
  const config = await load(configFilePath);
9
- if (config) {
10
- const runners = config.testRunner ? [`@stryker-mutator/${config.testRunner}-runner`] : [];
11
- const checkers = config.checkers ? config.checkers.map(checker => `@stryker-mutator/${checker}-checker`) : [];
12
- const plugins = config.plugins ?? [];
13
- return [...runners, ...checkers, ...plugins];
14
- }
15
- return [];
11
+ if (!config)
12
+ return [];
13
+ const runners = config.testRunner ? [`@stryker-mutator/${config.testRunner}-runner`] : [];
14
+ const checkers = config.checkers ? config.checkers.map(checker => `@stryker-mutator/${checker}-checker`) : [];
15
+ const plugins = config.plugins ?? [];
16
+ return [...runners, ...checkers, ...plugins];
16
17
  };
17
18
  export const findDependencies = timerify(findStrykerDependencies);
@@ -9,7 +9,9 @@ export const CONFIG_FILE_PATTERNS = [
9
9
  '.stylelintrc.{cjs,js,json,yaml,yml}',
10
10
  'stylelint.config.{cjs,mjs,js}',
11
11
  ];
12
- const findPluginDependencies = async (configFilePath, { manifest }) => {
12
+ const findPluginDependencies = async (configFilePath, { manifest, isProduction }) => {
13
+ if (isProduction)
14
+ return [];
13
15
  const config = configFilePath.endsWith('package.json')
14
16
  ? manifest.stylelint
15
17
  : await load(configFilePath);
@@ -1,7 +1,8 @@
1
- import type { IsPluginEnabledCallback } from '../../types/plugins.js';
1
+ import type { GenericPluginCallback, IsPluginEnabledCallback } from '../../types/plugins.js';
2
2
  export declare const NAME = "Svelte";
3
3
  export declare const ENABLERS: string[];
4
4
  export declare const isEnabled: IsPluginEnabledCallback;
5
5
  export declare const ENTRY_FILE_PATTERNS: string[];
6
6
  export declare const PRODUCTION_ENTRY_FILE_PATTERNS: string[];
7
7
  export declare const PROJECT_FILE_PATTERNS: string[];
8
+ export declare const findDependencies: GenericPluginCallback;
@@ -1,4 +1,6 @@
1
+ import { timerify } from '../../util/Performance.js';
1
2
  import { hasDependency } from '../../util/plugin.js';
3
+ import { toEntryPattern, toProductionEntryPattern } from '../../util/protocols.js';
2
4
  export const NAME = 'Svelte';
3
5
  export const ENABLERS = ['svelte'];
4
6
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
@@ -7,3 +9,7 @@ export const PRODUCTION_ENTRY_FILE_PATTERNS = [
7
9
  'src/routes/**/+{page,server,page.server,error,layout,layout.server}{,@*}.{js,ts,svelte}',
8
10
  ];
9
11
  export const PROJECT_FILE_PATTERNS = ['src/**/*.{js,ts,svelte}'];
12
+ const findSvelteDependencies = async () => {
13
+ return [...PRODUCTION_ENTRY_FILE_PATTERNS.map(toProductionEntryPattern), ...ENTRY_FILE_PATTERNS.map(toEntryPattern)];
14
+ };
15
+ export const findDependencies = timerify(findSvelteDependencies);
@@ -1,6 +1,7 @@
1
1
  import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
2
2
  export declare const NAME = "TypeDoc";
3
3
  export declare const ENABLERS: string[];
4
+ export declare const PACKAGE_JSON_PATH = "typedocOptions";
4
5
  export declare const isEnabled: IsPluginEnabledCallback;
5
6
  export declare const CONFIG_FILE_PATTERNS: string[];
6
7
  export declare const findDependencies: GenericPluginCallback;
@@ -2,6 +2,7 @@ import { timerify } from '../../util/Performance.js';
2
2
  import { hasDependency, load } from '../../util/plugin.js';
3
3
  export const NAME = 'TypeDoc';
4
4
  export const ENABLERS = ['typedoc'];
5
+ export const PACKAGE_JSON_PATH = 'typedocOptions';
5
6
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
6
7
  export const CONFIG_FILE_PATTERNS = [
7
8
  'typedoc.{js,cjs,json,jsonc}',
@@ -11,9 +12,11 @@ export const CONFIG_FILE_PATTERNS = [
11
12
  'package.json',
12
13
  'tsconfig.json',
13
14
  ];
14
- const findTypeDocDependencies = async (configFilePath, { manifest }) => {
15
+ const findTypeDocDependencies = async (configFilePath, { manifest, isProduction }) => {
16
+ if (isProduction)
17
+ return [];
15
18
  const config = configFilePath.endsWith('package.json')
16
- ? manifest.typedocOptions
19
+ ? manifest[PACKAGE_JSON_PATH]
17
20
  : configFilePath.endsWith('tsconfig.json')
18
21
  ? (await load(configFilePath)).typedocOptions
19
22
  : await load(configFilePath);
@@ -21,7 +21,9 @@ const resolveExtensibleConfig = async (configFilePath) => {
21
21
  }
22
22
  return config;
23
23
  };
24
- export const findTypeScriptDependencies = async (configFilePath) => {
24
+ export const findTypeScriptDependencies = async (configFilePath, { isProduction }) => {
25
+ if (isProduction)
26
+ return [];
25
27
  const { compilerOptions } = await loadTSConfig(configFilePath);
26
28
  const config = await resolveExtensibleConfig(configFilePath);
27
29
  if (!compilerOptions || !config)
@@ -5,8 +5,8 @@ export const NAME = 'Vite';
5
5
  export const ENABLERS = ['vite'];
6
6
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
7
7
  export const CONFIG_FILE_PATTERNS = ['vite.config.{js,ts}'];
8
- const findViteDependencies = async (configFilePath) => {
8
+ const findViteDependencies = async (configFilePath, options) => {
9
9
  const config = await load(configFilePath);
10
- return findVitestDeps(config);
10
+ return findVitestDeps(config, options);
11
11
  };
12
12
  export const findDependencies = timerify(findViteDependencies);
@@ -1,9 +1,9 @@
1
1
  import type { VitestConfig } from './types.js';
2
- import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
2
+ import type { IsPluginEnabledCallback, GenericPluginCallback, GenericPluginCallbackOptions } from '../../types/plugins.js';
3
3
  export declare const NAME = "Vitest";
4
4
  export declare const ENABLERS: string[];
5
5
  export declare const isEnabled: IsPluginEnabledCallback;
6
6
  export declare const CONFIG_FILE_PATTERNS: string[];
7
- export declare const ENTRY_FILE_PATTERNS: never[];
8
- export declare const findVitestDeps: (config: VitestConfig) => any[];
7
+ export declare const ENTRY_FILE_PATTERNS: string[];
8
+ export declare const findVitestDeps: (config: VitestConfig, options: GenericPluginCallbackOptions) => any[];
9
9
  export declare const findDependencies: GenericPluginCallback;
@@ -1,37 +1,30 @@
1
1
  import { compact } from '../../util/array.js';
2
2
  import { timerify } from '../../util/Performance.js';
3
3
  import { hasDependency, load } from '../../util/plugin.js';
4
+ import { toEntryPattern } from '../../util/protocols.js';
4
5
  import { getEnvPackageName, getExternalReporters } from './helpers.js';
5
6
  export const NAME = 'Vitest';
6
7
  export const ENABLERS = ['vitest'];
7
8
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
8
9
  export const CONFIG_FILE_PATTERNS = ['vitest.config.ts', 'vitest.{workspace,projects}.{ts,js,json}'];
9
- export const ENTRY_FILE_PATTERNS = [];
10
- export const findVitestDeps = (config) => {
10
+ export const ENTRY_FILE_PATTERNS = ['**/*.{test,spec}.?(c|m)[jt]s?(x)'];
11
+ export const findVitestDeps = (config, options) => {
12
+ const { isProduction } = options;
11
13
  if (!config || !config.test)
12
14
  return [];
13
- const cfg = config.test;
14
- const environments = cfg.environment ? [getEnvPackageName(cfg.environment)] : [];
15
- const reporters = getExternalReporters(cfg.reporters);
16
- const coverage = cfg.coverage ? [`@vitest/coverage-${cfg.coverage.provider ?? 'v8'}`] : [];
17
- const setupFiles = cfg.setupFiles ? [cfg.setupFiles].flat() : [];
18
- const globalSetup = cfg.globalSetup ? [cfg.globalSetup].flat() : [];
19
- return compact([...environments, ...reporters, ...coverage, ...setupFiles, ...globalSetup]);
15
+ const testConfig = config.test;
16
+ const entryPatterns = (options.config?.entry ?? testConfig.include ?? ENTRY_FILE_PATTERNS).map(toEntryPattern);
17
+ if (isProduction)
18
+ return entryPatterns;
19
+ const environments = testConfig.environment ? [getEnvPackageName(testConfig.environment)] : [];
20
+ const reporters = getExternalReporters(testConfig.reporters);
21
+ const coverage = testConfig.coverage ? [`@vitest/coverage-${testConfig.coverage.provider ?? 'v8'}`] : [];
22
+ const setupFiles = testConfig.setupFiles ? [testConfig.setupFiles].flat() : [];
23
+ const globalSetup = testConfig.globalSetup ? [testConfig.globalSetup].flat() : [];
24
+ return [...entryPatterns, ...environments, ...reporters, ...coverage, ...setupFiles, ...globalSetup];
20
25
  };
21
- const findVitestWorkspaceDeps = (config) => {
22
- let deps = [];
23
- for (const cfg of config) {
24
- if (typeof cfg === 'string')
25
- continue;
26
- deps = [...deps, ...findVitestDeps(cfg)];
27
- }
28
- return compact(deps);
29
- };
30
- const findVitestDependencies = async (configFilePath) => {
26
+ const findVitestDependencies = async (configFilePath, options) => {
31
27
  const config = await load(configFilePath);
32
- if (Array.isArray(config)) {
33
- return findVitestWorkspaceDeps(config);
34
- }
35
- return findVitestDeps(config);
28
+ return compact([config].flat().flatMap(cfg => (!cfg || typeof cfg === 'string' ? [] : findVitestDeps(cfg, options))));
36
29
  };
37
30
  export const findDependencies = timerify(findVitestDependencies);
@@ -1,5 +1,6 @@
1
1
  export interface VitestConfig {
2
2
  test: {
3
+ include: string[];
3
4
  coverage?: {
4
5
  provider: string;
5
6
  };
@@ -44,10 +44,12 @@ const resolveUseItem = (use) => {
44
44
  return [];
45
45
  };
46
46
  const findWebpackDependencies = async (configFilePath, { manifest, isProduction }) => {
47
+ if (isProduction)
48
+ return [];
47
49
  const config = await load(configFilePath);
48
50
  if (!config)
49
51
  return [];
50
- const passes = typeof config === 'function' ? [false, true] : [isProduction];
52
+ const passes = typeof config === 'function' ? [false, true] : [false];
51
53
  const dependencies = passes.flatMap(isProduction => {
52
54
  const env = { production: isProduction };
53
55
  const argv = { mode: isProduction ? 'production' : 'development' };
@@ -7,11 +7,12 @@ export type RawConfiguration = z.infer<typeof ConfigurationValidator>;
7
7
  export type RawPluginConfiguration = z.infer<typeof pluginSchema>;
8
8
  type NormalizedGlob = string[];
9
9
  export type PluginName = keyof typeof Plugins;
10
- export type PluginConfiguration = {
10
+ export type EnsuredPluginConfiguration = {
11
11
  config: NormalizedGlob | null;
12
12
  entry: NormalizedGlob | null;
13
13
  project: NormalizedGlob | null;
14
- } | boolean;
14
+ };
15
+ export type PluginConfiguration = EnsuredPluginConfiguration | boolean;
15
16
  export type PluginsConfiguration = Record<PluginName, PluginConfiguration>;
16
17
  interface BaseWorkspaceConfiguration {
17
18
  entry: NormalizedGlob;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="npmcli__package-json" />
2
- import type { PluginConfiguration, WorkspaceConfiguration } from './config.js';
2
+ import type { EnsuredPluginConfiguration, WorkspaceConfiguration } from './config.js';
3
3
  import type { PackageJson } from '@npmcli/package-json';
4
4
  export type PackageJsonWithPlugins = PackageJson & Record<string, unknown>;
5
5
  type IsPluginEnabledCallbackOptions = {
@@ -9,10 +9,10 @@ type IsPluginEnabledCallbackOptions = {
9
9
  config: WorkspaceConfiguration;
10
10
  };
11
11
  export type IsPluginEnabledCallback = (options: IsPluginEnabledCallbackOptions) => boolean | Promise<boolean>;
12
- type GenericPluginCallbackOptions = {
12
+ export type GenericPluginCallbackOptions = {
13
13
  cwd: string;
14
14
  manifest: PackageJsonWithPlugins;
15
- config: PluginConfiguration;
15
+ config?: EnsuredPluginConfiguration;
16
16
  isProduction: boolean;
17
17
  };
18
18
  export type GenericPluginCallback = (configFilePath: string, options: GenericPluginCallbackOptions) => Promise<string[]> | string[];