knip 5.1.2 → 5.1.3

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 (179) hide show
  1. package/dist/ConfigurationChief.d.ts +3 -3
  2. package/dist/ConfigurationValidator.d.ts +21 -21
  3. package/dist/ProjectPrincipal.d.ts +1 -1
  4. package/dist/ProjectPrincipal.js +3 -5
  5. package/dist/WorkspaceWorker.d.ts +2 -2
  6. package/dist/WorkspaceWorker.js +61 -44
  7. package/dist/binaries/index.js +2 -2
  8. package/dist/binaries/resolvers/index.d.ts +12 -12
  9. package/dist/compilers/index.d.ts +6 -7
  10. package/dist/compilers/index.js +0 -3
  11. package/dist/constants.d.ts +1 -2
  12. package/dist/constants.js +8 -4
  13. package/dist/plugins/_template/index.d.ts +10 -9
  14. package/dist/plugins/_template/index.js +16 -30
  15. package/dist/plugins/angular/index.d.ts +8 -6
  16. package/dist/plugins/angular/index.js +17 -22
  17. package/dist/plugins/astro/index.d.ts +7 -7
  18. package/dist/plugins/astro/index.js +14 -17
  19. package/dist/plugins/ava/index.d.ts +9 -7
  20. package/dist/plugins/ava/index.js +19 -21
  21. package/dist/plugins/babel/helpers.js +1 -1
  22. package/dist/plugins/babel/index.d.ts +7 -7
  23. package/dist/plugins/babel/index.js +15 -26
  24. package/dist/plugins/capacitor/index.d.ts +7 -6
  25. package/dist/plugins/capacitor/index.js +11 -18
  26. package/dist/plugins/changesets/index.d.ts +7 -6
  27. package/dist/plugins/changesets/index.js +14 -21
  28. package/dist/plugins/changesets/types.d.ts +3 -0
  29. package/dist/plugins/changesets/types.js +1 -0
  30. package/dist/plugins/commitizen/index.d.ts +8 -7
  31. package/dist/plugins/commitizen/index.js +13 -21
  32. package/dist/plugins/commitlint/index.d.ts +9 -6
  33. package/dist/plugins/commitlint/index.js +11 -19
  34. package/dist/plugins/cspell/index.d.ts +7 -6
  35. package/dist/plugins/cspell/index.js +12 -20
  36. package/dist/plugins/cypress/index.d.ts +7 -7
  37. package/dist/plugins/cypress/index.js +13 -21
  38. package/dist/plugins/drizzle/index.d.ts +7 -6
  39. package/dist/plugins/drizzle/index.js +13 -16
  40. package/dist/plugins/eleventy/index.d.ts +11 -9
  41. package/dist/plugins/eleventy/index.js +35 -41
  42. package/dist/plugins/eslint/helpers.d.ts +3 -5
  43. package/dist/plugins/eslint/helpers.js +10 -15
  44. package/dist/plugins/eslint/index.d.ts +10 -8
  45. package/dist/plugins/eslint/index.js +15 -29
  46. package/dist/plugins/gatsby/index.d.ts +8 -7
  47. package/dist/plugins/gatsby/index.js +15 -22
  48. package/dist/plugins/github-actions/index.d.ts +6 -6
  49. package/dist/plugins/github-actions/index.js +15 -25
  50. package/dist/plugins/graphql-codegen/index.d.ts +8 -7
  51. package/dist/plugins/graphql-codegen/index.js +15 -23
  52. package/dist/plugins/husky/index.d.ts +6 -6
  53. package/dist/plugins/husky/index.js +10 -16
  54. package/dist/plugins/jest/index.d.ts +9 -7
  55. package/dist/plugins/jest/index.js +50 -31
  56. package/dist/plugins/lefthook/index.d.ts +6 -6
  57. package/dist/plugins/lefthook/index.js +19 -24
  58. package/dist/plugins/lint-staged/index.d.ts +8 -7
  59. package/dist/plugins/lint-staged/index.js +16 -23
  60. package/dist/plugins/linthtml/index.d.ts +8 -7
  61. package/dist/plugins/linthtml/index.js +16 -24
  62. package/dist/plugins/markdownlint/index.d.ts +7 -6
  63. package/dist/plugins/markdownlint/index.js +12 -17
  64. package/dist/plugins/mocha/index.d.ts +9 -7
  65. package/dist/plugins/mocha/index.js +19 -22
  66. package/dist/plugins/msw/index.d.ts +8 -7
  67. package/dist/plugins/msw/index.js +12 -15
  68. package/dist/plugins/netlify/index.d.ts +9 -7
  69. package/dist/plugins/netlify/index.js +23 -27
  70. package/dist/plugins/next/index.d.ts +6 -7
  71. package/dist/plugins/next/index.js +10 -18
  72. package/dist/plugins/node-test-runner/index.d.ts +5 -6
  73. package/dist/plugins/node-test-runner/index.js +6 -18
  74. package/dist/plugins/npm-package-json-lint/index.d.ts +8 -7
  75. package/dist/plugins/npm-package-json-lint/index.js +12 -19
  76. package/dist/plugins/nx/index.d.ts +7 -6
  77. package/dist/plugins/nx/index.js +18 -27
  78. package/dist/plugins/nyc/index.d.ts +7 -6
  79. package/dist/plugins/nyc/index.js +11 -17
  80. package/dist/plugins/playwright/index.d.ts +11 -13
  81. package/dist/plugins/playwright/index.js +23 -30
  82. package/dist/plugins/playwright-ct/index.d.ts +8 -7
  83. package/dist/plugins/playwright-ct/index.js +12 -24
  84. package/dist/plugins/postcss/index.d.ts +7 -6
  85. package/dist/plugins/postcss/index.js +12 -21
  86. package/dist/plugins/prettier/index.d.ts +7 -6
  87. package/dist/plugins/prettier/index.js +14 -20
  88. package/dist/plugins/release-it/index.d.ts +8 -7
  89. package/dist/plugins/release-it/index.js +18 -27
  90. package/dist/plugins/remark/index.d.ts +8 -7
  91. package/dist/plugins/remark/index.js +13 -28
  92. package/dist/plugins/remix/index.d.ts +6 -7
  93. package/dist/plugins/remix/index.js +10 -20
  94. package/dist/plugins/rollup/index.d.ts +5 -6
  95. package/dist/plugins/rollup/index.js +8 -16
  96. package/dist/plugins/semantic-release/index.d.ts +8 -7
  97. package/dist/plugins/semantic-release/index.js +13 -25
  98. package/dist/plugins/sentry/index.d.ts +5 -6
  99. package/dist/plugins/sentry/index.js +8 -16
  100. package/dist/plugins/storybook/index.d.ts +10 -8
  101. package/dist/plugins/storybook/index.js +28 -35
  102. package/dist/plugins/stryker/index.d.ts +7 -6
  103. package/dist/plugins/stryker/index.js +10 -18
  104. package/dist/plugins/stylelint/index.d.ts +7 -6
  105. package/dist/plugins/stylelint/index.js +13 -23
  106. package/dist/plugins/svelte/index.d.ts +7 -8
  107. package/dist/plugins/svelte/index.js +13 -23
  108. package/dist/plugins/tailwind/index.d.ts +5 -6
  109. package/dist/plugins/tailwind/index.js +8 -14
  110. package/dist/plugins/tsup/index.d.ts +7 -6
  111. package/dist/plugins/tsup/index.js +14 -21
  112. package/dist/plugins/typedoc/index.d.ts +10 -7
  113. package/dist/plugins/typedoc/index.js +14 -24
  114. package/dist/plugins/typescript/index.d.ts +8 -7
  115. package/dist/plugins/typescript/index.js +31 -25
  116. package/dist/plugins/unbuild/index.d.ts +7 -6
  117. package/dist/plugins/unbuild/index.js +12 -17
  118. package/dist/plugins/vercel-og/index.d.ts +5 -6
  119. package/dist/plugins/vercel-og/index.js +8 -16
  120. package/dist/plugins/vite/index.d.ts +9 -7
  121. package/dist/plugins/vite/index.js +13 -18
  122. package/dist/plugins/vitest/index.d.ts +11 -9
  123. package/dist/plugins/vitest/index.js +62 -49
  124. package/dist/plugins/vue/index.d.ts +7 -6
  125. package/dist/plugins/vue/index.js +14 -26
  126. package/dist/plugins/webpack/index.d.ts +7 -6
  127. package/dist/plugins/webpack/index.js +17 -20
  128. package/dist/plugins/wireit/index.d.ts +8 -7
  129. package/dist/plugins/wireit/index.js +12 -20
  130. package/dist/plugins/yorkie/index.d.ts +8 -7
  131. package/dist/plugins/yorkie/index.js +13 -21
  132. package/dist/plugins.d.ts +3 -0
  133. package/dist/plugins.js +14 -0
  134. package/dist/reporters/index.d.ts +5 -5
  135. package/dist/types/config.d.ts +1 -1
  136. package/dist/types/package-json.d.ts +12 -13
  137. package/dist/types/plugins.d.ts +20 -14
  138. package/dist/types/util.d.ts +0 -13
  139. package/dist/typescript/SourceFileManager.js +3 -0
  140. package/dist/typescript/createHosts.js +4 -3
  141. package/dist/typescript/resolveModuleNames.js +26 -41
  142. package/dist/typescript/visitors/dynamic-imports/importCall.d.ts +1 -1
  143. package/dist/typescript/visitors/dynamic-imports/importType.d.ts +1 -1
  144. package/dist/typescript/visitors/dynamic-imports/index.d.ts +1 -1
  145. package/dist/typescript/visitors/dynamic-imports/jsDocType.d.ts +1 -1
  146. package/dist/typescript/visitors/dynamic-imports/propertyAccessCall.d.ts +1 -1
  147. package/dist/typescript/visitors/dynamic-imports/requireCall.d.ts +1 -1
  148. package/dist/typescript/visitors/exports/exportAssignment.d.ts +1 -1
  149. package/dist/typescript/visitors/exports/exportDeclaration.d.ts +1 -1
  150. package/dist/typescript/visitors/exports/exportKeyword.d.ts +1 -1
  151. package/dist/typescript/visitors/exports/index.d.ts +1 -1
  152. package/dist/typescript/visitors/exports/moduleExportsAccessExpression.d.ts +1 -1
  153. package/dist/typescript/visitors/imports/importDeclaration.d.ts +1 -1
  154. package/dist/typescript/visitors/imports/importEqualsDeclaration.d.ts +1 -1
  155. package/dist/typescript/visitors/imports/index.d.ts +1 -1
  156. package/dist/typescript/visitors/imports/reExportDeclaration.d.ts +1 -1
  157. package/dist/typescript/visitors/scripts/bun.d.ts +1 -1
  158. package/dist/typescript/visitors/scripts/execa.d.ts +1 -1
  159. package/dist/typescript/visitors/scripts/index.d.ts +1 -1
  160. package/dist/typescript/visitors/scripts/zx.d.ts +1 -1
  161. package/dist/util/Performance.d.ts +1 -4
  162. package/dist/util/Performance.js +5 -1
  163. package/dist/util/fs.js +0 -3
  164. package/dist/util/loader.d.ts +0 -2
  165. package/dist/util/loader.js +8 -16
  166. package/dist/util/object.d.ts +1 -1
  167. package/dist/util/path.d.ts +0 -3
  168. package/dist/util/path.js +0 -1
  169. package/dist/util/plugin.d.ts +4 -1
  170. package/dist/util/plugin.js +28 -1
  171. package/dist/util/require.d.ts +1 -0
  172. package/dist/util/require.js +13 -0
  173. package/dist/util/tsconfig-loader.js +1 -2
  174. package/dist/util/type.d.ts +1 -1
  175. package/dist/version.d.ts +1 -1
  176. package/dist/version.js +1 -1
  177. package/package.json +5 -1
  178. package/dist/plugins/eslint/fallback.d.ts +0 -1
  179. package/dist/plugins/eslint/fallback.js +0 -18
