knip 5.22.3 → 5.23.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 (95) hide show
  1. package/dist/ConfigurationChief.d.ts +15 -89
  2. package/dist/ConfigurationValidator.d.ts +1141 -2897
  3. package/dist/DependencyDeputy.d.ts +6 -21
  4. package/dist/IssueCollector.d.ts +7 -4
  5. package/dist/IssueCollector.js +7 -2
  6. package/dist/IssueFixer.d.ts +1 -1
  7. package/dist/PrincipalFactory.d.ts +3 -3
  8. package/dist/ProjectPrincipal.d.ts +9 -9
  9. package/dist/WorkspaceWorker.d.ts +9 -14
  10. package/dist/binaries/util.d.ts +5 -5
  11. package/dist/cli.js +2 -1
  12. package/dist/compilers/astro.d.ts +1 -1
  13. package/dist/compilers/compilers.d.ts +2 -2
  14. package/dist/compilers/index.d.ts +83 -695
  15. package/dist/compilers/mdx.d.ts +1 -1
  16. package/dist/constants.d.ts +4 -4
  17. package/dist/index.d.ts +1 -7
  18. package/dist/index.js +45 -11
  19. package/dist/manifest/helpers.d.ts +1 -1
  20. package/dist/manifest/index.d.ts +6 -4
  21. package/dist/plugins/babel/helpers.d.ts +1 -1
  22. package/dist/plugins/babel/index.d.ts +1 -1
  23. package/dist/plugins/capacitor/index.d.ts +1 -1
  24. package/dist/plugins/cypress/index.d.ts +1 -1
  25. package/dist/plugins/eleventy/helpers.d.ts +5 -5
  26. package/dist/plugins/eleventy/index.d.ts +2 -5
  27. package/dist/plugins/graphql-codegen/index.d.ts +1 -1
  28. package/dist/plugins/husky/index.d.ts +1 -1
  29. package/dist/plugins/jest/index.d.ts +2 -3
  30. package/dist/plugins/lefthook/index.d.ts +1 -1
  31. package/dist/plugins/lint-staged/index.d.ts +1 -2
  32. package/dist/plugins/markdownlint/helpers.d.ts +1 -1
  33. package/dist/plugins/netlify/helpers.d.ts +1 -1
  34. package/dist/plugins/netlify/index.d.ts +1 -1
  35. package/dist/plugins/next/index.d.ts +1 -1
  36. package/dist/plugins/nx/index.d.ts +1 -1
  37. package/dist/plugins/playwright-ct/index.d.ts +1 -1
  38. package/dist/plugins/remix/index.d.ts +1 -1
  39. package/dist/plugins/sentry/index.d.ts +1 -1
  40. package/dist/plugins/simple-git-hooks/index.d.ts +1 -2
  41. package/dist/plugins/storybook/index.d.ts +2 -2
  42. package/dist/plugins/svelte/index.d.ts +1 -1
  43. package/dist/plugins/unbuild/index.d.ts +1 -2
  44. package/dist/plugins/vitest/helpers.d.ts +2 -2
  45. package/dist/plugins/webpack/index.d.ts +1 -4
  46. package/dist/plugins/wireit/index.d.ts +3 -2
  47. package/dist/plugins/yorkie/index.d.ts +1 -2
  48. package/dist/reporters/index.d.ts +2 -2
  49. package/dist/reporters/json.d.ts +1 -1
  50. package/dist/reporters/symbols.d.ts +1 -1
  51. package/dist/reporters/symbols.js +18 -8
  52. package/dist/reporters/util.d.ts +1 -1
  53. package/dist/types/dependency-graph.d.ts +2 -2
  54. package/dist/types/issues.d.ts +9 -0
  55. package/dist/typescript/SourceFileManager.d.ts +5 -5
  56. package/dist/typescript/ast-helpers.d.ts +7 -4
  57. package/dist/typescript/ast-helpers.js +19 -0
  58. package/dist/typescript/getImportsAndExports.d.ts +10 -11
  59. package/dist/typescript/getImportsAndExports.js +48 -27
  60. package/dist/typescript/visitors/dynamic-imports/index.d.ts +1 -1
  61. package/dist/typescript/visitors/exports/exportKeyword.js +26 -62
  62. package/dist/typescript/visitors/exports/index.d.ts +1 -1
  63. package/dist/typescript/visitors/imports/index.d.ts +1 -1
  64. package/dist/typescript/visitors/scripts/index.d.ts +1 -1
  65. package/dist/util/Performance.d.ts +2 -2
  66. package/dist/util/array.d.ts +2 -2
  67. package/dist/util/errors.d.ts +1 -1
  68. package/dist/util/file-entry-cache.d.ts +3 -6
  69. package/dist/util/fs.d.ts +6 -6
  70. package/dist/util/get-included-issue-types.d.ts +1 -2
  71. package/dist/util/git.d.ts +1 -1
  72. package/dist/util/glob.d.ts +6 -6
  73. package/dist/util/handle-dependency.d.ts +1 -1
  74. package/dist/util/is-identifier-referenced.d.ts +1 -1
  75. package/dist/util/loader.d.ts +1 -1
  76. package/dist/util/map-workspaces.d.ts +1 -2
  77. package/dist/util/modules.d.ts +7 -7
  78. package/dist/util/package-json.d.ts +2 -6
  79. package/dist/util/path.d.ts +6 -6
  80. package/dist/util/pkgs-graph.d.ts +1 -1
  81. package/dist/util/plugin.d.ts +7 -7
  82. package/dist/util/protocols.d.ts +9 -9
  83. package/dist/util/regex.d.ts +3 -2
  84. package/dist/util/regex.js +2 -0
  85. package/dist/util/reporter.d.ts +1 -1
  86. package/dist/util/require.d.ts +3 -3
  87. package/dist/util/resolve.d.ts +1 -1
  88. package/dist/util/tag.d.ts +3 -2
  89. package/dist/util/tag.js +2 -2
  90. package/dist/util/trace.d.ts +2 -2
  91. package/dist/util/tsconfig-loader.d.ts +1 -6
  92. package/dist/util/unwrap-function.d.ts +1 -1
  93. package/dist/version.d.ts +1 -1
  94. package/dist/version.js +1 -1
  95. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  import type { Workspace } from './ConfigurationChief.js';
