knip 5.41.1 → 5.42.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/README.md +1 -1
  2. package/dist/ConfigurationChief.d.ts +2 -0
  3. package/dist/ConfigurationValidator.d.ts +112 -0
  4. package/dist/IssueCollector.js +6 -4
  5. package/dist/ProjectPrincipal.js +2 -14
  6. package/dist/WorkspaceWorker.js +2 -3
  7. package/dist/binaries/package-manager/bun.js +8 -2
  8. package/dist/binaries/package-manager/bunx.d.ts +3 -0
  9. package/dist/binaries/package-manager/bunx.js +18 -0
  10. package/dist/binaries/package-manager/index.d.ts +2 -0
  11. package/dist/binaries/package-manager/index.js +4 -0
  12. package/dist/binaries/package-manager/npm.js +1 -2
  13. package/dist/binaries/package-manager/npx.js +7 -2
  14. package/dist/binaries/package-manager/pnpm.js +7 -1
  15. package/dist/binaries/package-manager/pnpx.d.ts +3 -0
  16. package/dist/binaries/package-manager/pnpx.js +18 -0
  17. package/dist/binaries/package-manager/yarn.js +4 -3
  18. package/dist/binaries/plugins.js +7 -2
  19. package/dist/compilers/index.d.ts +20 -0
  20. package/dist/constants.js +2 -0
  21. package/dist/index.js +27 -17
  22. package/dist/plugins/_template/index.js +1 -1
  23. package/dist/plugins/angular/index.js +59 -27
  24. package/dist/plugins/angular/types.d.ts +2 -2
  25. package/dist/plugins/capacitor/index.js +1 -1
  26. package/dist/plugins/changesets/index.js +1 -1
  27. package/dist/plugins/commitlint/index.js +1 -1
  28. package/dist/plugins/dependency-cruiser/index.d.ts +12 -0
  29. package/dist/plugins/dependency-cruiser/index.js +16 -0
  30. package/dist/plugins/expo/helpers.js +1 -1
  31. package/dist/plugins/expo/index.d.ts +3 -0
  32. package/dist/plugins/expo/index.js +6 -4
  33. package/dist/plugins/gatsby/index.js +1 -1
  34. package/dist/plugins/graphql-codegen/index.js +1 -1
  35. package/dist/plugins/index.d.ts +29 -11
  36. package/dist/plugins/index.js +4 -0
  37. package/dist/plugins/jest/index.d.ts +3 -0
  38. package/dist/plugins/jest/index.js +4 -0
  39. package/dist/plugins/karma/helpers.d.ts +7 -0
  40. package/dist/plugins/karma/helpers.js +32 -0
  41. package/dist/plugins/karma/index.d.ts +1 -2
  42. package/dist/plugins/karma/index.js +10 -36
  43. package/dist/plugins/lefthook/index.js +2 -2
  44. package/dist/plugins/linthtml/index.d.ts +2 -2
  45. package/dist/plugins/linthtml/types.d.ts +1 -1
  46. package/dist/plugins/markdownlint/index.js +1 -1
  47. package/dist/plugins/metro/index.d.ts +15 -0
  48. package/dist/plugins/metro/index.js +47 -0
  49. package/dist/plugins/metro/types.d.ts +13 -0
  50. package/dist/plugins/metro/types.js +1 -0
  51. package/dist/plugins/nest/index.js +1 -1
  52. package/dist/plugins/netlify/index.js +2 -2
  53. package/dist/plugins/npm-package-json-lint/index.js +1 -1
  54. package/dist/plugins/nuxt/index.d.ts +3 -1
  55. package/dist/plugins/nuxt/index.js +3 -3
  56. package/dist/plugins/nx/index.js +11 -3
  57. package/dist/plugins/nx/types.d.ts +1 -0
  58. package/dist/plugins/oclif/index.js +1 -1
  59. package/dist/plugins/prettier/index.js +1 -1
  60. package/dist/plugins/release-it/index.d.ts +0 -1
  61. package/dist/plugins/release-it/index.js +1 -3
  62. package/dist/plugins/semantic-release/index.js +7 -1
  63. package/dist/plugins/simple-git-hooks/index.d.ts +2 -3
  64. package/dist/plugins/simple-git-hooks/index.js +1 -9
  65. package/dist/plugins/simple-git-hooks/types.d.ts +1 -1
  66. package/dist/plugins/storybook/index.js +5 -1
  67. package/dist/plugins/typescript/index.d.ts +3 -1
  68. package/dist/plugins/typescript/index.js +2 -2
  69. package/dist/plugins/vite/index.d.ts +0 -1
  70. package/dist/plugins/vite/index.js +0 -2
  71. package/dist/plugins/vitest/index.js +1 -1
  72. package/dist/plugins/webdriver-io/index.js +1 -1
  73. package/dist/plugins/webpack/index.d.ts +4 -1
  74. package/dist/plugins/webpack/index.js +5 -2
  75. package/dist/plugins/wireit/index.d.ts +0 -1
  76. package/dist/plugins/wireit/index.js +0 -2
  77. package/dist/reporters/symbols.js +12 -3
  78. package/dist/schema/plugins.d.ts +46 -0
  79. package/dist/schema/plugins.js +2 -0
  80. package/dist/types/PluginNames.d.ts +2 -2
  81. package/dist/types/PluginNames.js +2 -0
  82. package/dist/types/config.d.ts +1 -2
  83. package/dist/types/dependency-graph.d.ts +2 -4
  84. package/dist/typescript/ast-helpers.d.ts +1 -0
  85. package/dist/typescript/ast-helpers.js +1 -0
  86. package/dist/typescript/get-imports-and-exports.d.ts +2 -4
  87. package/dist/typescript/get-imports-and-exports.js +18 -23
  88. package/dist/typescript/visitors/exports/exportAssignment.js +2 -1
  89. package/dist/typescript/visitors/exports/exportDeclaration.js +2 -1
  90. package/dist/typescript/visitors/exports/exportKeyword.js +3 -4
  91. package/dist/typescript/visitors/helpers.d.ts +2 -1
  92. package/dist/typescript/visitors/helpers.js +3 -2
  93. package/dist/typescript/visitors/scripts/bun.js +1 -1
  94. package/dist/typescript/visitors/scripts/execa.js +24 -1
  95. package/dist/util/dependency-graph.js +2 -4
  96. package/dist/util/file-entry-cache.js +2 -6
  97. package/dist/util/get-referenced-inputs.js +4 -2
  98. package/dist/util/input.d.ts +3 -1
  99. package/dist/util/input.js +5 -1
  100. package/dist/util/modules.js +1 -1
  101. package/dist/version.d.ts +1 -1
  102. package/dist/version.js +1 -1
  103. package/package.json +13 -12
  104. package/schema.json +8 -0