@@ -1,32 +1,24 @@
1
- import { load, hasDependency } from '../../util/plugin.js';
1
+ import { hasDependency } from '#p/util/plugin.js';
2
2
  import { toEntryPattern } from '../../util/protocols.js';
3
- const NAME = 'Cypress';
4
- const ENABLERS = ['cypress'];
5
- const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
6
- const CONFIG_FILE_PATTERNS = ['cypress.config.{js,ts,mjs,cjs}'];
3
+ const title = 'Cypress';
4
+ const enablers = ['cypress'];
5
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
6
+ const config = ['cypress.config.{js,ts,mjs,cjs}'];
7
7
  const TEST_FILE_PATTERNS = ['cypress/e2e/**/*.cy.{js,jsx,ts,tsx}'];
8
8
  const SUPPORT_FILE_PATTERNS = [
9
9
  'cypress/support/e2e.{js,jsx,ts,tsx}',
10
10
  'cypress/support/commands.{js,ts}',
11
11
  'cypress/plugins/index.js',
12
12
  ];
13
- const ENTRY_FILE_PATTERNS = [...TEST_FILE_PATTERNS, ...SUPPORT_FILE_PATTERNS];
14
- const findDependencies = async (configFilePath, options) => {
15
- const { config } = options;
16
- const localConfig = await load(configFilePath);
17
- if (!localConfig)
18
- return [];
19
- if (config.entry)
20
- return config.entry.map(toEntryPattern);
21
- const patterns = [localConfig.e2e?.specPattern ?? [], localConfig.component?.specPattern ?? []].flat();
22
- const entryPatterns = (patterns.length > 0 ? patterns : TEST_FILE_PATTERNS).map(toEntryPattern);
23
- return [...entryPatterns, ...SUPPORT_FILE_PATTERNS.map(toEntryPattern)];
13
+ const entry = [...TEST_FILE_PATTERNS, ...SUPPORT_FILE_PATTERNS];
14
+ const resolveEntryPaths = async (localConfig) => {
15
+ return [localConfig.e2e?.specPattern ?? [], localConfig.component?.specPattern ?? []].flat().map(toEntryPattern);
24
16
  };
25
17
  export default {
26
- NAME,
27
- ENABLERS,
18
+ title,
19
+ enablers,
28
20
  isEnabled,
29
- CONFIG_FILE_PATTERNS,
30
- ENTRY_FILE_PATTERNS,
31
- findDependencies,
21
+ config,
22
+ entry,
23
+ resolveEntryPaths,
32
24
  };
@@ -1,9 +1,10 @@
1
- import type { GenericPluginCallback, IsPluginEnabledCallback } from '../../types/plugins.js';
1
+ import type { ResolveConfig, IsPluginEnabled } from '#p/types/plugins.js';
2
+ import type { DrizzleConfig } from './types.js';
2
3
  declare const _default: {
3
- NAME: string;
4
- ENABLERS: string[];
5
- isEnabled: IsPluginEnabledCallback;
6
- CONFIG_FILE_PATTERNS: string[];
7
- findDependencies: GenericPluginCallback;
4
+ readonly title: "Drizzle";
5
+ readonly enablers: string[];
6
+ readonly isEnabled: IsPluginEnabled;
7
+ readonly config: string[];
8
+ readonly resolveConfig: ResolveConfig<DrizzleConfig>;
8
9
  };
9
10
  export default _default;
@@ -1,21 +1,18 @@
1
- import { timerify } from '../../util/Performance.js';
2
- import { hasDependency, load } from '../../util/plugin.js';
3
- import { toProductionEntryPattern } from '../../util/protocols.js';
4
- const NAME = 'Drizzle';
5
- const ENABLERS = ['drizzle-kit'];
6
- const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
7
- const CONFIG_FILE_PATTERNS = ['drizzle.config.{ts,js,json}'];
8
- const findDrizzleDependencies = async (configFilePath) => {
9
- const localConfig = await load(configFilePath);
10
- if (!localConfig?.schema)
1
+ import { hasDependency } from '#p/util/plugin.js';
2
+ import { toProductionEntryPattern } from '#p/util/protocols.js';
3
+ const title = 'Drizzle';
4
+ const enablers = ['drizzle-kit'];
5
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
6
+ const config = ['drizzle.config.{ts,js,json}'];
7
+ const resolveConfig = config => {
8
+ if (!config.schema)
11
9
  return [];
12
- return [localConfig.schema].flat().map(toProductionEntryPattern);
10
+ return [config.schema].flat().map(toProductionEntryPattern);
13
11
  };
14
- const findDependencies = timerify(findDrizzleDependencies);
15
12
  export default {
16
- NAME,
17
- ENABLERS,
13
+ title,
14
+ enablers,
18
15
  isEnabled,
19
- CONFIG_FILE_PATTERNS,
20
- findDependencies,
16
+ config,
17
+ resolveConfig,
21
18
  };
@@ -1,12 +1,14 @@
1
- import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
1
+ import { DummyEleventyConfig } from './helpers.js';
2
+ import type { IsPluginEnabled, ResolveConfig, ResolveEntryPaths } from '#p/types/plugins.js';
3
+ import type { EleventyConfig } from './types.js';
4
+ type T = Partial<EleventyConfig> | ((arg: DummyEleventyConfig) => Promise<Partial<EleventyConfig>>);
2
5
  declare const _default: {
3
- NAME: string;
4
- ENABLERS: string[];
5
- isEnabled: IsPluginEnabledCallback;
6
- CONFIG_FILE_PATTERNS: string[];
7
- ENTRY_FILE_PATTERNS: string[];
8
- PRODUCTION_ENTRY_FILE_PATTERNS: string[];
9
- PROJECT_FILE_PATTERNS: string[];
10
- findDependencies: GenericPluginCallback;
6
+ title: string;
7
+ enablers: string[];
8
+ isEnabled: IsPluginEnabled;
9
+ config: string[];
10
+ production: string[];
11
+ resolveEntryPaths: ResolveEntryPaths<T>;
12
+ resolveConfig: ResolveConfig<T>;
11
13
  };
12
14
  export default _default;
@@ -1,24 +1,16 @@
1
+ import { isDirectory } from '#p/util/fs.js';
2
+ import { isInNodeModules, join } from '#p/util/path.js';
3
+ import { hasDependency } from '#p/util/plugin.js';
4
+ import { toProductionEntryPattern } from '#p/util/protocols.js';
1
5
  import { DEFAULT_EXTENSIONS } from '../../constants.js';
2
- import { isDirectory } from '../../util/fs.js';
3
- import { dirname, isInNodeModules, join } from '../../util/path.js';
4
- import { timerify } from '../../util/Performance.js';
5
- import { hasDependency, load } from '../../util/plugin.js';
6
- import { toProductionEntryPattern } from '../../util/protocols.js';
7
6
  import { DummyEleventyConfig, defaultEleventyConfig } from './helpers.js';
8
- const NAME = 'Eleventy';
9
- const ENABLERS = ['@11ty/eleventy'];
10
- const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
11
- const CONFIG_FILE_PATTERNS = ['.eleventy.js', 'eleventy.config.{js,cjs,mjs}'];
12
- const ENTRY_FILE_PATTERNS = [];
13
- const PRODUCTION_ENTRY_FILE_PATTERNS = ['posts/**/*.11tydata.js', '_data/**/*.{js,cjs,mjs}'];
14
- const PROJECT_FILE_PATTERNS = [];
15
- const findEleventyDependencies = async (configFilePath, options) => {
16
- const { config } = options;
17
- let localConfig = (await load(configFilePath));
18
- if (!localConfig)
19
- return config.entry
20
- ? config.entry.map(toProductionEntryPattern)
21
- : PRODUCTION_ENTRY_FILE_PATTERNS.map(toProductionEntryPattern);
7
+ const title = 'Eleventy';
8
+ const enablers = ['@11ty/eleventy'];
9
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
10
+ const config = ['.eleventy.js', 'eleventy.config.{js,cjs,mjs}'];
11
+ const production = ['posts/**/*.11tydata.js', '_data/**/*.{js,cjs,mjs}'];
12
+ const resolveEntryPaths = async (localConfig, options) => {
13
+ const { configFileDir } = options;
22
14
  const dummyUserConfig = new DummyEleventyConfig();
23
15
  if (typeof localConfig === 'function')
24
16
  localConfig = await localConfig(dummyUserConfig);
@@ -26,38 +18,40 @@ const findEleventyDependencies = async (configFilePath, options) => {
26
18
  const dataDir = localConfig?.dir?.data || defaultEleventyConfig.dir.data;
27
19
  const templateFormats = localConfig.templateFormats || defaultEleventyConfig.templateFormats;
28
20
  const exts = DEFAULT_EXTENSIONS.map(extname => extname.slice(1)).join(',');
29
- const copiedPackages = new Set();
30
21
  const copiedEntries = new Set();
31
22
  for (const path of Object.keys(dummyUserConfig.passthroughCopies)) {
32
- const isDir = !path.includes('*') && isDirectory(join(dirname(configFilePath), path));
23
+ const isDir = !path.includes('*') && isDirectory(join(configFileDir, path));
33
24
  if (isDir) {
34
25
  copiedEntries.add(join(path, `**/*.{${exts}}`));
35
26
  }
36
- else if (isInNodeModules(path)) {
37
- copiedPackages.add(path);
38
- }
39
- else {
27
+ else if (!isInNodeModules(path)) {
40
28
  copiedEntries.add(path);
41
29
  }
42
30
  }
43
31
  return [
44
- ...(config?.entry ?? [
45
- join(inputDir, dataDir, '**/*.js'),
46
- join(inputDir, `**/*.{${typeof templateFormats === 'string' ? templateFormats : templateFormats.join(',')}}`),
47
- join(inputDir, '**/*.11tydata.js'),
48
- ...copiedEntries,
49
- ]).map(toProductionEntryPattern),
50
- ...copiedPackages,
51
- ];
32
+ join(inputDir, dataDir, '**/*.{js,cjs,mjs}'),
33
+ join(inputDir, `**/*.{${typeof templateFormats === 'string' ? templateFormats : templateFormats.join(',')}}`),
34
+ join(inputDir, '**/*.11tydata.js'),
35
+ ...copiedEntries,
36
+ ].map(toProductionEntryPattern);
37
+ };
38
+ const resolveConfig = async (localConfig) => {
39
+ const dummyUserConfig = new DummyEleventyConfig();
40
+ if (typeof localConfig === 'function')
41
+ localConfig = await localConfig(dummyUserConfig);
42
+ const copiedPackages = new Set();
43
+ for (const path of Object.keys(dummyUserConfig.passthroughCopies)) {
44
+ if (isInNodeModules(path))
45
+ copiedPackages.add(path);
46
+ }
47
+ return [...copiedPackages];
52
48
  };
53
- const findDependencies = timerify(findEleventyDependencies);
54
49
  export default {
55
- NAME,
56
- ENABLERS,
50
+ title,
51
+ enablers,
57
52
  isEnabled,
58
- CONFIG_FILE_PATTERNS,
59
- ENTRY_FILE_PATTERNS,
60
- PRODUCTION_ENTRY_FILE_PATTERNS,
61
- PROJECT_FILE_PATTERNS,
62
- findDependencies,
53
+ config,
54
+ production,
55
+ resolveEntryPaths,
56
+ resolveConfig,
63
57
  };
@@ -1,7 +1,5 @@
1
- import type { PackageJson } from '../../types/package-json.js';
2
- type GetDependenciesDeep = (configFilePath: string, options: {
3
- cwd: string;
4
- manifest: PackageJson;
5
- }, dependencies?: Set<string>) => Promise<Set<string>>;
1
+ import type { ESLintConfig } from './types.js';
2
+ import type { PluginOptions } from '../../types/plugins.js';
3
+ type GetDependenciesDeep = (localConfig: ESLintConfig, options: PluginOptions, dependencies?: Set<string>) => Promise<Set<string>>;
6
4
  export declare const getDependenciesDeep: GetDependenciesDeep;
7
5
  export {};
@@ -1,11 +1,9 @@
1
- import { compact } from '../../util/array.js';
2
- import { getPackageNameFromFilePath, getPackageNameFromModuleSpecifier } from '../../util/modules.js';
3
- import { basename, isInternal, dirname, toAbsolute, isAbsolute } from '../../util/path.js';
4
- import { load } from '../../util/plugin.js';
5
- import { _resolve } from '../../util/require.js';
1
+ import { compact } from '#p/util/array.js';
2
+ import { getPackageNameFromFilePath, getPackageNameFromModuleSpecifier } from '#p/util/modules.js';
3
+ import { isInternal, toAbsolute, isAbsolute } from '#p/util/path.js';
4
+ import { load } from '#p/util/plugin.js';
5
+ import { _resolve } from '#p/util/require.js';
6
6
  import { getDependenciesFromConfig } from '../babel/index.js';
7
- import { fallback } from './fallback.js';
8
- import { PACKAGE_JSON_PATH } from './index.js';
9
7
  const getDependencies = (config) => {
10
8
  const extendsSpecifiers = config.extends ? [config.extends].flat().map(resolveExtendSpecifier) : [];
11
9
  if (extendsSpecifiers.some(specifier => specifier?.startsWith('eslint-plugin-prettier')))
@@ -19,21 +17,18 @@ const getDependencies = (config) => {
19
17
  const overrides = config.overrides ? [config.overrides].flat().flatMap(getDependencies) : [];
20
18
  return compact([...extendsSpecifiers, ...plugins, parser, ...babelDependencies, ...settings, ...overrides]);
21
19
  };
22
- export const getDependenciesDeep = async (configFilePath, options, dependencies = new Set()) => {
20
+ export const getDependenciesDeep = async (localConfig, options, dependencies = new Set()) => {
21
+ const { configFileDir } = options;
23
22
  const addAll = (deps) => deps.forEach(dependency => dependencies.add(dependency));
24
- const localConfig = basename(configFilePath) === 'package.json'
25
- ? options.manifest[PACKAGE_JSON_PATH]
26
- : /(\.(jsonc?|ya?ml)|rc)$/.test(configFilePath)
27
- ? await load(configFilePath)
28
- : await fallback(configFilePath);
29
23
  if (localConfig) {
30
24
  if (localConfig.extends) {
31
25
  for (const extend of [localConfig.extends].flat()) {
32
26
  if (isInternal(extend)) {
33
- const filePath = toAbsolute(extend, dirname(configFilePath));
27
+ const filePath = toAbsolute(extend, configFileDir);
34
28
  const extendConfigFilePath = _resolve(filePath);
35
29
  dependencies.add(extendConfigFilePath);
36
- addAll(await getDependenciesDeep(extendConfigFilePath, options, dependencies));
30
+ const localConfig = await load(extendConfigFilePath);
31
+ addAll(await getDependenciesDeep(localConfig, options, dependencies));
37
32
  }
38
33
  }
39
34
  }
@@ -1,11 +1,13 @@
1
- import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
2
- export declare const PACKAGE_JSON_PATH = "eslintConfig";
1
+ import type { IsPluginEnabled, ResolveConfig } from '#p/types/plugins.js';
2
+ import type { ESLintConfig } from './types.js';
3
+ export declare const packageJsonPath = "eslintConfig";
3
4
  declare const _default: {
4
- NAME: string;
5
- ENABLERS: string[];
6
- isEnabled: IsPluginEnabledCallback;
7
- PACKAGE_JSON_PATH: string;
8
- CONFIG_FILE_PATTERNS: string[];
9
- findDependencies: GenericPluginCallback;
5
+ readonly title: "ESLint";
6
+ readonly enablers: string[];
7
+ readonly isEnabled: IsPluginEnabled;
8
+ readonly packageJsonPath: "eslintConfig";
9
+ readonly entry: string[];
10
+ readonly config: string[];
11
+ readonly resolveConfig: ResolveConfig<ESLintConfig>;
10
12
  };
11
13
  export default _default;
@@ -1,37 +1,23 @@
1
- import { basename } from '../../util/path.js';
2
- import { timerify } from '../../util/Performance.js';
3
- import { hasDependency } from '../../util/plugin.js';
1
+ import { hasDependency } from '#p/util/plugin.js';
4
2
  import { getDependenciesDeep } from './helpers.js';
5
- const NAME = 'ESLint';
6
- const ENABLERS = ['eslint'];
7
- const isEnabled = ({ dependencies, manifest, config }) => hasDependency(dependencies, ENABLERS) ||
3
+ const title = 'ESLint';
4
+ const enablers = ['eslint'];
5
+ const isEnabled = ({ dependencies, manifest, config }) => hasDependency(dependencies, enablers) ||
8
6
  'eslint' in config ||
9
7
  Boolean(manifest.name && /(^eslint-config|\/eslint-config)/.test(manifest.name));
10
- export const PACKAGE_JSON_PATH = 'eslintConfig';
11
- const CONFIG_FILE_PATTERNS = [
12
- 'eslint.config.{js,cjs,mjs}',
13
- '.eslintrc',
14
- '.eslintrc.{js,json,cjs}',
15
- '.eslintrc.{yml,yaml}',
16
- 'package.json',
17
- ];
18
- const findESLintDependencies = async (configFilePath, { cwd, manifest, isProduction }) => {
19
- if (isProduction)
20
- return [];
21
- const baseFilePath = basename(configFilePath);
22
- if (baseFilePath === 'eslint.config.js' ||
23
- baseFilePath === 'eslint.config.cjs' ||
24
- baseFilePath === 'eslint.config.mjs')
25
- return [];
26
- const dependencies = await getDependenciesDeep(configFilePath, { cwd, manifest });
8
+ export const packageJsonPath = 'eslintConfig';
9
+ const entry = ['eslint.config.{js,cjs,mjs}'];
10
+ const config = ['.eslintrc', '.eslintrc.{js,json,cjs}', '.eslintrc.{yml,yaml}', 'package.json'];
11
+ const resolveConfig = async (localConfig, options) => {
12
+ const dependencies = await getDependenciesDeep(localConfig, options);
27
13
  return Array.from(dependencies);
28
14
  };
29
- const findDependencies = timerify(findESLintDependencies);
30
15
  export default {
31
- NAME,
32
- ENABLERS,
16
+ title,
17
+ enablers,
33
18
  isEnabled,
34
- PACKAGE_JSON_PATH,
35
- CONFIG_FILE_PATTERNS,
36
- findDependencies,
19
+ packageJsonPath,
20
+ entry,
21
+ config,
22
+ resolveConfig,
37
23
  };
@@ -1,10 +1,11 @@
1
- import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
1
+ import type { IsPluginEnabled, ResolveConfig } from '#p/types/plugins.js';
2
+ import type { GatsbyConfig, GatsbyNode } from './types.js';
2
3
  declare const _default: {
3
- NAME: string;
4
- ENABLERS: string[];
5
- isEnabled: IsPluginEnabledCallback;
6
- CONFIG_FILE_PATTERNS: string[];
7
- PRODUCTION_ENTRY_FILE_PATTERNS: string[];
8
- findDependencies: GenericPluginCallback;
4
+ title: string;
5
+ enablers: string[];
6
+ isEnabled: IsPluginEnabled;
7
+ config: string[];
8
+ production: string[];
9
+ resolveConfig: ResolveConfig<GatsbyConfig | GatsbyNode>;
9
10
  };
10
11
  export default _default;
@@ -1,11 +1,9 @@
1
- import { timerify } from '../../util/Performance.js';
2
- import { hasDependency, load } from '../../util/plugin.js';
3
- import { toProductionEntryPattern } from '../../util/protocols.js';
4
- const NAME = 'Gatsby';
5
- const ENABLERS = ['gatsby', 'gatsby-cli'];
6
- const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
7
- const CONFIG_FILE_PATTERNS = ['gatsby-{config,node}.{js,jsx,ts,tsx}', 'plugins/**/gatsby-node.{js,jsx,ts,tsx}'];
8
- const PRODUCTION_ENTRY_FILE_PATTERNS = [
1
+ import { hasDependency } from '#p/util/plugin.js';
2
+ const title = 'Gatsby';
3
+ const enablers = ['gatsby', 'gatsby-cli'];
4
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
5
+ const config = ['gatsby-{config,node}.{js,jsx,ts,tsx}', 'plugins/**/gatsby-node.{js,jsx,ts,tsx}'];
6
+ const production = [
9
7
  'gatsby-{browser,ssr}.{js,jsx,ts,tsx}',
10
8
  'src/api/**/*.{js,ts}',
11
9
  'src/pages/**/*.{js,jsx,ts,tsx}',
@@ -13,16 +11,12 @@ const PRODUCTION_ENTRY_FILE_PATTERNS = [
13
11
  'src/html.{js,jsx,ts,tsx}',
14
12
  'plugins/**/gatsby-{browser,ssr}.{js,jsx,ts,tsx}',
15
13
  ];
16
- const findGatsbyDependencies = async (configFilePath, options) => {
17
- const { isProduction, config } = options;
18
- const localConfig = await load(configFilePath);
19
- const entryPatterns = (config.entry ?? PRODUCTION_ENTRY_FILE_PATTERNS).map(toProductionEntryPattern);
20
- if (isProduction || !localConfig)
21
- return entryPatterns;
22
- if (/gatsby-config/.test(configFilePath)) {
14
+ const resolveConfig = async (localConfig, options) => {
15
+ const { configFileName } = options;
16
+ if (/gatsby-config/.test(configFileName)) {
23
17
  return localConfig.plugins.map(plugin => (typeof plugin === 'string' ? plugin : plugin.resolve));
24
18
  }
25
- if (/gatsby-node/.test(configFilePath)) {
19
+ if (/gatsby-node/.test(configFileName)) {
26
20
  const plugins = new Set();
27
21
  const actions = { setBabelPlugin: plugin => plugins.add(plugin.name) };
28
22
  const _config = localConfig;
@@ -33,12 +27,11 @@ const findGatsbyDependencies = async (configFilePath, options) => {
33
27
  }
34
28
  return [];
35
29
  };
36
- const findDependencies = timerify(findGatsbyDependencies);
37
30
  export default {
38
- NAME,
39
- ENABLERS,
31
+ title,
32
+ enablers,
40
33
  isEnabled,
41
- CONFIG_FILE_PATTERNS,
42
- PRODUCTION_ENTRY_FILE_PATTERNS,
43
- findDependencies,
34
+ config,
35
+ production,
36
+ resolveConfig,
44
37
  };
@@ -1,9 +1,9 @@
1
- import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
1
+ import type { IsPluginEnabled, ResolveConfig } from '#p/types/plugins.js';
2
2
  declare const _default: {
3
- NAME: string;
4
- ENABLERS: string;
5
- isEnabled: IsPluginEnabledCallback;
6
- CONFIG_FILE_PATTERNS: string[];
7
- findDependencies: GenericPluginCallback;
3
+ title: string;
4
+ enablers: string;
5
+ isEnabled: IsPluginEnabled;
6
+ config: string[];
7
+ resolveConfig: ResolveConfig;
8
8
  };
9
9
  export default _default;
@@ -1,38 +1,28 @@
1
- import { _firstGlob } from '../../util/glob.js';
2
- import { getValuesByKeyDeep } from '../../util/object.js';
3
- import { basename, dirname, join } from '../../util/path.js';
4
- import { timerify } from '../../util/Performance.js';
5
- import { getDependenciesFromScripts, load } from '../../util/plugin.js';
6
- function isString(value) {
7
- return typeof value === 'string';
8
- }
9
- const NAME = 'GitHub Actions';
10
- const ENABLERS = 'This plugin is enabled when a `.yml` or `.yaml` file is found in the `.github/workflows` folder.';
1
+ import { _firstGlob } from '#p/util/glob.js';
2
+ import { getValuesByKeyDeep } from '#p/util/object.js';
3
+ import { join } from '#p/util/path.js';
4
+ import { getDependenciesFromScripts } from '#p/util/plugin.js';
5
+ const title = 'GitHub Actions';
6
+ const enablers = 'This plugin is enabled when a `.yml` or `.yaml` file is found in the `.github/workflows` folder.';
11
7
  const isEnabled = async ({ cwd }) => Boolean(await _firstGlob({ cwd, patterns: ['.github/workflows/*.{yml,yaml}'] }));
12
- const CONFIG_FILE_PATTERNS = ['.github/workflows/*.{yml,yaml}', '.github/**/action.{yml,yaml}'];
13
- const findGithubActionsDependencies = async (configFilePath, options) => {
14
- const { isProduction } = options;
15
- const configFileName = basename(configFilePath);
16
- if (isProduction)
17
- return [];
18
- const config = await load(configFilePath);
19
- if (!config)
20
- return [];
8
+ const config = ['.github/workflows/*.{yml,yaml}', '.github/**/action.{yml,yaml}'];
9
+ const isString = (value) => typeof value === 'string';
10
+ const resolveConfig = async (config, options) => {
11
+ const { configFileDir, configFileName } = options;
21
12
  const scripts = getValuesByKeyDeep(config, 'run').filter(isString);
22
13
  const getActionDependencies = () => {
23
14
  const isActionManifest = configFileName === 'action.yml' || configFileName === 'action.yaml';
24
15
  if (!isActionManifest || !config?.runs?.using?.startsWith('node'))
25
16
  return [];
26
17
  const scripts = [config.runs.pre, config.runs.main, config.runs.post].filter(isString);
27
- return scripts.map(script => join(dirname(configFilePath), script));
18
+ return scripts.map(script => join(configFileDir, script));
28
19
  };
29
20
  return [...getActionDependencies(), ...getDependenciesFromScripts(scripts, { ...options, knownGlobalsOnly: true })];
30
21
  };
31
- const findDependencies = timerify(findGithubActionsDependencies);
32
22
  export default {
33
- NAME,
34
- ENABLERS,
23
+ title,
24
+ enablers,
35
25
  isEnabled,
36
- CONFIG_FILE_PATTERNS,
37
- findDependencies,
26
+ config,
27
+ resolveConfig,
38
28
  };
@@ -1,10 +1,11 @@
1
- import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
1
+ import type { ResolveConfig, IsPluginEnabled } from '#p/types/plugins.js';
2
+ import type { GraphqlCodegenTypes } from './types.js';
2
3
  declare const _default: {
3
- NAME: string;
4
- ENABLERS: RegExp[];
5
- isEnabled: IsPluginEnabledCallback;
6
- PACKAGE_JSON_PATH: string;
7
- CONFIG_FILE_PATTERNS: string[];
8
- findDependencies: GenericPluginCallback;
4
+ readonly title: "GraphQL Codegen";
5
+ readonly enablers: RegExp[];
6
+ readonly isEnabled: IsPluginEnabled;
7
+ readonly packageJsonPath: "codegen";
8
+ readonly config: string[];
9
+ readonly resolveConfig: ResolveConfig<GraphqlCodegenTypes>;
9
10
  };
10
11
  export default _default;
@@ -1,26 +1,19 @@
1
- import { basename, isInternal } 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';
1
+ import { isInternal } from '#p/util/path.js';
2
+ import { hasDependency } from '#p/util/plugin.js';
3
+ import { toEntryPattern } from '#p/util/protocols.js';
5
4
  import { isConfigurationOutput } from './types.js';
6
- const NAME = 'GraphQL Codegen';
7
- const ENABLERS = [/^@graphql-codegen\//];
8
- const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
9
- const PACKAGE_JSON_PATH = 'codegen';
10
- const CONFIG_FILE_PATTERNS = [
5
+ const title = 'GraphQL Codegen';
6
+ const enablers = [/^@graphql-codegen\//];
7
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
8
+ const packageJsonPath = 'codegen';
9
+ const config = [
11
10
  'codegen.{json,yml,yaml,js,ts,mjs,cts}',
12
11
  '.codegenrc.{json,yml,yaml,js,ts}',
13
12
  'codegen.config.js',
14
13
  'package.json',
15
14
  ];
16
- const findPluginDependencies = async (configFilePath, options) => {
17
- const { manifest, isProduction } = options;
18
- if (isProduction)
19
- return [];
20
- const localConfig = basename(configFilePath) === 'package.json' ? manifest[PACKAGE_JSON_PATH] : await load(configFilePath);
21
- if (!localConfig)
22
- return [];
23
- const generateSet = localConfig.generates ? Object.values(localConfig.generates) : [];
15
+ const resolveConfig = config => {
16
+ const generateSet = config.generates ? Object.values(config.generates) : [];
24
17
  const configurationOutput = generateSet.filter(isConfigurationOutput);
25
18
  const presets = configurationOutput
26
19
  .map(configOutput => (configOutput.preset ? configOutput.preset : undefined))
@@ -41,12 +34,11 @@ const findPluginDependencies = async (configFilePath, options) => {
41
34
  });
42
35
  return [...presets, ...flatPlugins, ...nestedPlugins];
43
36
  };
44
- const findDependencies = timerify(findPluginDependencies);
45
37
  export default {
46
- NAME,
47
- ENABLERS,
38
+ title,
39
+ enablers,
48
40
  isEnabled,
49
- PACKAGE_JSON_PATH,
50
- CONFIG_FILE_PATTERNS,
51
- findDependencies,
41
+ packageJsonPath,
42
+ config,
43
+ resolveConfig,
52
44
  };
@@ -1,9 +1,9 @@
1
- import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
1
+ import type { IsPluginEnabled, ResolveConfig } from '../../types/plugins.js';
2
2
  declare const _default: {
3
- NAME: string;
4
- ENABLERS: string[];
5
- isEnabled: IsPluginEnabledCallback;
6
- CONFIG_FILE_PATTERNS: string[];
7
- findDependencies: GenericPluginCallback;
3
+ title: string;
4
+ enablers: string[];
5
+ isEnabled: IsPluginEnabled;
6
+ config: string[];
7
+ resolveConfig: ResolveConfig<string>;
8
8
  };
9
9
  export default _default;
@@ -1,25 +1,19 @@
1
1
  import { getGitHookPaths } from '../../util/git.js';
2
- import { timerify } from '../../util/Performance.js';
3
- import { getDependenciesFromScripts, hasDependency, loadFile } from '../../util/plugin.js';
4
- const NAME = 'husky';
5
- const ENABLERS = ['husky'];
6
- const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
2
+ import { getDependenciesFromScripts, hasDependency } from '../../util/plugin.js';
3
+ const title = 'husky';
4
+ const enablers = ['husky'];
5
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
7
6
  const gitHookPaths = getGitHookPaths('.husky', false);
8
- const CONFIG_FILE_PATTERNS = [...gitHookPaths];
9
- const findHuskyDependencies = async (configFilePath, options) => {
10
- const { isProduction } = options;
11
- if (isProduction)
12
- return [];
13
- const script = await loadFile(configFilePath);
7
+ const config = [...gitHookPaths];
8
+ const resolveConfig = async (script, options) => {
14
9
  if (!script)
15
10
  return [];
16
11
  return getDependenciesFromScripts(String(script), { ...options, knownGlobalsOnly: true });
17
12
  };
18
- const findDependencies = timerify(findHuskyDependencies);
19
13
  export default {
20
- NAME,
21
- ENABLERS,
14
+ title,
15
+ enablers,
22
16
  isEnabled,
23
- CONFIG_FILE_PATTERNS,
24
- findDependencies,
17
+ config,
18
+ resolveConfig,
25
19
  };