2
- import type { ConfigurationHints, Counters, Issue, Issues, SymbolIssueType } from './types/issues.js';
2
+ import type { Counters, Issue, Issues, SymbolIssueType } from './types/issues.js';
3
3
  import type { PackageJson } from './types/package-json.js';
4
4
  import type { DependencyArray, DependencySet, HostDependencies, InstalledBinaries, WorkspaceManifests } from './types/workspace.js';
5
5
  type Options = {
@@ -25,33 +25,18 @@ export declare class DependencyDeputy {
25
25
  ignoreDependencies: (string | RegExp)[];
26
26
  ignoreBinaries: (string | RegExp)[];
27
27
  }): void;
28
- getWorkspaceManifest(workspaceName: string): {
29
- workspaceDir: string;
30
- manifestPath: string;
31
- dependencies: DependencyArray;
32
- devDependencies: DependencyArray;
33
- peerDependencies: DependencySet;
34
- optionalPeerDependencies: DependencyArray;
35
- allDependencies: DependencySet;
36
- ignoreDependencies: (string | RegExp)[];
37
- ignoreBinaries: (string | RegExp)[];
38
- usedIgnoreDependencies: Set<string | RegExp>;
39
- usedIgnoreBinaries: Set<string | RegExp>;
40
- } | undefined;
28
+ getWorkspaceManifest(workspaceName: string): any;
41
29
  getProductionDependencies(workspaceName: string): DependencyArray;
42
30
  getDevDependencies(workspaceName: string): DependencyArray;
43
31
  getDependencies(workspaceName: string): DependencySet;
