knip 2.33.3 → 2.33.4

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 (77) hide show
  1. package/README.md +2 -0
  2. package/dist/WorkspaceWorker.js +12 -17
  3. package/dist/binaries/bash-parser.js +1 -1
  4. package/dist/index.js +17 -16
  5. package/dist/plugins/_template/index.js +14 -3
  6. package/dist/plugins/_template/types.d.ts +1 -0
  7. package/dist/plugins/angular/index.js +11 -11
  8. package/dist/plugins/ava/index.js +13 -12
  9. package/dist/plugins/babel/index.js +8 -5
  10. package/dist/plugins/capacitor/index.js +4 -2
  11. package/dist/plugins/changesets/index.js +7 -5
  12. package/dist/plugins/commitizen/index.js +4 -3
  13. package/dist/plugins/commitizen/types.d.ts +1 -1
  14. package/dist/plugins/commitlint/index.js +4 -2
  15. package/dist/plugins/cspell/index.js +4 -2
  16. package/dist/plugins/cspell/types.d.ts +1 -1
  17. package/dist/plugins/cypress/index.js +7 -4
  18. package/dist/plugins/drizzle/index.js +4 -4
  19. package/dist/plugins/eslint/fallback.js +6 -1
  20. package/dist/plugins/eslint/helpers.d.ts +2 -2
  21. package/dist/plugins/eslint/helpers.js +7 -7
  22. package/dist/plugins/eslint/index.d.ts +0 -1
  23. package/dist/plugins/eslint/index.js +3 -4
  24. package/dist/plugins/gatsby/index.js +5 -8
  25. package/dist/plugins/github-actions/index.d.ts +1 -1
  26. package/dist/plugins/github-actions/index.js +5 -4
  27. package/dist/plugins/husky/index.js +4 -2
  28. package/dist/plugins/jest/index.js +8 -8
  29. package/dist/plugins/jest/types.d.ts +3 -0
  30. package/dist/plugins/jest/types.js +1 -0
  31. package/dist/plugins/lefthook/index.js +5 -4
  32. package/dist/plugins/lint-staged/index.js +7 -7
  33. package/dist/plugins/markdownlint/index.js +5 -4
  34. package/dist/plugins/mocha/index.js +8 -7
  35. package/dist/plugins/mocha/types.d.ts +4 -0
  36. package/dist/plugins/mocha/types.js +1 -0
  37. package/dist/plugins/npm-package-json-lint/index.js +4 -3
  38. package/dist/plugins/nx/index.js +5 -4
  39. package/dist/plugins/nyc/index.js +4 -3
  40. package/dist/plugins/nyc/types.d.ts +3 -0
  41. package/dist/plugins/nyc/types.js +1 -0
  42. package/dist/plugins/playwright/index.d.ts +1 -1
  43. package/dist/plugins/playwright/index.js +7 -6
  44. package/dist/plugins/playwright-ct/index.js +11 -6
  45. package/dist/plugins/postcss/index.js +6 -5
  46. package/dist/plugins/prettier/index.js +3 -3
  47. package/dist/plugins/prettier/types.d.ts +8 -0
  48. package/dist/plugins/prettier/types.js +1 -0
  49. package/dist/plugins/release-it/index.js +10 -9
  50. package/dist/plugins/remark/index.js +6 -5
  51. package/dist/plugins/remix/index.js +1 -5
  52. package/dist/plugins/rollup/index.js +1 -1
  53. package/dist/plugins/semantic-release/index.js +5 -4
  54. package/dist/plugins/semantic-release/types.d.ts +1 -1
  55. package/dist/plugins/storybook/index.js +13 -11
  56. package/dist/plugins/stryker/index.js +9 -6
  57. package/dist/plugins/stylelint/index.js +6 -5
  58. package/dist/plugins/typedoc/index.js +4 -3
  59. package/dist/plugins/typedoc/types.d.ts +1 -1
  60. package/dist/plugins/typescript/index.js +13 -10
  61. package/dist/plugins/vite/index.js +4 -2
  62. package/dist/plugins/vitest/index.d.ts +1 -1
  63. package/dist/plugins/vitest/index.js +8 -8
  64. package/dist/plugins/webpack/index.js +25 -15
  65. package/dist/plugins/webpack/types.d.ts +2 -1
  66. package/dist/types/config.d.ts +1 -1
  67. package/dist/types/plugins.d.ts +1 -1
  68. package/dist/typescript/SourceFileManager.js +3 -3
  69. package/dist/util/debug.d.ts +3 -3
  70. package/dist/util/debug.js +10 -8
  71. package/dist/util/glob.js +1 -1
  72. package/dist/util/path.js +1 -1
  73. package/dist/util/plugin.js +7 -1
  74. package/dist/util/require.js +1 -1
  75. package/dist/version.d.ts +1 -1
  76. package/dist/version.js +1 -1
  77. package/package.json +1 -1