@@ -1,43 +1,28 @@
1
- import { toDeferResolveEntry, toDevDependency, toEntry } from '../../util/input.js';
2
- import { isInternal, join } from '../../util/path.js';
1
+ import { toEntry } from '../../util/input.js';
2
+ import { join } from '../../util/path.js';
3
3
  import { hasDependency } from '../../util/plugin.js';
4
+ import { configFiles, inputsFromFrameworks, inputsFromPlugins, loadConfig } from './helpers.js';
4
5
  const title = 'Karma';
5
6
  const enablers = ['karma'];
6
7
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
7
- const config = ['karma.conf.js', 'karma.conf.ts', '.config/karma.conf.js', '.config/karma.conf.ts'];
8
+ const config = configFiles;
8
9
  const entry = [];
9
10
  const resolveConfig = async (localConfig, options) => {
10
11
  const inputs = new Set();
11
12
  const config = loadConfig(localConfig);
13
+ if (!config)
14
+ return [];
12
15
  if (config.frameworks) {
13
- for (const framework of config.frameworks) {
14
- inputs.add(toDevDependency(devDepForFramework(framework)));
15
- }
16
- }
17
- if (config.plugins) {
18
- for (const plugin of config.plugins) {
19
- if (typeof plugin !== 'string')
20
- continue;
21
- if (isInternal(plugin)) {
22
- inputs.add(toDeferResolveEntry(plugin));
23
- }
24
- else {
25
- inputs.add(toDevDependency(plugin));
26
- }
27
- }
28
- }
29
- else {
30
- const karmaPluginDevDeps = Object.keys(options.manifest.devDependencies ?? {}).filter(name => name.startsWith('karma-'));
31
- for (const karmaPluginDevDep of karmaPluginDevDeps) {
32
- inputs.add(toDevDependency(karmaPluginDevDep));
33
- }
16
+ inputsFromFrameworks(config.frameworks).forEach(inputs.add, inputs);
34
17
  }
18
+ inputsFromPlugins(config.plugins, options.manifest.devDependencies).forEach(inputs.add, inputs);
35
19
  return Array.from(inputs);
36
20
  };