44
32
  setInstalledBinaries(workspaceName: string, installedBinaries: Map<string, Set<string>>): void;
45
- getInstalledBinaries(workspaceName: string): InstalledBinaries | undefined;
33
+ getInstalledBinaries(workspaceName: string): any;
46
34
  setHasTypesIncluded(workspaceName: string, hasTypesIncluded: Set<string>): void;
47
- getHasTypesIncluded(workspaceName: string): InstalledBinaries | undefined;
35
+ getHasTypesIncluded(workspaceName: string): any;
48
36
  addReferencedDependency(workspaceName: string, packageName: string): void;
49
37
  addReferencedBinary(workspaceName: string, binaryName: string): void;
50
38
  setHostDependencies(workspaceName: string, hostDependencies: HostDependencies): void;
51
- getHostDependenciesFor(workspaceName: string, dependency: string): {
52
- name: string;
53
- isPeerOptional: boolean;
54
- }[];
39
+ getHostDependenciesFor(workspaceName: string, dependency: string): any;
55
40
  getOptionalPeerDependencies(workspaceName: string): DependencyArray;
56
41
  maybeAddReferencedExternalDependency(workspace: Workspace, packageName: string): boolean;
57
42
  maybeAddReferencedBinary(workspace: Workspace, binaryName: string): boolean;
@@ -66,6 +51,6 @@ export declare class DependencyDeputy {
66
51
  getConfigurationHints({ issues, counters }: {
67
52
  issues: Issues;
68
53
  counters: Counters;
69
- }): ConfigurationHints;
54
+ }): Set<import("./types/issues.js").ConfigurationHint>;
70
55
  }
71
56
  export {};
@@ -1,4 +1,4 @@
1
- import type { ConfigurationHint, Issue, Rules } from './types/issues.js';
1
+ import type { ConfigurationHint, Issue, Rules, TagHint } from './types/issues.js';
2
2
  type Filters = Partial<{
3
3
  dir: string;
4
4
  }>;