@@ -4,10 +4,11 @@ import { getValuesByKeyDeep } from '../../util/object.js';
4
4
  import { timerify } from '../../util/Performance.js';
5
5
  import { load } from '../../util/plugin.js';
6
6
  export const NAME = 'GitHub Actions';
7
- export const ENABLERS = 'This plugin is enabled when a `.yml` file is found in the `.github/workflows` folder.';
8
- export const isEnabled = async ({ cwd }) => Boolean(await _firstGlob({ cwd, patterns: ['.github/workflows/*.yml'] }));
9
- export const CONFIG_FILE_PATTERNS = ['.github/workflows/*.yml', '.github/**/action.{yml,yaml}'];
10
- const findGithubActionsDependencies = async (configFilePath, { cwd, manifest, isProduction }) => {
7
+ export const ENABLERS = 'This plugin is enabled when a `.yml` or `.yaml` file is found in the `.github/workflows` folder.';
8
+ export const isEnabled = async ({ cwd }) => Boolean(await _firstGlob({ cwd, patterns: ['.github/workflows/*.{yml,yaml}'] }));
9
+ export const CONFIG_FILE_PATTERNS = ['.github/workflows/*.{yml,yaml}', '.github/**/action.{yml,yaml}'];
10
+ const findGithubActionsDependencies = async (configFilePath, options) => {
11
+ const { cwd, manifest, isProduction } = options;
11
12
  if (isProduction)
12
13
  return [];
13
14
  const config = await load(configFilePath);
@@ -1,6 +1,7 @@
1
1
  import { readFileSync } from 'fs';
2
2
  import { _getDependenciesFromScripts } from '../../binaries/index.js';
3
3
  import { getGitHookPaths } from '../../util/git.js';
4
+ import { FAKE_PATH } from '../../util/loader.js';
4
5
  import { timerify } from '../../util/Performance.js';
5
6
  import { hasDependency } from '../../util/plugin.js';
6
7
  export const NAME = 'husky';
@@ -8,8 +9,9 @@ export const ENABLERS = ['husky'];
8
9
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
9
10
  const gitHookPaths = getGitHookPaths('.husky');
10
11
  export const CONFIG_FILE_PATTERNS = [...gitHookPaths];
11
- const findHuskyDependencies = async (configFilePath, { cwd, manifest, isProduction }) => {
12
- if (isProduction)
12
+ const findHuskyDependencies = async (configFilePath, options) => {
13
+ const { cwd, manifest, isProduction } = options;
14
+ if (isProduction || configFilePath === FAKE_PATH)
13
15
  return [];
14
16
  const script = readFileSync(configFilePath);
15
17
  return _getDependenciesFromScripts(String(script), {
@@ -21,7 +21,7 @@ const resolveExtensibleConfig = async (configFilePath) => {
21
21
  };
22
22
  const resolveDependencies = (config, options) => {
23
23
  const { isProduction } = options;
24
- const entryPatterns = (config.testMatch ?? ENTRY_FILE_PATTERNS).map(toEntryPattern);
24
+ const entryPatterns = (options.config?.entry ?? config.testMatch ?? ENTRY_FILE_PATTERNS).map(toEntryPattern);
25
25
  if (isProduction)
26
26
  return entryPatterns;
27
27
  const presets = (config.preset ? [config.preset] : []).map(preset => isInternal(preset) ? preset : join(preset, 'jest-preset'));
@@ -64,16 +64,16 @@ const resolveDependencies = (config, options) => {
64
64
  };
65
65
  const findJestDependencies = async (configFilePath, options) => {
66
66
  const { manifest, cwd } = options;
67
- let config = configFilePath.endsWith('package.json')
67
+ let localConfig = configFilePath.endsWith('package.json')
68
68
  ? manifest.jest
69
69
  : await resolveExtensibleConfig(configFilePath);
70
- if (typeof config === 'function')
71
- config = await config();
72
- if (!config)
73
- return [];
74
- const rootDir = config.rootDir ? join(dirname(configFilePath), config.rootDir) : dirname(configFilePath);
70
+ if (typeof localConfig === 'function')
71
+ localConfig = await localConfig();
72
+ if (!localConfig)
73
+ localConfig = {};
74
+ const rootDir = localConfig.rootDir ? join(dirname(configFilePath), localConfig.rootDir) : dirname(configFilePath);
75
75
  const replaceRootDir = (name) => (name.includes('<rootDir>') ? name.replace(/<rootDir>/, rootDir) : name);
76
- const dependencies = resolveDependencies(config, options);
76
+ const dependencies = resolveDependencies(localConfig, options);
77
77
  const matchCwd = new RegExp('^' + toEntryPattern(cwd) + '/');
78
78
  return dependencies.map(replaceRootDir).map(dependency => dependency.replace(matchCwd, toEntryPattern('')));
79
79
  };
@@ -0,0 +1,3 @@
1
+ import type { Config } from '@jest/types';
2
+ export type JestInitialOptions = Config.InitialOptions;
3
+ export type JestConfig = JestInitialOptions | (() => JestInitialOptions) | (() => Promise<JestInitialOptions>);
@@ -0,0 +1 @@
1
+ export {};
@@ -10,15 +10,16 @@ export const ENABLERS = ['lefthook', '@arkweid/lefthook', '@evilmartians/lefthoo
10
10
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
11
11
  const gitHookPaths = getGitHookPaths();
12
12
  export const CONFIG_FILE_PATTERNS = ['lefthook.yml', ...gitHookPaths];
13
- const findLefthookDependencies = async (configFilePath, { cwd, manifest, isProduction }) => {
13
+ const findLefthookDependencies = async (configFilePath, options) => {
14
+ const { cwd, manifest, isProduction } = options;
14
15
  if (isProduction)
15
16
  return [];
16
17
  const dependencies = manifest.devDependencies ? Object.keys(manifest.devDependencies) : [];
17
18
  if (configFilePath.endsWith('.yml')) {
18
- const config = await load(configFilePath);
19
- if (!config)
19
+ const localConfig = await load(configFilePath);
20
+ if (!localConfig)
20
21
  return [];
21
- const scripts = getValuesByKeyDeep(config, 'run').filter((value) => typeof value === 'string');
22
+ const scripts = getValuesByKeyDeep(localConfig, 'run').filter((run) => typeof run === 'string');
22
23
  const lefthook = process.env.CI ? ENABLERS.filter(dependency => dependencies.includes(dependency)) : [];
23
24
  return [...lefthook, ..._getDependenciesFromScripts(scripts, { cwd, manifest, knownGlobalsOnly: true })];
24
25
  }
@@ -13,19 +13,19 @@ export const CONFIG_FILE_PATTERNS = [
13
13
  'lint-staged.config.{js,mjs,cjs}',
14
14
  'package.json',
15
15
  ];
16
- const findLintStagedDependencies = async (configFilePath, { cwd, manifest, isProduction }) => {
16
+ const findLintStagedDependencies = async (configFilePath, options) => {
17
+ const { cwd, manifest, isProduction } = options;
17
18
  if (isProduction)
18
19
  return [];
19
- let config = configFilePath.endsWith('package.json')
20
+ let localConfig = configFilePath.endsWith('package.json')
20
21
  ? manifest['lint-staged']
21
22
  : await load(configFilePath);
22
- if (!config)
23
+ if (typeof localConfig === 'function')
24
+ localConfig = localConfig();
25
+ if (!localConfig)
23
26
  return [];
24
- if (typeof config === 'function') {
25
- config = config();
26
- }
27
27
  const dependencies = new Set();
28
- for (const entry of Object.values(config).flat()) {
28
+ for (const entry of Object.values(localConfig).flat()) {
29
29
  const scripts = [typeof entry === 'function' ? await entry([]) : entry].flat();
30
30
  const options = { cwd, manifest };
31
31
  _getDependenciesFromScripts(scripts, options).forEach(identifier => dependencies.add(identifier));
@@ -5,12 +5,13 @@ export const NAME = 'markdownlint';
5
5
  export const ENABLERS = ['markdownlint-cli'];
6
6
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
7
7
  export const CONFIG_FILE_PATTERNS = ['.markdownlint.{json,jsonc}', '.markdownlint.{yml,yaml}'];
8
- const findMarkdownlintConfigDependencies = async (configFilePath, { manifest, isProduction }) => {
8
+ const findMarkdownlintConfigDependencies = async (configFilePath, options) => {
9
+ const { manifest, isProduction } = options;
9
10
  if (isProduction)
10
11
  return [];
11
- const config = await load(configFilePath);
12
- const extend = config?.extends ? [config.extends] : [];
13
- const scripts = manifest.scripts
12
+ const localConfig = await load(configFilePath);
13
+ const extend = localConfig?.extends ? [localConfig.extends] : [];
14
+ const scripts = manifest?.scripts
14
15
  ? Object.values(manifest.scripts).filter((script) => typeof script === 'string')
15
16
  : [];
16
17
  const uses = scripts
@@ -6,14 +6,15 @@ export const ENABLERS = ['mocha'];
6
6
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
7
7
  export const CONFIG_FILE_PATTERNS = ['.mocharc.{js,cjs,json,jsonc,yml,yaml}', 'package.json'];
8
8
  export const ENTRY_FILE_PATTERNS = ['**/test/*.{js,cjs,mjs}'];
9
- const findMochaDependencies = async (configFilePath, { manifest, isProduction }) => {
10
- const entryPatterns = ENTRY_FILE_PATTERNS.map(toEntryPattern);
11
- if (isProduction)
9
+ const findMochaDependencies = async (configFilePath, options) => {
10
+ const { config, manifest, isProduction } = options;
11
+ const localConfig = configFilePath.endsWith('package.json')
12
+ ? manifest.mocha
13
+ : await load(configFilePath);
14
+ const entryPatterns = (config.entry ?? (localConfig?.spec ? [localConfig.spec].flat() : ENTRY_FILE_PATTERNS)).map(toEntryPattern);
15
+ if (isProduction || !localConfig)
12
16
  return entryPatterns;
13
- const config = configFilePath.endsWith('package.json') ? manifest.mocha : await load(configFilePath);
14
- if (!config)
15
- return [];
16
- const require = config.require ? [config.require].flat() : [];
17
+ const require = localConfig.require ? [localConfig.require].flat() : [];
17
18
  return [...require, ...entryPatterns];
18
19
  };
19
20
  export const findDependencies = timerify(findMochaDependencies);
@@ -0,0 +1,4 @@
1
+ export interface MochaConfig {
2
+ require?: string | string[];
3
+ spec?: string | string[];
4
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -5,12 +5,13 @@ export const ENABLERS = ['npm-package-json-lint'];
5
5
  export const PACKAGE_JSON_PATH = 'npmpackagejsonlint';
6
6
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
7
7
  export const CONFIG_FILE_PATTERNS = ['.npmpackagejsonlintrc.json', 'npmpackagejsonlint.config.js', 'package.json'];
8
- const findNpmPkgJsonLintConfigDependencies = async (configFilePath, { manifest, isProduction }) => {
8
+ const findNpmPkgJsonLintConfigDependencies = async (configFilePath, options) => {
9
+ const { manifest, isProduction } = options;
9
10
  if (isProduction)
10
11
  return [];
11
- const config = configFilePath.endsWith('package.json')
12
+ const localConfig = configFilePath.endsWith('package.json')
12
13
  ? manifest[PACKAGE_JSON_PATH]
13
14
  : await load(configFilePath);
14
- return config?.extends ? [config.extends] : [];
15
+ return localConfig?.extends ? [localConfig.extends] : [];
15
16
  };
16
17
  export const findDependencies = timerify(findNpmPkgJsonLintConfigDependencies);
@@ -6,13 +6,14 @@ 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, isProduction }) => {
9
+ const findNxDependencies = async (configFilePath, options) => {
10
+ const { cwd, manifest, isProduction } = options;
10
11
  if (isProduction)
11
12
  return [];
12
- const config = await load(configFilePath);
13
- if (!config)
13
+ const localConfig = await load(configFilePath);
14
+ if (!localConfig)
14
15
  return [];
15
- const targets = config.targets ? Object.values(config.targets) : [];
16
+ const targets = localConfig.targets ? Object.values(localConfig.targets) : [];
16
17
  const executors = compact(targets
17
18
  .map(target => target?.executor)
18
19
  .filter(executor => executor && !executor.startsWith('.'))
@@ -4,10 +4,11 @@ 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, { isProduction }) => {
7
+ const findNycDependencies = async (configFilePath, options) => {
8
+ const { isProduction } = options;
8
9
  if (isProduction)
9
10
  return [];
10
- const config = await load(configFilePath);
11
- return config.extends ? [config.extends].flat() : [];
11
+ const localConfig = await load(configFilePath);
12
+ return localConfig?.extends ? [localConfig.extends].flat() : [];
12
13
  };
13
14
  export const findDependencies = timerify(findNycDependencies);
@@ -0,0 +1,3 @@
1
+ export type NycConfig = {
2
+ extends?: string;
3
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -3,7 +3,7 @@ import type { PlaywrightTestConfig } from 'playwright/test';
3
3
  export declare const NAME = "Playwright";
4
4
  export declare const ENABLERS: string[];
5
5
  export declare const isEnabled: IsPluginEnabledCallback;
6
- export declare const ENTRY_FILE_PATTERNS: string[];
7
6
  export declare const CONFIG_FILE_PATTERNS: string[];
7
+ export declare const ENTRY_FILE_PATTERNS: string[];
8
8
  export declare const toEntryPatterns: (testMatch: string | RegExp | Array<string | RegExp> | undefined, cwd: string, configFilePath: string, config: PlaywrightTestConfig) => string[];
9
9
  export declare const findDependencies: GenericPluginCallback;
@@ -5,8 +5,8 @@ import { toEntryPattern } from '../../util/protocols.js';
5
5
  export const NAME = 'Playwright';
6
6
  export const ENABLERS = ['@playwright/test'];
7
7
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
8
- export const ENTRY_FILE_PATTERNS = ['**/*.@(spec|test).?(c|m)[jt]s?(x)'];
9
8
  export const CONFIG_FILE_PATTERNS = ['playwright.config.{js,ts}'];
9
+ export const ENTRY_FILE_PATTERNS = ['**/*.@(spec|test).?(c|m)[jt]s?(x)'];
10
10
  export const toEntryPatterns = (testMatch, cwd, configFilePath, config) => {
11
11
  if (!testMatch)
12
12
  return [];
@@ -14,14 +14,15 @@ export const toEntryPatterns = (testMatch, cwd, configFilePath, config) => {
14
14
  const patterns = [testMatch].flat().filter((p) => typeof p === 'string');
15
15
  return patterns.map(pattern => toEntryPattern(join(dir, pattern)));
16
16
  };
17
- const findPlaywrightDependencies = async (configFilePath, { cwd, config }) => {
18
- const cfg = await load(configFilePath);
19
- if (cfg) {
20
- const projects = cfg.projects ? [cfg, ...cfg.projects] : [cfg];
17
+ const findPlaywrightDependencies = async (configFilePath, options) => {
18
+ const { cwd, config } = options;
19
+ const localConfig = await load(configFilePath);
20
+ if (localConfig) {
21
+ const projects = localConfig.projects ? [localConfig, ...localConfig.projects] : [localConfig];
21
22
  const patterns = projects.flatMap(config => toEntryPatterns(config.testMatch, cwd, configFilePath, config));
22
23
  if (patterns.length > 0)
23
24
  return patterns;
24
25
  }
25
- return toEntryPatterns(config?.entry ?? ENTRY_FILE_PATTERNS, cwd, configFilePath, cfg ?? {});
26
+ return (config?.entry ?? ENTRY_FILE_PATTERNS).map(toEntryPattern);
26
27
  };
27
28
  export const findDependencies = timerify(findPlaywrightDependencies);
@@ -1,16 +1,21 @@
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
  import { toEntryPatterns } from '../playwright/index.js';
4
5
  export const NAME = 'Playwright for components';
5
6
  export const ENABLERS = [/^@playwright\/experimental-ct-/];
6
7
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
7
8
  export const CONFIG_FILE_PATTERNS = ['playwright-ct.config.{js,ts}', 'playwright/index.{js,ts,jsx,tsx}'];
8
9
  export const ENTRY_FILE_PATTERNS = ['**/*.@(spec|test).?(c|m)[jt]s?(x)'];
9
- const findPlaywrightCTDependencies = async (configFilePath, { cwd }) => {
10
- const config = await load(configFilePath);
11
- const entryPatterns = toEntryPatterns(config.testMatch, cwd, configFilePath, config);
12
- if (entryPatterns.length > 0)
13
- return entryPatterns;
14
- return toEntryPatterns(ENTRY_FILE_PATTERNS, cwd, configFilePath, config);
10
+ const findPlaywrightCTDependencies = async (configFilePath, options) => {
11
+ const { cwd, config } = options;
12
+ const localConfig = await load(configFilePath);
13
+ if (localConfig) {
14
+ const projects = localConfig.projects ? [localConfig, ...localConfig.projects] : [localConfig];
15
+ const patterns = projects.flatMap(config => toEntryPatterns(config.testMatch, cwd, configFilePath, config));
16
+ if (patterns.length > 0)
17
+ return patterns;
18
+ }
19
+ return (config?.entry ?? ENTRY_FILE_PATTERNS).map(toEntryPattern);
15
20
  };
16
21
  export const findDependencies = timerify(findPlaywrightCTDependencies);
@@ -4,16 +4,17 @@ 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, isProduction }) => {
7
+ const findPostCSSDependencies = async (configFilePath, options) => {
8
+ const { manifest, isProduction } = options;
8
9
  if (isProduction)
9
10
  return [];
10
- const config = configFilePath.endsWith('package.json')
11
+ const localConfig = configFilePath.endsWith('package.json')
11
12
  ? manifest?.postcss
12
13
  : await load(configFilePath);
13
- if (!config)
14
+ if (!localConfig)
14
15
  return [];
15
- return config.plugins
16
- ? (Array.isArray(config.plugins) ? config.plugins : Object.keys(config.plugins)).flatMap(plugin => {
16
+ return localConfig.plugins
17
+ ? (Array.isArray(localConfig.plugins) ? localConfig.plugins : Object.keys(localConfig.plugins)).flatMap(plugin => {
17
18
  if (typeof plugin === 'string')
18
19
  return plugin;
19
20
  if (Array.isArray(plugin) && typeof plugin[0] === 'string')
@@ -12,11 +12,11 @@ export const CONFIG_FILE_PATTERNS = [
12
12
  const findPrettierDependencies = async (configFilePath, { manifest, isProduction }) => {
13
13
  if (isProduction)
14
14
  return [];
15
- const config = configFilePath.endsWith('package.json')
15
+ const localConfig = configFilePath.endsWith('package.json')
16
16
  ? manifest.prettier
17
17
  : await load(configFilePath);
18
- return config && Array.isArray(config.plugins)
19
- ? config.plugins.filter((plugin) => typeof plugin === 'string')
18
+ return localConfig && Array.isArray(localConfig.plugins)
19
+ ? localConfig.plugins.filter((plugin) => typeof plugin === 'string')
20
20
  : [];
21
21
  };
22
22
  export const findDependencies = timerify(findPrettierDependencies);
@@ -0,0 +1,8 @@
1
+ export type PrettierConfig = {
2
+ plugins?: (string | {
3
+ parsers?: Record<string, unknown>;
4
+ printers?: Record<string, unknown>;
5
+ languages?: unknown[];
6
+ options?: Record<string, unknown>;
7
+ })[];
8
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -11,21 +11,22 @@ export const CONFIG_FILE_PATTERNS = [
11
11
  '.release-it.{yml,yaml}',
12
12
  'package.json',
13
13
  ];
14
- const findReleaseItDependencies = async (configFilePath, { cwd, manifest, isProduction }) => {
14
+ const findReleaseItDependencies = async (configFilePath, options) => {
15
+ const { cwd, manifest, isProduction } = options;
15
16
  if (isProduction)
16
17
  return [];
17
- const config = configFilePath.endsWith('package.json')
18
+ const localConfig = configFilePath.endsWith('package.json')
18
19
  ? manifest[PACKAGE_JSON_PATH]
19
20
  : await load(configFilePath);
20
- if (!config)
21
+ if (!localConfig)
21
22
  return [];
22
- const plugins = config.plugins ? Object.keys(config.plugins) : [];
23
- const scripts = config.hooks ? Object.values(config.hooks).flat() : [];
24
- if (typeof config.github?.releaseNotes === 'string') {
25
- scripts.push(config.github.releaseNotes);
23
+ const plugins = localConfig.plugins ? Object.keys(localConfig.plugins) : [];
24
+ const scripts = localConfig.hooks ? Object.values(localConfig.hooks).flat() : [];
25
+ if (typeof localConfig.github?.releaseNotes === 'string') {
26
+ scripts.push(localConfig.github.releaseNotes);
26
27
  }
27
- if (typeof config.gitlab?.releaseNotes === 'string') {
28
- scripts.push(config.gitlab.releaseNotes);
28
+ if (typeof localConfig.gitlab?.releaseNotes === 'string') {
29
+ scripts.push(localConfig.gitlab.releaseNotes);
29
30
  }
30
31
  const dependencies = _getDependenciesFromScripts(scripts, { cwd, manifest });
31
32
  return [...plugins, ...dependencies];
@@ -11,15 +11,16 @@ export const CONFIG_FILE_PATTERNS = [
11
11
  '.remarkrc.{js,cjs,mjs}',
12
12
  '.remarkrc.{yml,yaml}',
13
13
  ];
14
- const findRemarkDependencies = async (configFilePath, { manifest, isProduction }) => {
14
+ const findRemarkDependencies = async (configFilePath, options) => {
15
+ const { manifest, isProduction } = options;
15
16
  if (isProduction)
16
17
  return [];
17
- const config = configFilePath.endsWith('package.json')
18
+ const localConfig = configFilePath.endsWith('package.json')
18
19
  ? manifest[PACKAGE_JSON_PATH]
19
20
  : await load(configFilePath);
20
- if (!config)
21
+ if (!localConfig)
21
22
  return [];
22
- const plugins = config.plugins?.map(plugin => `remark-${plugin}`) ?? [];
23
- return [...plugins];
23
+ const plugins = localConfig.plugins?.map(plugin => `remark-${plugin}`) ?? [];
24
+ return plugins;
24
25
  };
25
26
  export const findDependencies = timerify(findRemarkDependencies);
@@ -12,10 +12,6 @@ export const PRODUCTION_ENTRY_FILE_PATTERNS = [
12
12
  'server.{js,ts}',
13
13
  ];
14
14
  const findRemixDependencies = async () => {
15
- const entryPatterns = [
16
- ...ENTRY_FILE_PATTERNS.map(toEntryPattern),
17
- ...PRODUCTION_ENTRY_FILE_PATTERNS.map(toProductionEntryPattern),
18
- ];
19
- return entryPatterns;
15
+ return [...ENTRY_FILE_PATTERNS.map(toEntryPattern), ...PRODUCTION_ENTRY_FILE_PATTERNS.map(toProductionEntryPattern)];
20
16
  };
21
17
  export const findDependencies = timerify(findRemixDependencies);
@@ -4,7 +4,7 @@ import { toEntryPattern } from '../../util/protocols.js';
4
4
  export const NAME = 'Rollup';
5
5
  export const ENABLERS = ['rollup'];
6
6
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
7
- export const ENTRY_FILE_PATTERNS = ['rollup.config.{js,mjs,ts}'];
7
+ export const ENTRY_FILE_PATTERNS = ['rollup.config.{js,cjs,mjs,ts}'];
8
8
  const findRollupDependencies = async () => {
9
9
  const entryPatterns = ENTRY_FILE_PATTERNS.map(toEntryPattern);
10
10
  return entryPatterns;
@@ -10,13 +10,14 @@ export const CONFIG_FILE_PATTERNS = [
10
10
  'release.config.{js,cjs}',
11
11
  'package.json',
12
12
  ];
13
- const findSemanticReleaseDependencies = async (configFilePath, { manifest, isProduction }) => {
13
+ const findSemanticReleaseDependencies = async (configFilePath, options) => {
14
+ const { manifest, isProduction } = options;
14
15
  if (isProduction)
15
16
  return [];
16
- const config = configFilePath.endsWith('package.json')
17
+ const localConfig = configFilePath.endsWith('package.json')
17
18
  ? manifest[PACKAGE_JSON_PATH]
18
19
  : await load(configFilePath);
19
- const plugins = config?.plugins ?? [];
20
- return plugins.map(plugin => (Array.isArray(plugin) ? plugin[0] : plugin));
20
+ const plugins = (localConfig?.plugins ?? []).map(plugin => (Array.isArray(plugin) ? plugin[0] : plugin));
21
+ return plugins;
21
22
  };
22
23
  export const findDependencies = timerify(findSemanticReleaseDependencies);
@@ -1,3 +1,3 @@
1
- export type PluginConfig = {
1
+ export type SemanticReleaseConfig = {
2
2
  plugins?: (string | [string, Record<string, unknown>])[];
3
3
  };
@@ -9,19 +9,21 @@ export const CONFIG_FILE_PATTERNS = ['.storybook/{main,test-runner}.{js,ts}'];
9
9
  export const STORIES_FILE_PATTERNS = ['**/*.stories.{js,jsx,ts,tsx}'];
10
10
  export const ENTRY_FILE_PATTERNS = ['.storybook/{manager,preview}.{js,jsx,ts,tsx}', ...STORIES_FILE_PATTERNS];
11
11
  export const PROJECT_FILE_PATTERNS = ['.storybook/**/*.{js,jsx,ts,tsx}'];
12
- const findStorybookDependencies = async (configFilePath, { isProduction, config }) => {
13
- const cfg = await load(configFilePath);
14
- const stories = (typeof cfg.stories === 'function' ? await cfg.stories(STORIES_FILE_PATTERNS) : cfg.stories)?.map(pattern => relative(join(dirname(configFilePath), pattern)));
15
- const cfgPatterns = [...(config?.entry ?? []), ...(stories ?? [])];
16
- const entryPatterns = (cfgPatterns.length > 0 ? cfgPatterns : ENTRY_FILE_PATTERNS).map(toEntryPattern);
17
- if (isProduction)
12
+ const findStorybookDependencies = async (configFilePath, options) => {
13
+ const { isProduction, cwd, config } = options;
14
+ const localConfig = await load(configFilePath);
15
+ const stories = typeof localConfig?.stories === 'function'
16
+ ? await localConfig.stories(STORIES_FILE_PATTERNS)
17
+ : localConfig?.stories;
18
+ const relativePatterns = stories?.map(pattern => relative(cwd, join(dirname(configFilePath), pattern)));
19
+ const patterns = [...(config?.entry ?? []), ...(relativePatterns ?? [])];
20
+ const entryPatterns = (patterns.length > 0 ? patterns : ENTRY_FILE_PATTERNS).map(toEntryPattern);
21
+ if (!localConfig || isProduction)
18
22
  return entryPatterns;
19
- if (!cfg)
20
- return [];
21
- const addons = cfg.addons?.map(addon => (typeof addon === 'string' ? addon : addon.name)) ?? [];
22
- const builder = cfg?.core?.builder;
23
+ const addons = localConfig.addons?.map(addon => (typeof addon === 'string' ? addon : addon.name)) ?? [];
24
+ const builder = localConfig?.core?.builder;
23
25
  const builderPackages = builder && /webpack/.test(builder) ? [`@storybook/builder-${builder}`, `@storybook/manager-${builder}`] : [];
24
- const frameworks = cfg.framework?.name ? [cfg.framework.name] : [];
26
+ const frameworks = localConfig.framework?.name ? [localConfig.framework.name] : [];
25
27
  return [...entryPatterns, ...addons, ...builderPackages, ...frameworks];
26
28
  };
27
29
  export const findDependencies = timerify(findStorybookDependencies);
@@ -4,15 +4,18 @@ 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, { isProduction }) => {
7
+ const findStrykerDependencies = async (configFilePath, options) => {
8
+ const { isProduction } = options;
8
9
  if (isProduction)
9
10
  return [];
10
- const config = await load(configFilePath);
11
- if (!config)
11
+ const localConfig = await load(configFilePath);
12
+ if (!localConfig)
12
13
  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 ?? [];
14
+ const runners = localConfig.testRunner ? [`@stryker-mutator/${localConfig.testRunner}-runner`] : [];
15
+ const checkers = localConfig.checkers
16
+ ? localConfig.checkers.map(checker => `@stryker-mutator/${checker}-checker`)
17
+ : [];
18
+ const plugins = localConfig.plugins ?? [];
16
19
  return [...runners, ...checkers, ...plugins];
17
20
  };
18
21
  export const findDependencies = timerify(findStrykerDependencies);
@@ -9,16 +9,17 @@ 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, isProduction }) => {
12
+ const findPluginDependencies = async (configFilePath, options) => {
13
+ const { manifest, isProduction } = options;
13
14
  if (isProduction)
14
15
  return [];
15
- const config = configFilePath.endsWith('package.json')
16
+ const localConfig = configFilePath.endsWith('package.json')
16
17
  ? manifest.stylelint
17
18
  : await load(configFilePath);
18
- if (!config)
19
+ if (!localConfig)
19
20
  return [];
20
- const extend = config.extends ? [config.extends].flat().filter(extend => !isInternal(extend)) : [];
21
- const plugins = config.plugins ? [config.plugins].flat().filter(plugin => !isInternal(plugin)) : [];
21
+ const extend = localConfig.extends ? [localConfig.extends].flat().filter(extend => !isInternal(extend)) : [];
22
+ const plugins = localConfig.plugins ? [localConfig.plugins].flat().filter(plugin => !isInternal(plugin)) : [];
22
23
  return [...extend, ...plugins];
23
24
  };
24
25
  export const findDependencies = timerify(findPluginDependencies);
@@ -12,14 +12,15 @@ export const CONFIG_FILE_PATTERNS = [
12
12
  'package.json',
13
13
  'tsconfig.json',
14
14
  ];
15
- const findTypeDocDependencies = async (configFilePath, { manifest, isProduction }) => {
15
+ const findTypeDocDependencies = async (configFilePath, options) => {
16
+ const { manifest, isProduction } = options;
16
17
  if (isProduction)
17
18
  return [];
18
- const config = configFilePath.endsWith('package.json')
19
+ const localConfig = configFilePath.endsWith('package.json')
19
20
  ? manifest[PACKAGE_JSON_PATH]
20
21
  : configFilePath.endsWith('tsconfig.json')
21
22
  ? (await load(configFilePath)).typedocOptions
22
23
  : await load(configFilePath);
23
- return config?.plugin ?? [];
24
+ return localConfig?.plugin ?? [];
24
25
  };
25
26
  export const findDependencies = timerify(findTypeDocDependencies);
@@ -1,3 +1,3 @@
1
- export type PluginConfig = {
1
+ export type TypeDocConfig = {
2
2
  plugin?: string[];
3
3
  };