37
- const devDepForFramework = (framework) => (framework === 'jasmine' ? 'jasmine-core' : framework);
38
21
  const resolveEntryPaths = (localConfig, options) => {
39
22
  const inputs = new Set();
40
23
  const config = loadConfig(localConfig);
24
+ if (!config)
25
+ return [];
41
26
  const basePath = config.basePath ?? '';
42
27
  if (config.files) {
43
28
  for (const fileOrPatternObj of config.files) {
@@ -52,17 +37,6 @@ const resolveEntryPaths = (localConfig, options) => {
52
37
  }
53
38
  return Array.from(inputs);
54
39
  };
55
- const loadConfig = (configFile) => {
56
- const inMemoryConfig = new InMemoryConfig();
57
- configFile(inMemoryConfig);
58
- return inMemoryConfig.config ?? {};
59
- };
60
- class InMemoryConfig {
61
- config;
62
- set(config) {
63
- this.config = config;
64
- }
65
- }
66
40
  export default {
67
41
  title,
68
42
  enablers,
@@ -10,7 +10,7 @@ const gitHookPaths = getGitHookPaths();
10
10
  const config = ['lefthook.yml', ...gitHookPaths];
11
11
  const resolveConfig = async (localConfig, options) => {
12
12
  const { manifest, configFileName, cwd, getInputsFromScripts } = options;
13
- const inputs = manifest.devDependencies ? Object.keys(manifest.devDependencies).map(toDependency) : [];
13
+ const inputs = manifest.devDependencies ? Object.keys(manifest.devDependencies).map(id => toDependency(id)) : [];
14
14
  if (extname(configFileName) === '.yml') {
15
15
  const scripts = findByKeyDeep(localConfig, 'run').flatMap(command => {
16
16
  const deps = getInputsFromScripts([command.run], { ...options, knownBinsOnly: true });
@@ -18,7 +18,7 @@ const resolveConfig = async (localConfig, options) => {
18
18
  return deps.flatMap(dependency => ({ ...dependency, dir }));
19
19
  });
20
20
  const lefthook = process.env.CI
21
- ? enablers.filter(dependency => inputs.some(d => d.specifier === dependency)).map(toDependency)
21
+ ? enablers.filter(dependency => inputs.some(d => d.specifier === dependency)).map(id => toDependency(id))
22
22
  : [];
23
23
  return [...scripts, ...lefthook];
24
24
  }
@@ -1,11 +1,11 @@
1
1
  import type { IsPluginEnabled, ResolveConfig } from '../../types/config.js';
2
- import type { PluginConfig } from './types.js';
2
+ import type { LintHTMLConfig } from './types.js';
3
3
  declare const _default: {
4
4
  title: string;
5
5
  enablers: string[];
6
6
  isEnabled: IsPluginEnabled;
7
7
  packageJsonPath: string;
8
8
  config: string[];
9
- resolveConfig: ResolveConfig<PluginConfig>;
9
+ resolveConfig: ResolveConfig<LintHTMLConfig>;
10
10
  };
11
11
  export default _default;
@@ -1,4 +1,4 @@
1
- export type PluginConfig = {
1
+ export type LintHTMLConfig = {
2
2
  extends?: string | string[];
3
3
  plugins?: string[];
4
4
  };
@@ -14,7 +14,7 @@ const resolveConfig = (config, options) => {
14
14
  const uses = scripts
15
15
  .filter(script => script.includes('markdownlint '))
16
16
  .flatMap(script => getArgumentValues(script, / (--rules|-r)[ =]([^ ]+)/g));
17
- return [...extend, ...uses].map(toDependency);
17
+ return [...extend, ...uses].map(id => toDependency(id));
18
18
  };
19
19
  export default {
20
20
  title,
@@ -0,0 +1,15 @@
1
+ import type { IsPluginEnabled, ResolveConfig, ResolveEntryPaths } from '../../types/config.js';
2
+ import type { MetroConfig } from './types.js';
3
+ export declare const docs: {
4
+ note: string;
5
+ production: string[];
6
+ };
7
+ declare const _default: {
8
+ title: string;
9
+ enablers: string[];
10
+ isEnabled: IsPluginEnabled;
11
+ config: string[];
12
+ resolveEntryPaths: ResolveEntryPaths<MetroConfig>;
13
+ resolveConfig: ResolveConfig<MetroConfig>;
14
+ };
15
+ export default _default;
@@ -0,0 +1,47 @@
1
+ import { compact } from '../../util/array.js';
2
+ import { toDeferResolve, toProductionEntry } from '../../util/input.js';
3
+ import { join } from '../../util/path.js';
4
+ import { hasDependency } from '../../util/plugin.js';
5
+ const title = 'Metro';
6
+ const enablers = ['metro', 'react-native'];
7
+ const isEnabled = options => hasDependency(options.dependencies, enablers);
8
+ const config = ['metro.config.{js,cjs,json}', 'package.json'];
9
+ const DEFAULT_PLATFORMS = ['ios', 'android', 'windows', 'web'];
10
+ const PLATFORMS = [...DEFAULT_PLATFORMS, 'native', 'default'];
11
+ const DEFAULT_EXTENSIONS = ['js', 'jsx', 'json', 'ts', 'tsx'];
12
+ const production = [`src/**/*.{${PLATFORMS.join(',')}}.{${DEFAULT_EXTENSIONS.join(',')}}`];
13
+ const resolveEntryPaths = async (config) => {
14
+ const platformEntryPatterns = compact(PLATFORMS.concat(config.resolver?.platforms ?? []));
15
+ const sourceExts = config.resolver?.sourceExts ?? DEFAULT_EXTENSIONS;
16
+ const pattern = `src/**/*.{${platformEntryPatterns.join(',')}}.{${sourceExts.join(',')}}`;
17
+ if (!config.projectRoot)
18
+ return [toProductionEntry(pattern)];
19
+ const entryFilePattern = 'index.{js,jsx,ts,tsx}';
20
+ const entryFilePath = join(config.projectRoot, entryFilePattern);
21
+ const entryFilePaths = join(config.projectRoot, pattern);
22
+ return [toProductionEntry(entryFilePath), toProductionEntry(entryFilePaths)];
23
+ };
24
+ const resolveConfig = async (config) => {
25
+ const { transformerPath, transformer } = config;
26
+ const inputs = [];
27
+ if (transformerPath)
28
+ inputs.push(transformerPath);
29
+ if (transformer?.assetPlugins)
30
+ inputs.push(...transformer.assetPlugins);
31
+ if (transformer?.minifierPath)
32
+ inputs.push(transformer.minifierPath);
33
+ if (transformer?.babelTransformerPath)
34
+ inputs.push(transformer.babelTransformerPath);
35
+ return [...inputs].map(toDeferResolve);
36
+ };
37
+ const note = `False positives for platform-specific unused files?
38
+ Override the entry patterns as shown below to match platforms and extensions.`;
39
+ export const docs = { note, production };
40
+ export default {
41
+ title,
42
+ enablers,
43
+ isEnabled,
44
+ config,
45
+ resolveEntryPaths,
46
+ resolveConfig,
47
+ };
@@ -0,0 +1,13 @@
1
+ export type MetroConfig = {
2
+ projectRoot?: string;
3
+ transformerPath?: string;
4
+ transformer?: {
5
+ minifierPath?: string;
6
+ assetPlugins?: string[];
7
+ babelTransformerPath?: string;
8
+ };
9
+ resolver?: {
10
+ platforms?: string[];
11
+ sourceExts?: string[];
12
+ };
13
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -6,7 +6,7 @@ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
6
6
  const config = ['nest-cli.json', '.nestcli.json', '.nest-cli.json', 'nest.json'];
7
7
  const resolveConfig = async (config) => {
8
8
  const inputs = config?.collection ? [config.collection] : [];
9
- return [...inputs].map(toDependency);
9
+ return [...inputs].map(id => toDependency(id));
10
10
  };
11
11
  export default {
12
12
  title,
@@ -19,8 +19,8 @@ const resolveEntryPaths = localConfig => {
19
19
  };
20
20
  const resolveConfig = async (localConfig) => {
21
21
  return [
22
- ...(localConfig?.plugins?.map(plugin => plugin.package) ?? []).map(toDependency),
23
- ...extractFunctionsConfigProperty(localConfig.functions || {}, 'external_node_modules').map(toDependency),
22
+ ...(localConfig?.plugins?.map(plugin => plugin.package) ?? []).map(id => toDependency(id)),
23
+ ...extractFunctionsConfigProperty(localConfig.functions || {}, 'external_node_modules').map(id => toDependency(id)),
24
24
  ];
25
25
  };
26
26
  export default {
@@ -7,7 +7,7 @@ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
7
7
  const packageJsonPath = 'npmpackagejsonlint';
8
8
  const config = ['package.json', ...toCosmiconfig('npmpackagejsonlint')];
9
9
  const resolveConfig = localConfig => {
10
- return localConfig?.extends ? [localConfig.extends].map(toDependency) : [];
10
+ return localConfig?.extends ? [localConfig.extends].map(id => toDependency(id)) : [];
11
11
  };
12
12
  export default {
13
13
  title,
@@ -1,8 +1,10 @@
1
1
  import type { IsPluginEnabled, ResolveEntryPaths } from '../../types/config.js';
2
2
  import type { NuxtConfig } from './types.js';
3
+ export declare const docs: {
4
+ note: string;
5
+ };
3
6
  declare const _default: {
4
7
  title: string;
5
- note: string;
6
8
  enablers: string[];
7
9
  isEnabled: IsPluginEnabled;
8
10
  entry: string[];
@@ -2,8 +2,6 @@ import { toProductionEntry } from '../../util/input.js';
2
2
  import { join } from '../../util/path.js';
3
3
  import { hasDependency } from '../../util/plugin.js';
4
4
  const title = 'Nuxt';
5
- const note = `Knip works best with [explicit imports](https://nuxt.com/docs/guide/concepts/auto-imports#explicit-imports).
6
- Nuxt allows to [disable auto-imports](https://nuxt.com/docs/guide/concepts/auto-imports#disabling-auto-imports).`;
7
5
  const enablers = ['nuxt'];
8
6
  const isEnabled = ({ dependencies }) => {
9
7
  const isEnabled = hasDependency(dependencies, enablers);
@@ -38,9 +36,11 @@ const resolveEntryPaths = async (localConfig) => {
38
36
  ];
39
37
  return patterns.map(pattern => toProductionEntry(join(srcDir, pattern)));
40
38
  };
39
+ const note = `Knip works best with [explicit imports](https://nuxt.com/docs/guide/concepts/auto-imports#explicit-imports).
40
+ Nuxt allows to [disable auto-imports](https://nuxt.com/docs/guide/concepts/auto-imports#disabling-auto-imports).`;
41
+ export const docs = { note };
41
42
  export default {
42
43
  title,
43
- note,
44
44
  enablers,
45
45
  isEnabled,
46
46
  entry,
@@ -21,7 +21,7 @@ const findNxDependenciesInNxJson = async (localConfig) => {
21
21
  .filter(value => value !== undefined)
22
22
  .map(value => value.split(':')[0])
23
23
  : [];
24
- return compact([...targetsDefault, ...plugins, ...generators]).map(toDependency);
24
+ return compact([...targetsDefault, ...plugins, ...generators]).map(id => toDependency(id));
25
25
  };
26
26
  const resolveConfig = async (localConfig, options) => {
27
27
  const { configFileName } = options;
@@ -35,8 +35,16 @@ const resolveConfig = async (localConfig, options) => {
35
35
  .filter(executor => executor && !executor.startsWith('.'))
36
36
  .map(executor => executor?.split(':')[0]);
37
37
  const scripts = targets
38
- .filter(target => target.executor === 'nx:run-commands')
39
- .flatMap(target => target.options?.commands ?? (target.options?.command ? [target.options.command] : []));
38
+ .filter(target => target.executor === 'nx:run-commands' || target.command)
39
+ .flatMap(target => {
40
+ if (target.command)
41
+ return [target.command];
42
+ if (target.options?.command)
43
+ return [target.options.command];
44
+ if (target.options?.commands)
45
+ return target.options.commands;
46
+ return [];
47
+ });
40
48
  const inputs = options.getInputsFromScripts(scripts);
41
49
  return compact([...executors, ...inputs]).map(id => (typeof id === 'string' ? toDependency(id) : id));
42
50
  };
@@ -1,6 +1,7 @@
1
1
  export interface NxProjectConfiguration {
2
2
  targets?: {
3
3
  [targetName: string]: {
4
+ command?: string;
4
5
  executor?: string;
5
6
  options?: {
6
7
  command?: string;
@@ -7,7 +7,7 @@ const config = ['package.json'];
7
7
  const resolveConfig = async (config) => {
8
8
  const plugins = config?.plugins ?? [];
9
9
  const devPlugins = config?.devPlugins ?? [];
10
- return [...plugins, ...devPlugins].map(toDependency);
10
+ return [...plugins, ...devPlugins].map(id => toDependency(id));
11
11
  };
12
12
  export default {
13
13
  title,
@@ -13,7 +13,7 @@ const resolveConfig = config => {
13
13
  if (typeof config === 'string')
14
14
  return [toDeferResolve(config)];
15
15
  return Array.isArray(config.plugins)
16
- ? config.plugins.filter((plugin) => typeof plugin === 'string').map(toDependency)
16
+ ? config.plugins.filter((plugin) => typeof plugin === 'string').map(id => toDependency(id))
17
17
  : [];
18
18
  };
19
19
  export default {
@@ -4,7 +4,6 @@ declare const _default: {
4
4
  title: string;
5
5
  enablers: string[];
6
6
  isEnabled: IsPluginEnabled;
7
- packageJsonPath: string;
8
7
  config: string[];
9
8
  resolveConfig: ResolveConfig<ReleaseItConfig>;
10
9
  };
@@ -3,7 +3,6 @@ import { hasDependency } from '../../util/plugin.js';
3
3
  const title = 'Release It!';
4
4
  const enablers = ['release-it'];
5
5
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
6
- const packageJsonPath = 'release-it';
7
6
  const config = ['.release-it.{json,js,cjs,ts,yml,yaml,toml}', 'package.json'];
8
7
  const resolveConfig = (config, options) => {
9
8
  const plugins = config.plugins ? Object.keys(config.plugins) : [];
@@ -15,13 +14,12 @@ const resolveConfig = (config, options) => {
15
14
  scripts.push(config.gitlab.releaseNotes);
16
15
  }
17
16
  const inputs = options.getInputsFromScripts(scripts);
18
- return [...plugins.map(toDependency), ...inputs];
17
+ return [...plugins.map(id => toDependency(id)), ...inputs];
19
18
  };
20
19
  export default {
21
20
  title,
22
21
  enablers,
23
22
  isEnabled,
24
- packageJsonPath,
25
23
  config,
26
24
  resolveConfig,
27
25
  };
@@ -7,9 +7,15 @@ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
7
7
  const isRootOnly = true;
8
8
  const packageJsonPath = 'release';
9
9
  const config = ['package.json', ...toCosmiconfig('release')];
10
+ const excludePackages = [
11
+ '@semantic-release/commit-analyzer',
12
+ '@semantic-release/github',
13
+ '@semantic-release/npm',
14
+ '@semantic-release/release-notes-generator',
15
+ ];
10
16
  const resolveConfig = config => {
11
17
  const plugins = (config?.plugins ?? []).map(plugin => (Array.isArray(plugin) ? plugin[0] : plugin));
12
- return plugins.map(toDeferResolve);
18
+ return plugins.filter(plugin => !excludePackages.includes(plugin)).map(toDeferResolve);
13
19
  };
14
20
  export default {
15
21
  title,
@@ -1,11 +1,10 @@
1
1
  import type { IsPluginEnabled, ResolveConfig } from '../../types/config.js';
2
- import type { PluginConfig } from './types.js';
2
+ import type { SimpleGitHooksConfig } from './types.js';
3
3
  declare const _default: {
4
4
  title: string;
5
5
  enablers: string[];
6
6
  isEnabled: IsPluginEnabled;
7
- packageJsonPath: string;
8
7
  config: string[];
9
- resolveConfig: ResolveConfig<PluginConfig>;
8
+ resolveConfig: ResolveConfig<SimpleGitHooksConfig>;
10
9
  };
11
10
  export default _default;
@@ -2,14 +2,7 @@ import { hasDependency } from '../../util/plugin.js';
2
2
  const title = 'simple-git-hooks';
3
3
  const enablers = ['simple-git-hooks'];
4
4
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
5
- const packageJsonPath = 'simple-git-hooks';
6
- const config = [
7
- '.simple-git-hooks.{js,cjs}',
8
- 'simple-git-hooks.{js,cjs}',
9
- '.simple-git-hooks.json',
10
- 'simple-git-hooks.json',
11
- 'package.json',
12
- ];
5
+ const config = ['.simple-git-hooks.{js,cjs,json}', 'simple-git-hooks.{js,cjs,json}', 'package.json'];
13
6
  const resolveConfig = async (config, options) => {
14
7
  if (typeof config === 'function')
15
8
  config = config();
@@ -26,7 +19,6 @@ export default {
26
19
  title,
27
20
  enablers,
28
21
  isEnabled,
29
- packageJsonPath,
30
22
  config,
31
23
  resolveConfig,
32
24
  };
@@ -1,3 +1,3 @@
1
1
  type Config = Record<string, string>;
2
- export type PluginConfig = Config | (() => Config);
2
+ export type SimpleGitHooksConfig = Config | (() => Config);
3
3
  export {};
@@ -30,7 +30,11 @@ const resolveConfig = async (localConfig) => {
30
30
  : [builder]
31
31
  : [];
32
32
  const frameworks = localConfig.framework?.name ? [localConfig.framework.name] : [];
33
- return [...addons.map(toDeferResolve), ...builderPackages.map(toDependency), ...frameworks.map(toDependency)];
33
+ return [
34
+ ...addons.map(toDeferResolve),
35
+ ...builderPackages.map(id => toDependency(id)),
36
+ ...frameworks.map(id => toDependency(id)),
37
+ ];
34
38
  };
35
39
  export default {
36
40
  title,
@@ -1,11 +1,13 @@
1
1
  import type { TsConfigJson } from 'type-fest';
2
2
  import type { IsPluginEnabled, ResolveConfig } from '../../types/config.js';
3
+ export declare const docs: {
4
+ note: string;
5
+ };
3
6
  declare const _default: {
4
7
  title: string;
5
8
  enablers: string[];
6
9
  isEnabled: IsPluginEnabled;
7
10
  config: string[];
8
- production: string[];
9
11
  resolveConfig: ResolveConfig<TsConfigJson>;
10
12
  args: {
11
13
  binaries: string[];
@@ -6,7 +6,6 @@ const title = 'TypeScript';
6
6
  const enablers = ['typescript'];
7
7
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
8
8
  const config = ['tsconfig.json'];
9
- const production = [];
10
9
  const resolveConfig = async (localConfig, options) => {
11
10
  const { compilerOptions } = localConfig;
12
11
  const extend = localConfig.extends
@@ -31,12 +30,13 @@ const args = {
31
30
  alias: { project: ['p'] },
32
31
  config: [['project', (p) => (p.endsWith('.json') ? p : join(p, 'tsconfig.json'))]],
33
32
  };
33
+ const note = '[What’s up with that configurable tsconfig.json location?](/reference/faq#whats-up-with-that-configurable-tsconfigjson-location)';
34
+ export const docs = { note };
34
35
  export default {
35
36
  title,
36
37
  enablers,
37
38
  isEnabled,
38
39
  config,
39
- production,
40
40
  resolveConfig,
41
41
  args,
42
42
  };
@@ -5,7 +5,6 @@ declare const _default: {
5
5
  enablers: string[];
6
6
  isEnabled: IsPluginEnabled;
7
7
  config: string[];
8
- production: string[];
9
8
  resolveEntryPaths: import("../../types/config.js").ResolveEntryPaths<import("../vitest/types.js").ViteConfigOrFn | import("../vitest/types.js").VitestWorkspaceConfig>;
10
9
  resolveConfig: import("../../types/config.js").ResolveConfig<import("../vitest/types.js").ViteConfigOrFn | import("../vitest/types.js").VitestWorkspaceConfig>;
11
10
  };
@@ -4,13 +4,11 @@ const title = 'Vite';
4
4
  const enablers = ['vite', 'vitest'];
5
5
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
6
6
  export const config = ['vite.config.{js,mjs,ts,cjs,mts,cts}'];
7
- const production = [];
8
7
  export default {
9
8
  title,
10
9
  enablers,
11
10
  isEnabled,
12
11
  config,
13
- production,
14
12
  resolveEntryPaths,
15
13
  resolveConfig,
16
14
  };
@@ -25,7 +25,7 @@ const findConfigDependencies = (localConfig, options) => {
25
25
  const dir = join(configFileDir, testConfig.root ?? '.');
26
26
  const setupFiles = [testConfig.setupFiles ?? []].flat().map(specifier => ({ ...toDeferResolve(specifier), dir }));
27
27
  const globalSetup = [testConfig.globalSetup ?? []].flat().map(specifier => ({ ...toDeferResolve(specifier), dir }));
28
- return [...[...environments, ...reporters, ...coverage].map(toDependency), ...setupFiles, ...globalSetup];
28
+ return [...[...environments, ...reporters, ...coverage].map(id => toDependency(id)), ...setupFiles, ...globalSetup];
29
29
  };
30
30
  const getConfigs = async (localConfig) => {
31
31
  const configs = [];
@@ -23,7 +23,7 @@ const resolveConfig = async (config) => {
23
23
  })
24
24
  .map(reporter => `@wdio/${reporter}-reporter`)
25
25
  : [];
26
- return [...frameworks, ...runners, ...reporters].map(toDependency);
26
+ return [...frameworks, ...runners, ...reporters].map(id => toDependency(id));
27
27
  };
28
28
  export default {
29
29
  title,
@@ -10,7 +10,10 @@ declare const _default: {
10
10
  enablers: string[];
11
11
  isEnabled: IsPluginEnabled;
12
12
  config: string[];
13
- production: string[];
14
13
  resolveConfig: ResolveConfig<WebpackConfig>;
14
+ args: {
15
+ binaries: string[];
16
+ config: boolean;
17
+ };
15
18
  };
16
19
  export default _default;
@@ -7,7 +7,6 @@ const title = 'webpack';
7
7
  const enablers = ['webpack', 'webpack-cli'];
8
8
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
9
9
  const config = ['webpack.config.{js,ts,mjs,cjs,mts,cts}'];
10
- const production = [];
11
10
  const hasBabelOptions = (use) => Boolean(use) &&
12
11
  typeof use !== 'string' &&
13
12
  'loader' in use &&
@@ -100,11 +99,15 @@ const resolveConfig = async (localConfig, options) => {
100
99
  const webpackDevServer = scripts.some(script => script?.includes('webpack serve')) ? ['webpack-dev-server'] : [];
101
100
  return compact([...inputs, [...webpackCLI, ...webpackDevServer].map(toDevDependency)].flat());
102
101
  };
102
+ const args = {
103
+ binaries: ['webpack', 'webpack-dev-server'],
104
+ config: true,
105
+ };
103
106
  export default {
104
107
  title,
105
108
  enablers,
106
109
  isEnabled,
107
110
  config,
108
- production,
109
111
  resolveConfig,
112
+ args,
110
113
  };
@@ -4,7 +4,6 @@ declare const _default: {
4
4
  title: string;
5
5
  enablers: string[];
6
6
  isEnabled: IsPluginEnabled;
7
- packageJsonPath: string;
8
7
  config: string[];
9
8
  resolveConfig: ResolveConfig<WireitConfig>;
10
9
  };
@@ -2,7 +2,6 @@ import { hasDependency } from '../../util/plugin.js';
2
2
  const title = 'Wireit';
3
3
  const enablers = ['wireit'];
4
4
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
5
- const packageJsonPath = 'wireit';
6
5
  const config = ['package.json'];
7
6
  const resolveConfig = (localConfig, options) => {
8
7
  const scripts = Object.values(localConfig).flatMap(({ command: script }) => (script ? [script] : []));
@@ -13,7 +12,6 @@ export default {
13
12
  title,
14
13
  enablers,
15
14
  isEnabled,
16
- packageJsonPath,
17
15
  config,
18
16
  resolveConfig,
19
17
  };
@@ -7,11 +7,20 @@ const dim = picocolors.gray;
7
7
  const bright = picocolors.whiteBright;
8
8
  const TRUNCATE_WIDTH = 40;
9
9
  const truncate = (text) => (text.length > TRUNCATE_WIDTH ? `${text.slice(0, TRUNCATE_WIDTH - 3)}...` : text);
10
+ const truncateStart = (text, width) => (text.length > width ? `...${text.slice(-(width - 3))}` : text);
11
+ const sortByPos = (a, b) => {
12
+ const [f, r, c] = a.filePath.split(':');
13
+ const [f2, r2, c2] = b.filePath.split(':');
14
+ return f === f2 ? (Number(r) === Number(r2) ? Number(c) - Number(c2) : Number(r) - Number(r2)) : f.localeCompare(f2);
15
+ };
10
16
  const hl = (issue) => {
11
17
  if (issue.specifier && issue.specifier !== issue.symbol && issue.specifier.includes(issue.symbol)) {
12
18
  const parts = issue.specifier.split(issue.symbol);
13
- const rest = parts.slice(1).join('');
14
- return [dim(parts[0]), bright(issue.symbol), dim(rest)].join('');
19
+ const right = parts.slice(1).join('');
20
+ const max = TRUNCATE_WIDTH - issue.symbol.length - right.length;
21
+ const part = parts[0];
22
+ const left = part.length > 3 ? (max <= 3 ? `...${part.slice(-3)}` : truncateStart(part, max)) : part;
23
+ return [dim(left), bright(issue.symbol), dim(right)].join('');
15
24
  }
16
25
  return issue.symbol;
17
26
  };
@@ -28,7 +37,7 @@ const logIssueRecord = (issues) => {
28
37
  issue.isFixed && table.cell('fixed', print('(removed)'));
29
38
  table.newRow();
30
39
  }
31
- console.log(table.sort(['filePath', 'parentSymbol', 'symbol']).print().trim());
40
+ console.log(table.sort(sortByPos).print().trim());
32
41
  };
33
42
  export default ({ report, issues, tagHints, configurationHints, noConfigHints, isShowProgress }) => {
34
43
  const reportMultipleGroups = Object.values(report).filter(Boolean).length > 1;