@@ -15,6 +15,7 @@ export declare class IssueCollector {
15
15
  private counters;
16
16
  private referencedFiles;
17
17
  private configurationHints;
18
+ private tagHints;
18
19
  private ignorePatterns;
19
20
  private isMatch;
20
21
  constructor({ cwd, rules, filters }: IssueCollectorOptions);
@@ -26,11 +27,13 @@ export declare class IssueCollector {
26
27
  addFilesIssues(filePaths: string[]): void;
27
28
  addIssue(issue: Issue): Issue | undefined;
28
29
  addConfigurationHint(issue: ConfigurationHint): void;
29
- purge(): import("./types/issues.js").IssueSet;
30
+ addTagHint(issue: TagHint): void;
31
+ purge(): Set<string>;
30
32
  getIssues(): {
31
33
  issues: import("./types/issues.js").Issues;
32
- counters: import("./types/issues.js").Counters;
33
- configurationHints: Set<ConfigurationHint>;
34
+ counters: Record<keyof import("./types/issues.js").Issues | "processed" | "total", number>;
35
+ tagHints: any;
36
+ configurationHints: any;
34
37
  };
35
38
  }
36
39
  export {};
@@ -2,7 +2,7 @@ import picomatch from 'picomatch';
2
2
  import { initCounters, initIssues } from './issues/initializers.js';
3
3
  import { timerify } from './util/Performance.js';
4
4
  import { relative } from './util/path.js';
5
- const hasHint = (hints, hint) => Array.from(hints).some(item => item.identifier === hint.identifier && item.type === hint.type && item.workspaceName === hint.workspaceName);
5
+ const hasConfigurationHint = (hints, hint) => Array.from(hints).some(item => item.identifier === hint.identifier && item.type === hint.type && item.workspaceName === hint.workspaceName);
6
6
  const isMatch = timerify(picomatch.isMatch, 'isMatch');
7
7
  export class IssueCollector {
8
8
  cwd;
@@ -12,6 +12,7 @@ export class IssueCollector {
12
12
  counters = initCounters();
13
13
  referencedFiles = new Set();
14
14
  configurationHints = new Set();
15
+ tagHints = new Set();
15
16
  ignorePatterns = new Set();
16
17
  isMatch;
17
18
  constructor({ cwd, rules, filters }) {
@@ -59,10 +60,13 @@ export class IssueCollector {
59
60
  return issue;
60
61
  }
61
62
  addConfigurationHint(issue) {
62
- if (!hasHint(this.configurationHints, issue)) {
63
+ if (!hasConfigurationHint(this.configurationHints, issue)) {
63
64
  this.configurationHints.add(issue);
64
65
  }
65
66
  }
67
+ addTagHint(issue) {
68
+ this.tagHints.add(issue);
69
+ }
66
70
  purge() {
67
71
  const unusedFiles = this.issues.files;
68
72
  this.issues = initIssues();
@@ -73,6 +77,7 @@ export class IssueCollector {
73
77
  return {
74
78
  issues: this.issues,
75
79
  counters: this.counters,
80
+ tagHints: this.tagHints,
76
81
  configurationHints: this.configurationHints,
77
82
  };
78
83
  }
@@ -18,7 +18,7 @@ export declare class IssueFixer {
18
18
  constructor({ isEnabled, cwd, fixTypes, isRemoveFiles }: Fixer);
19
19
  addUnusedTypeNode(filePath: string, fixes: Fixes | undefined): void;
20
20
  addUnusedExportNode(filePath: string, fixes: Fixes | undefined): void;
21
- fixIssues(issues: Issues): Promise<void>;
21
+ fixIssues(issues: Issues): any;
22
22
  private markExportFixed;
23
23
  private removeUnusedFiles;
24
24
  private removeUnusedExportKeywords;
@@ -21,12 +21,12 @@ export type PrincipalOptions = {
21
21
  };
22
22
  export declare class PrincipalFactory {
23
23
  principals: Principals;
24
- getPrincipal(options: PrincipalOptions): ProjectPrincipal;
24
+ getPrincipal(options: PrincipalOptions): any;
25
25
  private findReusablePrincipal;
26
26
  private linkPrincipal;
27
27
  private addNewPrincipal;
28
- getPrincipals(): ProjectPrincipal[];
29
- getPrincipalByPackageName(packageName: string): ProjectPrincipal | undefined;
28
+ getPrincipals(): any;
29
+ getPrincipalByPackageName(packageName: string): any;
30
30
  deletePrincipal(principal: ProjectPrincipal): void;
31
31
  }
32
32
  export {};
@@ -9,11 +9,11 @@ import { type GetImportsAndExportsOptions } from './typescript/getImportsAndExpo
9
9
  import type { ResolveModuleNames } from './typescript/resolveModuleNames.js';
10
10
  import type { ToSourceFilePath } from './util/to-source-path.js';
11
11
  export declare class ProjectPrincipal {
12
- entryPaths: Set<string>;
13
- projectPaths: Set<string>;
14
- nonEntryPaths: Set<string>;
12
+ entryPaths: any;
13
+ projectPaths: any;
14
+ nonEntryPaths: any;
15
15
  referencedDependencies: Set<[string, string, string]>;
16
- skipExportsAnalysis: Set<string>;
16
+ skipExportsAnalysis: any;
17
17
  cwd: string;
18
18
  compilerOptions: ts.CompilerOptions;
19
19
  extensions: Set<string>;
@@ -45,16 +45,16 @@ export declare class ProjectPrincipal {
45
45
  }): void;
46
46
  addNonEntryPath(filePath: string): void;
47
47
  addProjectPath(filePath: string): void;
48
- deletedFiles: Set<unknown>;
48
+ deletedFiles: any;
49
49
  removeProjectPath(filePath: string): void;
50
50
  addReferencedDependencies(workspaceName: string, referencedDependencies: ReferencedDependencies): void;
51
- runAsyncCompilers(): Promise<void>;
52
- getUsedResolvedFiles(): string[];
51
+ runAsyncCompilers(): any;
52
+ getUsedResolvedFiles(): any;
53
53
  private getProgramSourceFiles;
54
- getUnreferencedFiles(): string[];
54
+ getUnreferencedFiles(): any;
55
55
  analyzeSourceFile(filePath: string, options: Omit<GetImportsAndExportsOptions, 'skipExports'>, isGitIgnored: (filePath: string) => boolean, isPackageNameInternalWorkspace: (packageName: string) => boolean, getPrincipalByFilePath: (filePath: string) => undefined | ProjectPrincipal): FileNode;
56
56
  invalidateFile(filePath: string): void;
57
- findUnusedMembers(filePath: string, members: ExportMember[]): ExportMember[];
57
+ findUnusedMembers(filePath: string, members: ExportMember[]): any;
58
58
  hasExternalReferences(filePath: string, exportedItem: Export): boolean;
59
59
  reconcileCache(graph: DependencyGraph): void;
60
60
  }
@@ -32,28 +32,23 @@ export declare class WorkspaceWorker {
32
32
  isStrict: boolean;
33
33
  rootIgnore: Configuration['ignore'];
34
34
  negatedWorkspacePatterns: string[];
35
- enabledPluginsMap: Record<"angular" | "astro" | "ava" | "babel" | "capacitor" | "changesets" | "commitizen" | "commitlint" | "cspell" | "cucumber" | "cypress" | "drizzle" | "eleventy" | "eslint" | "gatsby" | "githubActions" | "graphqlCodegen" | "husky" | "jest" | "lefthook" | "linthtml" | "lintStaged" | "lockfileLint" | "lostPixel" | "markdownlint" | "mocha" | "moonrepo" | "msw" | "netlify" | "next" | "nodeTestRunner" | "npmPackageJsonLint" | "nx" | "nyc" | "oclif" | "playwright" | "playwrightCt" | "postcss" | "prettier" | "releaseIt" | "remark" | "remix" | "rollup" | "semanticRelease" | "sentry" | "simpleGitHooks" | "sizeLimit" | "storybook" | "stryker" | "stylelint" | "svelte" | "syncpack" | "tailwind" | "tsup" | "typedoc" | "typescript" | "unbuild" | "unocss" | "vercelOg" | "vite" | "vitest" | "vue" | "webdriverIo" | "webpack" | "wireit" | "wrangler" | "xo" | "yorkie", boolean>;
35
+ enabledPluginsMap: any;
36
36
  enabledPlugins: PluginName[];
37
37
  enabledPluginsInAncestors: string[];
38
38
  cache: CacheConsultant<CacheItem>;
39
39
  constructor({ name, dir, cwd, config, manifest, dependencies, isProduction, isStrict, rootIgnore, negatedWorkspacePatterns, enabledPluginsInAncestors, }: WorkspaceManagerOptions);
40
- init(): Promise<void>;
40
+ init(): any;
41
41
  private determineEnabledPlugins;
42
42
  private getConfigForPlugin;
43
- getEntryFilePatterns(): string[];
44
- getProjectFilePatterns(testFilePatterns: string[]): string[];
45
- getPluginProjectFilePatterns(): string[];
43
+ getEntryFilePatterns(): any;
44
+ getProjectFilePatterns(testFilePatterns: string[]): any;
45
+ getPluginProjectFilePatterns(): any;
46
46
  getPluginConfigPatterns(): string[];
47
- getProductionEntryFilePatterns(negatedTestFilePatterns: string[]): string[];
48
- getProductionProjectFilePatterns(negatedTestFilePatterns: string[]): string[];
47
+ getProductionEntryFilePatterns(negatedTestFilePatterns: string[]): any;
48
+ getProductionProjectFilePatterns(negatedTestFilePatterns: string[]): any;
49
49
  private getConfigurationFilePatterns;
50
- getIgnorePatterns(): string[];
51
- findDependenciesByPlugins(): Promise<{
52
- entryFilePatterns: Set<string>;
53
- productionEntryFilePatterns: Set<string>;
54
- referencedDependencies: ReferencedDependencies;
55
- enabledPlugins: ("angular" | "astro" | "ava" | "babel" | "capacitor" | "changesets" | "commitizen" | "commitlint" | "cspell" | "cucumber" | "cypress" | "drizzle" | "eleventy" | "eslint" | "gatsby" | "githubActions" | "graphqlCodegen" | "husky" | "jest" | "lefthook" | "linthtml" | "lintStaged" | "lockfileLint" | "lostPixel" | "markdownlint" | "mocha" | "moonrepo" | "msw" | "netlify" | "next" | "nodeTestRunner" | "npmPackageJsonLint" | "nx" | "nyc" | "oclif" | "playwright" | "playwrightCt" | "postcss" | "prettier" | "releaseIt" | "remark" | "remix" | "rollup" | "semanticRelease" | "sentry" | "simpleGitHooks" | "sizeLimit" | "storybook" | "stryker" | "stylelint" | "svelte" | "syncpack" | "tailwind" | "tsup" | "typedoc" | "typescript" | "unbuild" | "unocss" | "vercelOg" | "vite" | "vitest" | "vue" | "webdriverIo" | "webpack" | "wireit" | "wrangler" | "xo" | "yorkie")[];
56
- }>;
50
+ getIgnorePatterns(): any[];
51
+ findDependenciesByPlugins(): unknown;
57
52
  onDispose(): void;
58
53
  }
59
54
  export {};
@@ -1,5 +1,5 @@
1
- export declare const tryResolveFilePath: (cwd: string, specifier: string, acceptModuleSpecifier?: boolean) => string | undefined;
2
- export declare const tryResolveSpecifiers: (cwd: string, specifiers: string[]) => (string | undefined)[];
3
- export declare const stripVersionFromSpecifier: (specifier: string) => string;
4
- export declare const trimBinary: (command: string) => string;
5
- export declare const argsFrom: (args: string[], from: string) => string[];
1
+ export declare const tryResolveFilePath: (cwd: string, specifier: string, acceptModuleSpecifier?: boolean) => any;
2
+ export declare const tryResolveSpecifiers: (cwd: string, specifiers: string[]) => any;
3
+ export declare const stripVersionFromSpecifier: (specifier: string) => any;
4
+ export declare const trimBinary: (command: string) => any;
5
+ export declare const argsFrom: (args: string[], from: string) => any;
package/dist/cli.js CHANGED
@@ -21,7 +21,7 @@ if (isVersion) {
21
21
  const isShowProgress = isNoProgress === false && process.stdout.isTTY && typeof process.stdout.cursorTo === 'function';
22
22
  const run = async () => {
23
23
  try {
24
- const { report, issues, counters, rules, configurationHints } = await main({
24
+ const { report, issues, counters, rules, tagHints, configurationHints } = await main({
25
25
  cwd,
26
26
  tsConfigFile: tsConfig,
27
27
  gitignore: !isNoGitIgnore,
@@ -44,6 +44,7 @@ const run = async () => {
44
44
  report,
45
45
  issues,
46
46
  counters,
47
+ tagHints,
47
48
  configurationHints,
48
49
  noConfigHints,
49
50
  cwd,
@@ -1,6 +1,6 @@
1
1
  import type { HasDependency } from './types.js';
2
2
  declare const _default: {
3
3
  condition: (hasDependency: HasDependency) => boolean;
4
- compiler: (text: string) => string;
4
+ compiler: (text: string) => any;
5
5
  };
6
6
  export default _default;
@@ -1,4 +1,4 @@
1
1
  import type { SyncCompilerFn } from './types.js';
2
- export declare const importMatcher: RegExp;
3
- export declare const fencedCodeBlockMatcher: RegExp;
2
+ export declare const importMatcher: {};
3
+ export declare const fencedCodeBlockMatcher: {};
4
4
  export declare const importsWithinScripts: SyncCompilerFn;