knip 5.9.0 → 5.9.2

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 (154) hide show
  1. package/dist/ConfigurationChief.d.ts +6 -6
  2. package/dist/ConfigurationChief.js +10 -8
  3. package/dist/ConsoleStreamer.js +1 -1
  4. package/dist/DependencyDeputy.d.ts +1 -1
  5. package/dist/DependencyDeputy.js +22 -18
  6. package/dist/IssueCollector.js +10 -9
  7. package/dist/IssueFixer.js +9 -7
  8. package/dist/PrincipalFactory.d.ts +2 -2
  9. package/dist/PrincipalFactory.js +3 -5
  10. package/dist/ProjectPrincipal.d.ts +6 -6
  11. package/dist/ProjectPrincipal.js +12 -10
  12. package/dist/WorkspaceWorker.d.ts +2 -2
  13. package/dist/WorkspaceWorker.js +13 -9
  14. package/dist/binaries/index.js +1 -1
  15. package/dist/binaries/resolvers/bun.js +1 -1
  16. package/dist/binaries/resolvers/index.d.ts +12 -12
  17. package/dist/binaries/util.js +1 -1
  18. package/dist/cli.js +10 -9
  19. package/dist/compilers/index.d.ts +1 -1
  20. package/dist/index.js +65 -57
  21. package/dist/issues/initializers.d.ts +1 -1
  22. package/dist/manifest/helpers.js +1 -1
  23. package/dist/manifest/index.d.ts +1 -1
  24. package/dist/manifest/index.js +4 -4
  25. package/dist/plugins/ava/index.js +8 -8
  26. package/dist/plugins/babel/index.js +2 -2
  27. package/dist/plugins/babel/types.d.ts +1 -1
  28. package/dist/plugins/babel/types.js +1 -1
  29. package/dist/plugins/commitlint/index.d.ts +1 -1
  30. package/dist/plugins/cspell/index.d.ts +1 -1
  31. package/dist/plugins/drizzle/index.d.ts +1 -1
  32. package/dist/plugins/eleventy/helpers.d.ts +0 -1
  33. package/dist/plugins/eleventy/helpers.js +1 -2
  34. package/dist/plugins/eleventy/index.d.ts +1 -1
  35. package/dist/plugins/eslint/helpers.d.ts +1 -1
  36. package/dist/plugins/eslint/helpers.js +5 -2
  37. package/dist/plugins/eslint/index.d.ts +0 -1
  38. package/dist/plugins/eslint/index.js +1 -1
  39. package/dist/plugins/github-actions/index.js +1 -1
  40. package/dist/plugins/graphql-codegen/index.d.ts +1 -1
  41. package/dist/plugins/jest/index.js +5 -4
  42. package/dist/plugins/lint-staged/index.d.ts +1 -1
  43. package/dist/plugins/lint-staged/index.js +2 -1
  44. package/dist/plugins/linthtml/index.d.ts +1 -1
  45. package/dist/plugins/markdownlint/index.d.ts +1 -1
  46. package/dist/plugins/npm-package-json-lint/index.d.ts +1 -1
  47. package/dist/plugins/nyc/index.d.ts +1 -1
  48. package/dist/plugins/playwright/index.d.ts +1 -1
  49. package/dist/plugins/playwright-ct/index.js +1 -1
  50. package/dist/plugins/postcss/index.d.ts +1 -1
  51. package/dist/plugins/prettier/index.d.ts +1 -1
  52. package/dist/plugins/release-it/index.d.ts +1 -1
  53. package/dist/plugins/remark/index.d.ts +1 -1
  54. package/dist/plugins/semantic-release/index.d.ts +1 -1
  55. package/dist/plugins/stryker/index.d.ts +1 -1
  56. package/dist/plugins/stylelint/index.d.ts +1 -1
  57. package/dist/plugins/tsup/index.d.ts +1 -1
  58. package/dist/plugins/typescript/index.d.ts +0 -1
  59. package/dist/plugins/typescript/index.js +4 -3
  60. package/dist/plugins/unbuild/index.d.ts +1 -1
  61. package/dist/plugins/vite/index.d.ts +2 -2
  62. package/dist/plugins/vite/index.js +1 -1
  63. package/dist/plugins/vitest/index.d.ts +1 -1
  64. package/dist/plugins/vitest/index.js +8 -4
  65. package/dist/plugins/vue/index.d.ts +1 -1
  66. package/dist/plugins/vue/index.js +2 -1
  67. package/dist/plugins/vue/types.d.ts +1 -1
  68. package/dist/plugins/webpack/index.js +4 -4
  69. package/dist/plugins/wireit/index.d.ts +1 -1
  70. package/dist/plugins/yorkie/index.d.ts +1 -1
  71. package/dist/plugins/yorkie/index.js +2 -1
  72. package/dist/plugins.d.ts +1 -1
  73. package/dist/plugins.js +6 -3
  74. package/dist/reporters/codeowners.js +9 -7
  75. package/dist/reporters/compact.js +1 -1
  76. package/dist/reporters/index.d.ts +5 -5
  77. package/dist/reporters/json.js +3 -3
  78. package/dist/reporters/markdown.js +7 -7
  79. package/dist/reporters/symbols.js +8 -8
  80. package/dist/reporters/util.js +3 -2
  81. package/dist/types/config.d.ts +5 -5
  82. package/dist/types/config.js +1 -3
  83. package/dist/types/exports.d.ts +1 -1
  84. package/dist/types/exports.js +1 -1
  85. package/dist/types/imports.d.ts +1 -1
  86. package/dist/types/imports.js +1 -1
  87. package/dist/typescript/SourceFile.d.ts +1 -1
  88. package/dist/typescript/SourceFile.js +1 -1
  89. package/dist/typescript/SourceFileManager.d.ts +1 -1
  90. package/dist/typescript/ast-helpers.js +2 -2
  91. package/dist/typescript/createHosts.d.ts +1 -1
  92. package/dist/typescript/createHosts.js +1 -1
  93. package/dist/typescript/getImportsAndExports.d.ts +1 -1
  94. package/dist/typescript/getImportsAndExports.js +15 -12
  95. package/dist/typescript/resolveModuleNames.js +2 -2
  96. package/dist/typescript/visitors/dynamic-imports/importCall.d.ts +1 -1
  97. package/dist/typescript/visitors/dynamic-imports/importCall.js +24 -30
  98. package/dist/typescript/visitors/dynamic-imports/importType.d.ts +1 -1
  99. package/dist/typescript/visitors/dynamic-imports/index.d.ts +2 -2
  100. package/dist/typescript/visitors/dynamic-imports/index.js +0 -1
  101. package/dist/typescript/visitors/dynamic-imports/jsDocType.d.ts +1 -1
  102. package/dist/typescript/visitors/dynamic-imports/propertyAccessCall.d.ts +1 -1
  103. package/dist/typescript/visitors/dynamic-imports/requireCall.d.ts +1 -1
  104. package/dist/typescript/visitors/dynamic-imports/requireCall.js +14 -22
  105. package/dist/typescript/visitors/exports/exportAssignment.d.ts +1 -1
  106. package/dist/typescript/visitors/exports/exportDeclaration.d.ts +1 -1
  107. package/dist/typescript/visitors/exports/exportKeyword.d.ts +1 -1
  108. package/dist/typescript/visitors/exports/exportKeyword.js +10 -12
  109. package/dist/typescript/visitors/exports/exportsAccessExpression.d.ts +1 -1
  110. package/dist/typescript/visitors/exports/index.d.ts +2 -2
  111. package/dist/typescript/visitors/exports/index.js +0 -1
  112. package/dist/typescript/visitors/exports/moduleExportsAccessExpression.d.ts +1 -1
  113. package/dist/typescript/visitors/exports/moduleExportsAccessExpression.js +2 -4
  114. package/dist/typescript/visitors/imports/importDeclaration.d.ts +1 -1
  115. package/dist/typescript/visitors/imports/importDeclaration.js +18 -20
  116. package/dist/typescript/visitors/imports/importEqualsDeclaration.d.ts +1 -1
  117. package/dist/typescript/visitors/imports/index.d.ts +2 -2
  118. package/dist/typescript/visitors/imports/index.js +0 -1
  119. package/dist/typescript/visitors/imports/reExportDeclaration.d.ts +1 -1
  120. package/dist/typescript/visitors/imports/reExportDeclaration.js +14 -16
  121. package/dist/typescript/visitors/index.d.ts +1 -1
  122. package/dist/typescript/visitors/index.js +0 -1
  123. package/dist/typescript/visitors/scripts/bun.d.ts +1 -1
  124. package/dist/typescript/visitors/scripts/execa.d.ts +1 -1
  125. package/dist/typescript/visitors/scripts/index.d.ts +2 -2
  126. package/dist/typescript/visitors/scripts/index.js +0 -1
  127. package/dist/typescript/visitors/scripts/zx.d.ts +1 -1
  128. package/dist/util/Performance.d.ts +1 -1
  129. package/dist/util/Performance.js +5 -5
  130. package/dist/util/cli-arguments.js +1 -1
  131. package/dist/util/debug.js +1 -1
  132. package/dist/util/fs.d.ts +2 -2
  133. package/dist/util/fs.js +3 -3
  134. package/dist/util/get-included-issue-types.js +8 -5
  135. package/dist/util/get-reexporting-entry-file.js +12 -16
  136. package/dist/util/git.js +5 -5
  137. package/dist/util/glob.js +2 -2
  138. package/dist/util/globby.d.ts +1 -1
  139. package/dist/util/globby.js +11 -12
  140. package/dist/util/handle-dependency.d.ts +1 -1
  141. package/dist/util/handle-dependency.js +1 -2
  142. package/dist/util/is-identifier-referenced.js +4 -4
  143. package/dist/util/loader.js +3 -5
  144. package/dist/util/modules.js +7 -5
  145. package/dist/util/object.js +1 -1
  146. package/dist/util/plugin.d.ts +1 -1
  147. package/dist/util/plugin.js +12 -14
  148. package/dist/util/regex.js +1 -1
  149. package/dist/util/require.js +2 -2
  150. package/dist/util/tag.js +4 -2
  151. package/dist/util/type.js +2 -2
  152. package/dist/version.d.ts +1 -1
  153. package/dist/version.js +1 -1
  154. package/package.json +15 -23
@@ -19,7 +19,8 @@ const resolveConfig = async (config, options) => {
19
19
  const dependencies = new Set();
20
20
  for (const entry of Object.values(config).flat()) {
21
21
  const scripts = [typeof entry === 'function' ? await entry([]) : entry].flat();
22
- getDependenciesFromScripts(scripts, options).forEach(identifier => dependencies.add(identifier));
22
+ for (const id of getDependenciesFromScripts(scripts, options))
23
+ dependencies.add(id);
23
24
  }
24
25
  return Array.from(dependencies);
25
26
  };
@@ -1,4 +1,4 @@
1
- import type { ResolveConfig, IsPluginEnabled } from '#p/types/plugins.js';
1
+ import type { IsPluginEnabled, ResolveConfig } from '#p/types/plugins.js';
2
2
  import type { PluginConfig } from './types.js';
3
3
  declare const _default: {
4
4
  title: string;
@@ -1,4 +1,4 @@
1
- import type { ResolveConfig, IsPluginEnabled } from '#p/types/plugins.js';
1
+ import type { IsPluginEnabled, ResolveConfig } from '#p/types/plugins.js';
2
2
  import type { MarkdownlintConfig } from './types.js';
3
3
  declare const _default: {
4
4
  title: string;
@@ -1,4 +1,4 @@
1
- import type { ResolveConfig, IsPluginEnabled } from '#p/types/plugins.js';
1
+ import type { IsPluginEnabled, ResolveConfig } from '#p/types/plugins.js';
2
2
  import type { NpmPkgJsonLintConfig } from './types.js';
3
3
  declare const _default: {
4
4
  title: string;
@@ -1,4 +1,4 @@
1
- import type { ResolveConfig, IsPluginEnabled } from '#p/types/plugins.js';
1
+ import type { IsPluginEnabled, ResolveConfig } from '#p/types/plugins.js';
2
2
  import type { NycConfig } from './types.js';
3
3
  declare const _default: {
4
4
  title: string;
@@ -1,5 +1,5 @@
1
- import type { IsPluginEnabled, ResolveEntryPaths, ResolveConfig } from '#p/types/plugins.js';
2
1
  import type { PlaywrightTestConfig } from 'playwright/test';
2
+ import type { IsPluginEnabled, ResolveConfig, ResolveEntryPaths } from '#p/types/plugins.js';
3
3
  export declare const entry: string[];
4
4
  export declare const resolveEntryPaths: ResolveEntryPaths<PlaywrightTestConfig>;
5
5
  export declare const resolveConfig: ResolveConfig<PlaywrightTestConfig>;
@@ -1,5 +1,5 @@
1
1
  import { hasDependency } from '#p/util/plugin.js';
2
- import { resolveConfig, entry, resolveEntryPaths } from '../playwright/index.js';
2
+ import { entry, resolveConfig, resolveEntryPaths } from '../playwright/index.js';
3
3
  const title = 'Playwright for components';
4
4
  const enablers = [/^@playwright\/experimental-ct-/];
5
5
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
@@ -1,4 +1,4 @@
1
- import type { ResolveConfig, IsPluginEnabled } from '#p/types/plugins.js';
1
+ import type { IsPluginEnabled, ResolveConfig } from '#p/types/plugins.js';
2
2
  import type { PostCSSConfig } from './types.js';
3
3
  declare const _default: {
4
4
  title: string;
@@ -1,4 +1,4 @@
1
- import type { ResolveConfig, IsPluginEnabled } from '#p/types/plugins.js';
1
+ import type { IsPluginEnabled, ResolveConfig } from '#p/types/plugins.js';
2
2
  import type { PrettierConfig } from './types.js';
3
3
  declare const _default: {
4
4
  title: string;
@@ -1,4 +1,4 @@
1
- import type { ResolveConfig, IsPluginEnabled } from '#p/types/plugins.js';
1
+ import type { IsPluginEnabled, ResolveConfig } from '#p/types/plugins.js';
2
2
  import type { ReleaseItConfig } from './types.js';
3
3
  declare const _default: {
4
4
  title: string;
@@ -1,4 +1,4 @@
1
- import type { ResolveConfig, IsPluginEnabled } from '#p/types/plugins.js';
1
+ import type { IsPluginEnabled, ResolveConfig } from '#p/types/plugins.js';
2
2
  import type { RemarkConfig } from './types.js';
3
3
  declare const _default: {
4
4
  title: string;
@@ -1,4 +1,4 @@
1
- import type { ResolveConfig, IsPluginEnabled } from '#p/types/plugins.js';
1
+ import type { IsPluginEnabled, ResolveConfig } from '#p/types/plugins.js';
2
2
  import type { SemanticReleaseConfig } from './types.js';
3
3
  declare const _default: {
4
4
  title: string;
@@ -1,4 +1,4 @@
1
- import type { ResolveConfig, IsPluginEnabled } from '#p/types/plugins.js';
1
+ import type { IsPluginEnabled, ResolveConfig } from '#p/types/plugins.js';
2
2
  import type { StrykerConfig } from './types.js';
3
3
  declare const _default: {
4
4
  title: string;
@@ -1,4 +1,4 @@
1
- import type { ResolveConfig, IsPluginEnabled } from '#p/types/plugins.js';
1
+ import type { IsPluginEnabled, ResolveConfig } from '#p/types/plugins.js';
2
2
  import type { StyleLintConfig } from './types.js';
3
3
  declare const _default: {
4
4
  title: string;
@@ -1,4 +1,4 @@
1
- import type { ResolveConfig, IsPluginEnabled } from '#p/types/plugins.js';
1
+ import type { IsPluginEnabled, ResolveConfig } from '#p/types/plugins.js';
2
2
  import type { TsupConfig } from './types.js';
3
3
  declare const _default: {
4
4
  title: string;
@@ -1,5 +1,4 @@
1
1
  import type { IsPluginEnabled, ResolveConfig } from '#p/types/plugins.js';
2
- export declare const resolveConfig: ResolveConfig;
3
2
  declare const _default: {
4
3
  title: string;
5
4
  enablers: string[];
@@ -19,15 +19,16 @@ const getExtends = async (configFilePath, internalExtends = new Set()) => {
19
19
  await getExtends(presetConfigPath, internalExtends);
20
20
  }
21
21
  }
22
- extends_.forEach(extend => internalExtends.add(extend));
22
+ for (const extend of extends_)
23
+ internalExtends.add(extend);
23
24
  return internalExtends;
24
25
  };
25
- export const resolveConfig = async (localConfig, options) => {
26
+ const resolveConfig = async (localConfig, options) => {
26
27
  const { isProduction, configFileDir, configFileName } = options;
27
28
  const configFilePath = join(configFileDir, configFileName);
28
29
  const { compilerOptions } = await loadTSConfig(configFilePath);
29
30
  const extend = await getExtends(configFilePath);
30
- if (!compilerOptions || !localConfig)
31
+ if (!(compilerOptions && localConfig))
31
32
  return [];
32
33
  const jsx = compilerOptions?.jsxImportSource ? [compilerOptions.jsxImportSource] : [];
33
34
  if (isProduction)
@@ -1,4 +1,4 @@
1
- import type { ResolveConfig, IsPluginEnabled } from '#p/types/plugins.js';
1
+ import type { IsPluginEnabled, ResolveConfig } from '#p/types/plugins.js';
2
2
  import type { UnbuildConfig } from './types.js';
3
3
  declare const _default: {
4
4
  title: string;
@@ -6,7 +6,7 @@ declare const _default: {
6
6
  isEnabled: IsPluginEnabled;
7
7
  config: string[];
8
8
  production: string[];
9
- resolveEntryPaths: import("#p/types/plugins.js").ResolveEntryPaths<import("#p/plugins/vitest/types.ts").ViteConfigOrFn | import("#p/plugins/vitest/types.ts").VitestWorkspaceConfig>;
10
- resolveConfig: import("#p/types/plugins.js").ResolveConfig<import("#p/plugins/vitest/types.ts").ViteConfigOrFn | import("#p/plugins/vitest/types.ts").VitestWorkspaceConfig>;
9
+ resolveEntryPaths: import("#p/types/plugins.js").ResolveEntryPaths<import("../vitest/types.js").ViteConfigOrFn | import("../vitest/types.js").VitestWorkspaceConfig>;
10
+ resolveConfig: import("#p/types/plugins.js").ResolveConfig<import("../vitest/types.js").ViteConfigOrFn | import("../vitest/types.js").VitestWorkspaceConfig>;
11
11
  };
12
12
  export default _default;
@@ -1,5 +1,5 @@
1
1
  import { hasDependency } from '#p/util/plugin.js';
2
- import { resolveEntryPaths, resolveConfig } from '../vitest/index.js';
2
+ import { resolveConfig, resolveEntryPaths } from '../vitest/index.js';
3
3
  const title = 'Vite';
4
4
  const enablers = ['vite'];
5
5
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
@@ -1,4 +1,4 @@
1
- import type { IsPluginEnabled, ResolveEntryPaths, ResolveConfig } from '#p/types/plugins.js';
1
+ import type { IsPluginEnabled, ResolveConfig, ResolveEntryPaths } from '#p/types/plugins.js';
2
2
  import type { ViteConfigOrFn, VitestWorkspaceConfig } from './types.js';
3
3
  export declare const resolveEntryPaths: ResolveEntryPaths<ViteConfigOrFn | VitestWorkspaceConfig>;
4
4
  export declare const resolveConfig: ResolveConfig<ViteConfigOrFn | VitestWorkspaceConfig>;
@@ -59,10 +59,12 @@ export const resolveEntryPaths = async (localConfig, options) => {
59
59
  const configs = await getConfigs(localConfig);
60
60
  for (const cfg of configs) {
61
61
  if (cfg.test?.include) {
62
- cfg.test.include.forEach(dependency => dependencies.add(dependency));
62
+ for (const dependency of cfg.test.include)
63
+ dependencies.add(dependency);
63
64
  }
64
65
  else {
65
- (options.config.entry ?? entry).forEach(dependency => dependencies.add(dependency));
66
+ for (const dependency of options.config.entry ?? entry)
67
+ dependencies.add(dependency);
66
68
  }
67
69
  }
68
70
  return Array.from(dependencies).map(toEntryPattern);
@@ -71,10 +73,12 @@ export const resolveConfig = async (localConfig, options) => {
71
73
  const dependencies = new Set();
72
74
  const configs = await getConfigs(localConfig);
73
75
  for (const cfg of configs) {
74
- findConfigDependencies(cfg, options).forEach(dependency => dependencies.add(dependency));
76
+ for (const dependency of findConfigDependencies(cfg, options))
77
+ dependencies.add(dependency);
75
78
  const entry = cfg.build?.lib?.entry ?? [];
76
79
  const deps = (typeof entry === 'string' ? [entry] : Object.values(entry)).map(specifier => resolveEntry(options, specifier));
77
- deps.forEach(dependency => dependencies.add(dependency));
80
+ for (const dependency of deps)
81
+ dependencies.add(dependency);
78
82
  }
79
83
  return Array.from(dependencies);
80
84
  };
@@ -1,4 +1,4 @@
1
- import type { ResolveConfig, IsPluginEnabled } from '#p/types/plugins.js';
1
+ import type { IsPluginEnabled, ResolveConfig } from '#p/types/plugins.js';
2
2
  import type { VueConfig } from './types.js';
3
3
  declare const _default: {
4
4
  title: string;
@@ -20,7 +20,8 @@ const resolveConfig = async (config, options) => {
20
20
  config: modifiedConfig ?? baseConfig,
21
21
  cwd,
22
22
  });
23
- dependencies.forEach(dependency => deps.push(dependency));
23
+ for (const dependency of dependencies)
24
+ deps.push(dependency);
24
25
  }
25
26
  if (!isProduction &&
26
27
  manifest.scripts &&
@@ -1,5 +1,5 @@
1
1
  import type { Configuration } from 'webpack';
2
2
  export type VueConfig = {
3
- configureWebpack?: Configuration | ((config: Configuration) => Configuration | void);
3
+ configureWebpack?: Configuration | ((config: Configuration) => Configuration | undefined);
4
4
  };
5
5
  export type { Configuration as WebpackConfiguration };
@@ -62,7 +62,7 @@ export const findWebpackDependenciesFromConfig = async ({ config, cwd }) => {
62
62
  else if (Array.isArray(options.entry))
63
63
  entries.push(...options.entry);
64
64
  else if (typeof options.entry === 'object') {
65
- Object.values(options.entry).forEach(entry => {
65
+ for (const entry of Object.values(options.entry)) {
66
66
  if (typeof entry === 'string')
67
67
  entries.push(entry);
68
68
  else if (Array.isArray(entry))
@@ -71,9 +71,9 @@ export const findWebpackDependenciesFromConfig = async ({ config, cwd }) => {
71
71
  entries.push(entry());
72
72
  else if (entry && typeof entry === 'object' && 'filename' in entry)
73
73
  entries.push(entry['filename']);
74
- });
74
+ }
75
75
  }
76
- entries.forEach(entry => {
76
+ for (const entry of entries) {
77
77
  if (!isInternal(entry)) {
78
78
  dependencies.add(entry);
79
79
  }
@@ -82,7 +82,7 @@ export const findWebpackDependenciesFromConfig = async ({ config, cwd }) => {
82
82
  const value = options.mode === 'development' ? toEntryPattern(item) : toProductionEntryPattern(item);
83
83
  entryPatterns.add(value);
84
84
  }
85
- });
85
+ }
86
86
  }
87
87
  }
88
88
  return { dependencies, entryPatterns };
@@ -1,4 +1,4 @@
1
- import type { ResolveConfig, IsPluginEnabled } from '#p/types/plugins.js';
1
+ import type { IsPluginEnabled, ResolveConfig } from '#p/types/plugins.js';
2
2
  import type { WireitConfig } from './types.js';
3
3
  declare const _default: {
4
4
  title: string;
@@ -1,4 +1,4 @@
1
- import type { ResolveConfig, IsPluginEnabled } from '#p/types/plugins.js';
1
+ import type { IsPluginEnabled, ResolveConfig } from '#p/types/plugins.js';
2
2
  import type { LintStagedConfig } from '../lint-staged/types.js';
3
3
  declare const _default: {
4
4
  title: string;
@@ -8,7 +8,8 @@ const resolveConfig = (config, options) => {
8
8
  const dependencies = new Set();
9
9
  for (const script of Object.values(config).flat()) {
10
10
  const scripts = [script].flat();
11
- getDependenciesFromScripts(scripts, options).forEach(identifier => dependencies.add(identifier));
11
+ for (const identifier of getDependenciesFromScripts(scripts, options))
12
+ dependencies.add(identifier);
12
13
  }
13
14
  return ['yorkie', ...dependencies];
14
15
  };
package/dist/plugins.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import type { Plugin } from './types/plugins.js';
2
- declare const plugins: Record<"astro" | "svelte" | "vue" | "moonrepo" | "angular" | "ava" | "babel" | "capacitor" | "changesets" | "commitizen" | "commitlint" | "cspell" | "cypress" | "eleventy" | "eslint" | "gatsby" | "husky" | "jest" | "lefthook" | "linthtml" | "markdownlint" | "mocha" | "msw" | "netlify" | "next" | "nx" | "nyc" | "playwright" | "postcss" | "prettier" | "remark" | "remix" | "rollup" | "sentry" | "storybook" | "stryker" | "stylelint" | "tailwind" | "tsup" | "typedoc" | "typescript" | "unbuild" | "vite" | "vitest" | "webpack" | "wireit" | "wrangler" | "yorkie" | "drizzle" | "githubActions" | "graphqlCodegen" | "lintStaged" | "nodeTestRunner" | "npmPackageJsonLint" | "playwrightCt" | "releaseIt" | "semanticRelease" | "vercelOg", Plugin>;
2
+ declare const plugins: Record<"moonrepo" | "astro" | "angular" | "ava" | "babel" | "capacitor" | "changesets" | "commitizen" | "commitlint" | "cspell" | "cypress" | "eleventy" | "eslint" | "gatsby" | "husky" | "jest" | "lefthook" | "linthtml" | "markdownlint" | "mocha" | "msw" | "netlify" | "next" | "nx" | "nyc" | "playwright" | "postcss" | "prettier" | "remark" | "remix" | "rollup" | "sentry" | "storybook" | "stryker" | "stylelint" | "svelte" | "tailwind" | "tsup" | "typedoc" | "typescript" | "unbuild" | "vue" | "vite" | "vitest" | "webpack" | "wireit" | "wrangler" | "yorkie" | "drizzle" | "githubActions" | "graphqlCodegen" | "lintStaged" | "nodeTestRunner" | "npmPackageJsonLint" | "playwrightCt" | "releaseIt" | "semanticRelease" | "vercelOg", Plugin>;
3
3
  export { plugins };
package/dist/plugins.js CHANGED
@@ -1,14 +1,17 @@
1
1
  import * as originalPlugins from './plugins/index.js';
2
- import parsedArgValues from './util/cli-arguments.js';
3
2
  import { timerify } from './util/Performance.js';
3
+ import parsedArgValues from './util/cli-arguments.js';
4
4
  const { performance: isEnabled = false } = parsedArgValues;
5
5
  const plugins = (isEnabled ? {} : originalPlugins);
6
6
  const methods = ['resolve', 'resolveConfig', 'resolveEntryPaths'];
7
7
  if (isEnabled) {
8
8
  for (const [name, plugin] of Object.entries(originalPlugins)) {
9
9
  plugins[name] = plugin;
10
- methods.forEach(method => method in plugin &&
11
- (plugins[name][method] = timerify(plugin[method], `${method} (${plugin.title})`)));
10
+ for (const method of methods) {
11
+ if (method in plugin) {
12
+ plugins[name][method] = timerify(plugin[method], `${method} (${plugin.title})`);
13
+ }
14
+ }
12
15
  }
13
16
  }
14
17
  export { plugins };
@@ -1,15 +1,17 @@
1
1
  import { OwnershipEngine } from '@snyk/github-codeowners/dist/lib/ownership/index.js';
2
2
  import picocolors from 'picocolors';
3
- import { toRelative, relative, resolve } from '../util/path.js';
4
- import { getTitle, logTitle, logIssueLine } from './util.js';
3
+ import { relative, resolve, toRelative } from '../util/path.js';
4
+ import { getTitle, logIssueLine, logTitle } from './util.js';
5
5
  const logIssueSet = (issues) => {
6
- issues
7
- .sort((a, b) => (a.owner < b.owner ? -1 : 1))
8
- .forEach(issue => console.log(picocolors.cyan(issue.owner), toRelative(issue.symbol)));
6
+ for (const issue of issues.sort((a, b) => (a.owner < b.owner ? -1 : 1))) {
7
+ console.log(picocolors.cyan(issue.owner), toRelative(issue.symbol));
8
+ }
9
9
  };
10
10
  const logIssueRecord = (issues) => {
11
11
  const sortedByFilePath = issues.sort((a, b) => (a.owner < b.owner ? -1 : 1));
12
- sortedByFilePath.forEach(({ filePath, symbols, owner, parentSymbol }) => logIssueLine({ owner, filePath, symbols, parentSymbol }));
12
+ for (const { filePath, symbols, owner, parentSymbol } of sortedByFilePath) {
13
+ logIssueLine({ owner, filePath, symbols, parentSymbol });
14
+ }
13
15
  };
14
16
  export default ({ report, issues, isShowProgress, options }) => {
15
17
  let opts = {};
@@ -37,7 +39,7 @@ export default ({ report, issues, isShowProgress, options }) => {
37
39
  .map(toIssue)
38
40
  .map(addOwner)
39
41
  : reportType === 'duplicates'
40
- ? Object.values(issues[reportType]).map(Object.values).flat().map(addOwner)
42
+ ? Object.values(issues[reportType]).flatMap(Object.values).map(addOwner)
41
43
  : Object.values(issues[reportType]).map(issues => {
42
44
  const symbols = Object.values(issues);
43
45
  return addOwner({ ...symbols[0], symbols });
@@ -1,4 +1,4 @@
1
- import { getTitle, logTitle, logIssueLine, logIssueSet } from './util.js';
1
+ import { getTitle, logIssueLine, logIssueSet, logTitle } from './util.js';
2
2
  const logIssueRecord = (issues) => {
3
3
  const sortedByFilePath = issues.sort((a, b) => (a.filePath > b.filePath ? 1 : -1));
4
4
  sortedByFilePath.forEach(logIssueLine);
@@ -1,8 +1,8 @@
1
1
  declare const _default: {
2
- symbols: ({ report, issues, configurationHints, noConfigHints, isShowProgress }: import("#p/index.ts").ReporterOptions) => void;
3
- compact: ({ report, issues, isShowProgress }: import("#p/index.ts").ReporterOptions) => void;
4
- codeowners: ({ report, issues, isShowProgress, options }: import("#p/index.ts").ReporterOptions) => void;
5
- json: ({ report, issues, options }: import("#p/index.ts").ReporterOptions) => Promise<void>;
6
- markdown: ({ report, issues }: import("#p/index.ts").ReporterOptions) => void;
2
+ symbols: ({ report, issues, configurationHints, noConfigHints, isShowProgress }: import("../index.js").ReporterOptions) => void;
3
+ compact: ({ report, issues, isShowProgress }: import("../index.js").ReporterOptions) => void;
4
+ codeowners: ({ report, issues, isShowProgress, options }: import("../index.js").ReporterOptions) => void;
5
+ json: ({ report, issues, options }: import("../index.js").ReporterOptions) => Promise<void>;
6
+ markdown: ({ report, issues }: import("../index.js").ReporterOptions) => void;
7
7
  };
8
8
  export default _default;
@@ -40,7 +40,7 @@ export default async ({ report, issues, options }) => {
40
40
  if (type === 'files') {
41
41
  }
42
42
  else {
43
- flatten(issues[type]).forEach(issue => {
43
+ for (const issue of flatten(issues[type])) {
44
44
  const { filePath, symbol, symbols, parentSymbol } = issue;
45
45
  json[filePath] = json[filePath] ?? initRow(filePath);
46
46
  if (type === 'duplicates') {
@@ -61,7 +61,7 @@ export default async ({ report, issues, options }) => {
61
61
  json[filePath][type]?.push({ name: symbol });
62
62
  }
63
63
  }
64
- });
64
+ }
65
65
  }
66
66
  }
67
67
  }
@@ -70,5 +70,5 @@ export default async ({ report, issues, options }) => {
70
70
  issues: Object.values(json),
71
71
  });
72
72
  process.stdout._handle?.setBlocking?.(true);
73
- process.stdout.write(output + '\n');
73
+ process.stdout.write(`${output}\n`);
74
74
  };
@@ -3,7 +3,7 @@ import { getTitle } from './util.js';
3
3
  export default ({ report, issues }) => {
4
4
  console.log('# Knip report\n');
5
5
  const getFilePath = (issue) => {
6
- if (!issue.line || !issue.col)
6
+ if (!(issue.line && issue.col))
7
7
  return relative(issue.filePath);
8
8
  return `${relative(issue.filePath)}:${issue.line}:${issue.col}`;
9
9
  };
@@ -15,23 +15,23 @@ export default ({ report, issues }) => {
15
15
  const isSet = issues[reportType] instanceof Set;
16
16
  const issuesForType = isSet
17
17
  ? Array.from(issues[reportType])
18
- : Object.values(issues[reportType]).map(Object.values).flat();
18
+ : Object.values(issues[reportType]).flatMap(Object.values);
19
19
  if (issuesForType.length > 0) {
20
20
  console.log(`## ${title} (${issuesForType.length})\n`);
21
21
  if (isSet) {
22
- issuesForType.sort().forEach((issue) => {
22
+ for (const issue of issuesForType.sort()) {
23
23
  console.log(`* ${toRelative(issue)}`);
24
- });
24
+ }
25
25
  }
26
26
  else {
27
27
  const longestSymbol = issuesForType.sort(sortLongestSymbol)[0].symbol.length;
28
28
  const sortedByFilePath = issuesForType.sort(sortLongestFilePath);
29
29
  const longestFilePath = getFilePath(sortedByFilePath[0]).length;
30
- console.log(`| ${`Name`.padEnd(longestSymbol)} | ${`Location`.padEnd(longestFilePath)} | Severity |`);
30
+ console.log(`| ${'Name'.padEnd(longestSymbol)} | ${'Location'.padEnd(longestFilePath)} | Severity |`);
31
31
  console.log(`| :${'-'.repeat(longestSymbol - 1)} | :${'-'.repeat(longestFilePath - 1)} | :------- |`);
32
- sortedByFilePath.forEach((issue) => {
32
+ for (const issue of sortedByFilePath) {
33
33
  console.log(`| ${issue.symbol.padEnd(longestSymbol)} | ${getFilePath(issue).padEnd(longestFilePath)} | ${(issue.severity ?? '').padEnd(8)} |`);
34
- });
34
+ }
35
35
  }
36
36
  console.log('');
37
37
  }
@@ -2,12 +2,12 @@ import EasyTable from 'easy-table';
2
2
  import picocolors from 'picocolors';
3
3
  import { ROOT_WORKSPACE_NAME } from '../constants.js';
4
4
  import { relative } from '../util/path.js';
5
- import { getTitle, logTitle, logIssueSet, identity } from './util.js';
5
+ import { getTitle, identity, logIssueSet, logTitle } from './util.js';
6
6
  const TRUNCATE_WIDTH = 40;
7
- const truncate = (text) => (text.length > TRUNCATE_WIDTH ? text.slice(0, TRUNCATE_WIDTH - 3) + '...' : text);
7
+ const truncate = (text) => (text.length > TRUNCATE_WIDTH ? `${text.slice(0, TRUNCATE_WIDTH - 3)}...` : text);
8
8
  const logIssueRecord = (issues) => {
9
9
  const table = new EasyTable();
10
- issues.forEach(issue => {
10
+ for (const issue of issues) {
11
11
  const print = issue.severity === 'warn' ? picocolors.gray : identity;
12
12
  table.cell('symbol', print(issue.symbols ? truncate(issue.symbols.map(s => s.symbol).join(', ')) : issue.symbol));
13
13
  issue.parentSymbol && table.cell('parentSymbol', print(issue.parentSymbol));
@@ -15,7 +15,7 @@ const logIssueRecord = (issues) => {
15
15
  const filePath = `${relative(issue.filePath)}${issue.line === undefined ? '' : `:${issue.line}${issue.col === undefined ? '' : `:${issue.col}`}`}`;
16
16
  table.cell('filePath', print(filePath));
17
17
  table.newRow();
18
- });
18
+ }
19
19
  console.log(table.sort(['filePath', 'parentSymbol', 'symbol']).print().trim());
20
20
  };
21
21
  export default ({ report, issues, configurationHints, noConfigHints, isShowProgress }) => {
@@ -27,7 +27,7 @@ export default ({ report, issues, configurationHints, noConfigHints, isShowProgr
27
27
  const isSet = issues[reportType] instanceof Set;
28
28
  const issuesForType = isSet
29
29
  ? Array.from(issues[reportType])
30
- : Object.values(issues[reportType]).map(Object.values).flat();
30
+ : Object.values(issues[reportType]).flatMap(Object.values);
31
31
  if (issuesForType.length > 0) {
32
32
  title && logTitle(title, issuesForType.length);
33
33
  if (isSet) {
@@ -42,12 +42,12 @@ export default ({ report, issues, configurationHints, noConfigHints, isShowProgr
42
42
  }
43
43
  if (!noConfigHints && configurationHints.size > 0) {
44
44
  logTitle('Configuration issues', configurationHints.size);
45
- configurationHints.forEach(hint => {
45
+ for (const hint of configurationHints) {
46
46
  const { type, workspaceName, identifier } = hint;
47
47
  const message = `Unused item in ${type}`;
48
- const workspace = workspaceName && workspaceName !== ROOT_WORKSPACE_NAME ? ` (workspace: ${workspaceName})` : ``;
48
+ const workspace = workspaceName && workspaceName !== ROOT_WORKSPACE_NAME ? ` (workspace: ${workspaceName})` : '';
49
49
  console.warn(picocolors.gray(`${message}${workspace}:`), identifier);
50
- });
50
+ }
51
51
  }
52
52
  if (totalIssues === 0 && isShowProgress) {
53
53
  console.log('✂️ Excellent, Knip found no issues.');
@@ -1,6 +1,6 @@
1
1
  import picocolors from 'picocolors';
2
2
  import { ISSUE_TYPE_TITLE } from '../constants.js';
3
- import { toRelative, relative } from '../util/path.js';
3
+ import { relative, toRelative } from '../util/path.js';
4
4
  export const identity = (text) => text;
5
5
  export const getTitle = (reportType) => {
6
6
  return ISSUE_TYPE_TITLE[reportType];
@@ -13,7 +13,8 @@ export const logIssueLine = ({ owner, filePath, symbols, parentSymbol, severity
13
13
  console.log(`${owner ? `${picocolors.cyan(owner)} ` : ''}${print(`${relative(filePath)}${symbol}${parent}`)}`);
14
14
  };
15
15
  export const logIssueSet = (issues) => {
16
- issues.sort().forEach(value => console.log(toRelative(value)));
16
+ for (const value of issues.sort())
17
+ console.log(toRelative(value));
17
18
  };
18
19
  export const convert = (issue) => ({
19
20
  name: issue.symbol,
@@ -1,8 +1,8 @@
1
- import { z } from 'zod';
2
- import { ConfigurationValidator, pluginSchema } from '../ConfigurationValidator.js';
3
- import * as Plugins from '../plugins/index.js';
4
- import type { Rules, IssueType } from './issues.js';
5
- import type { SyncCompilers, AsyncCompilers } from '../compilers/types.js';
1
+ import type { z } from 'zod';
2
+ import type { ConfigurationValidator, pluginSchema } from '../ConfigurationValidator.js';
3
+ import type { AsyncCompilers, SyncCompilers } from '../compilers/types.js';
4
+ import type * as Plugins from '../plugins/index.js';
5
+ import type { IssueType, Rules } from './issues.js';
6
6
  export type RawConfiguration = z.infer<typeof ConfigurationValidator>;
7
7
  export type RawPluginConfiguration = z.infer<typeof pluginSchema>;
8
8
  type NormalizedGlob = string[];
@@ -1,3 +1 @@
1
- import { z } from 'zod';
2
- import { ConfigurationValidator, pluginSchema } from '../ConfigurationValidator.js';
3
- import * as Plugins from '../plugins/index.js';
1
+ export {};
@@ -1,4 +1,4 @@
1
- import ts from 'typescript';
1
+ import type ts from 'typescript';
2
2
  import type { SymbolType } from './issues.js';
3
3
  type FilePath = string;
4
4
  type Identifier = string;
@@ -1 +1 @@
1
- import ts from 'typescript';
1
+ export {};
@@ -1,4 +1,4 @@
1
- import ts from 'typescript';
1
+ import type ts from 'typescript';
2
2
  export interface ImportNode {
3
3
  specifier: string;
4
4
  identifier: string | undefined;
@@ -1 +1 @@
1
- import ts from 'typescript';
1
+ export {};
@@ -1,4 +1,4 @@
1
- import ts from 'typescript';
1
+ import type ts from 'typescript';
2
2
  type SymbolTable = Map<string, ts.Symbol>;
3
3
  type SymbolWithExports = ts.Symbol & {
4
4
  exports?: SymbolTable;
@@ -1 +1 @@
1
- import ts from 'typescript';
1
+ export {};
@@ -1,5 +1,5 @@
1
1
  import ts from 'typescript';
2
- import type { SyncCompilers, AsyncCompilers } from '../compilers/types.js';
2
+ import type { AsyncCompilers, SyncCompilers } from '../compilers/types.js';
3
3
  interface SourceFileManagerOptions {
4
4
  isSkipLibs: boolean;
5
5
  compilers: [SyncCompilers, AsyncCompilers];
@@ -55,7 +55,7 @@ export function findAncestor(node, callback) {
55
55
  if (result === 'STOP') {
56
56
  return undefined;
57
57
  }
58
- else if (result) {
58
+ if (result) {
59
59
  return node;
60
60
  }
61
61
  node = node.parent;
@@ -71,7 +71,7 @@ export function findDescendants(node, callback) {
71
71
  if (result === 'STOP') {
72
72
  return;
73
73
  }
74
- else if (result) {
74
+ if (result) {
75
75
  results.push(node);
76
76
  }
77
77
  ts.forEachChild(node, visit);
@@ -1,6 +1,6 @@
1
1
  import ts from 'typescript';
2
+ import type { AsyncCompilers, SyncCompilers } from '../compilers/types.js';
2
3
  import { SourceFileManager } from './SourceFileManager.js';
3
- import type { SyncCompilers, AsyncCompilers } from '../compilers/types.js';
4
4
  type CreateHostsOptions = {
5
5
  cwd: string;
6
6
  compilerOptions: ts.CompilerOptions;