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
@@ -6,14 +6,14 @@ interface SourceFileManagerOptions {
6
6
  }
7
7
  export declare class SourceFileManager {
8
8
  isSkipLibs: boolean;
9
- sourceFileCache: Map<string, ts.SourceFile | undefined>;
10
- snapshotCache: Map<string, ts.IScriptSnapshot | undefined>;
9
+ sourceFileCache: any;
10
+ snapshotCache: any;
11
11
  syncCompilers: SyncCompilers;
12
12
  asyncCompilers: AsyncCompilers;
13
13
  constructor({ compilers, isSkipLibs }: SourceFileManagerOptions);
14
14
  createSourceFile(filePath: string, contents: string): ts.SourceFile;
15
- getSourceFile(filePath: string): ts.SourceFile | undefined;
16
- getSnapshot(filePath: string): ts.IScriptSnapshot | undefined;
17
- compileAndAddSourceFile(filePath: string): Promise<void>;
15
+ getSourceFile(filePath: string): any;
16
+ getSnapshot(filePath: string): any;
17
+ compileAndAddSourceFile(filePath: string): any;
18
18
  }
19
19
  export {};
@@ -6,11 +6,11 @@ export declare function isAccessExpression(node: ts.Node): node is ts.AccessExpr
6
6
  export declare function isImportCall(node: ts.Node): node is ts.ImportCall;
7
7
  export declare function isRequireCall(callExpression: ts.Node): callExpression is ts.CallExpression;
8
8
  export declare function isPropertyAccessCall(node: ts.Node, identifier: string): node is ts.CallExpression;
9
- export declare function stripQuotes(name: string): string;
9
+ export declare function stripQuotes(name: string): any;
10
10
  export declare function findAncestor<T>(node: ts.Node | undefined, callback: (element: ts.Node) => boolean | 'STOP'): T | undefined;
11
11
  export declare function findDescendants<T>(node: ts.Node | undefined, callback: (element: ts.Node) => boolean | 'STOP'): T[];
12
12
  export declare const isDeclarationFileExtension: (extension: string) => extension is ".d.ts" | ".d.mts" | ".d.cts";
13
- export declare const getJSDocTags: (node: ts.Node) => Set<string>;
13
+ export declare const getJSDocTags: (node: ts.Node) => any;
14
14
  export declare const getLineAndCharacterOfPosition: (node: ts.Node, pos: number) => {
15
15
  line: number;
16
16
  col: number;
@@ -18,8 +18,11 @@ export declare const getLineAndCharacterOfPosition: (node: ts.Node, pos: number)
18
18
  };
19
19
  export declare const getAccessMembers: (typeChecker: ts.TypeChecker, node: ts.Identifier) => string[];
20
20
  export declare const isDestructuring: (node: ts.Node) => boolean;
21
- export declare const getDestructuredIds: (name: ts.ObjectBindingPattern) => string[];
22
- export declare const isConsiderReferencedNS: (node: ts.Identifier) => boolean;
21
+ export declare const getDestructuredIds: (name: ts.ObjectBindingPattern) => any;
22
+ export declare const isConsiderReferencedNS: (node: ts.Identifier) => any;
23
23
  export declare const isTopLevel: (node: ts.Node) => boolean;
24
24
  export declare const getTypeName: (node: ts.Identifier) => ts.QualifiedName | undefined;
25
25
  export declare const isImportSpecifier: (node: ts.Node) => boolean;
26
+ export declare const isReferencedInExportedType: (node: ts.Node) => any;
27
+ export declare const getExportKeywordNode: (node: ts.Node) => any;
28
+ export declare const getDefaultKeywordNode: (node: ts.Node) => any;
@@ -151,3 +151,22 @@ export const isImportSpecifier = (node) => ts.isImportSpecifier(node.parent) ||
151
151
  ts.isImportEqualsDeclaration(node.parent) ||
152
152
  ts.isImportClause(node.parent) ||
153
153
  ts.isNamespaceImport(node.parent);
154
+ const isExported = (node) => {
155
+ if (getExportKeywordNode(node))
156
+ return true;
157
+ return node.parent ? isExported(node.parent) : false;
158
+ };
159
+ const isTypeDeclaration = (node) => ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node) || ts.isEnumDeclaration(node);
160
+ const getAncestorTypeDeclaration = (node) => {
161
+ while (node) {
162
+ if (isTypeDeclaration(node))
163
+ return node;
164
+ node = node.parent;
165
+ }
166
+ };
167
+ export const isReferencedInExportedType = (node) => {
168
+ const typeNode = getAncestorTypeDeclaration(node);
169
+ return Boolean(typeNode && isExported(typeNode));
170
+ };
171
+ export const getExportKeywordNode = (node) => node.modifiers?.find(mod => mod.kind === ts.SyntaxKind.ExportKeyword);
172
+ export const getDefaultKeywordNode = (node) => node.modifiers?.find(mod => mod.kind === ts.SyntaxKind.DefaultKeyword);
@@ -1,7 +1,6 @@
1
1
  import ts from 'typescript';
2
2
  import type { Tags } from '../types/cli.js';
3
- import type { ExportMap, ImportMap, UnresolvedImport } from '../types/dependency-graph.js';
4
- import type { IssueSymbol } from '../types/issues.js';
3
+ import type { Export } from '../types/dependency-graph.js';
5
4
  import type { BoundSourceFile } from './SourceFile.js';
6
5
  export type GetImportsAndExportsOptions = {
7
6
  skipTypeOnly: boolean;
@@ -14,16 +13,16 @@ export type GetImportsAndExportsOptions = {
14
13
  };
15
14
  export declare const _getImportsAndExports: (sourceFile: BoundSourceFile, resolveModule: (specifier: string) => ts.ResolvedModuleFull | undefined, typeChecker: ts.TypeChecker, options: GetImportsAndExportsOptions) => {
16
15
  imports: {
17
- internal: ImportMap;
18
- external: Set<string>;
19
- resolved: Set<string>;
20
- specifiers: Set<[string, string]>;
21
- unresolved: Set<UnresolvedImport>;
16
+ internal: Map<string, import("../types/dependency-graph.js").ImportDetails>;
17
+ external: any;
18
+ resolved: any;
19
+ specifiers: any;
20
+ unresolved: any;
22
21
  };
23
22
  exports: {
24
- exported: ExportMap;
25
- duplicate: IssueSymbol[][];
23
+ exported: Map<string, Export>;
24
+ duplicate: any[];
26
25
  };
27
- scripts: Set<string>;
28
- traceRefs: Set<string>;
26
+ scripts: any;
27
+ traceRefs: any;
29
28
  };
@@ -5,8 +5,9 @@ import { timerify } from '../util/Performance.js';
5
5
  import { addNsValue, addValue, createImports } from '../util/dependency-graph.js';
6
6
  import { isStartsLikePackageName, sanitizeSpecifier } from '../util/modules.js';
7
7
  import { extname, isInNodeModules } from '../util/path.js';
8
+ import { isIdChar } from '../util/regex.js';
8
9
  import { shouldIgnore } from '../util/tag.js';
9
- import { getAccessMembers, getDestructuredIds, getJSDocTags, getLineAndCharacterOfPosition, getTypeName, isAccessExpression, isConsiderReferencedNS, isDestructuring, isImportSpecifier, } from './ast-helpers.js';
10
+ import { getAccessMembers, getDestructuredIds, getJSDocTags, getLineAndCharacterOfPosition, getTypeName, isAccessExpression, isConsiderReferencedNS, isDestructuring, isImportSpecifier, isReferencedInExportedType, } from './ast-helpers.js';
10
11
  import getDynamicImportVisitors from './visitors/dynamic-imports/index.js';
11
12
  import getExportVisitors from './visitors/exports/index.js';
12
13
  import { getImportsFromPragmas } from './visitors/helpers.js';
@@ -28,12 +29,13 @@ const createMember = (node, member, pos) => {
28
29
  line: line + 1,
29
30
  col: character + 1,
30
31
  fix: member.fix,
31
- refs: 0,
32
+ refs: [0, false],
32
33
  jsDocTags: getJSDocTags(member.node),
33
34
  };
34
35
  };
36
+ const isType = (item) => item.type === 'type' || item.type === 'interface' || item.type === 'member';
35
37
  const getImportsAndExports = (sourceFile, resolveModule, typeChecker, options) => {
36
- const { skipTypeOnly, tags } = options;
38
+ const { skipTypeOnly, tags, ignoreExportsUsedInFile } = options;
37
39
  const internalImports = new Map();
38
40
  const externalImports = new Set();
39
41
  const unresolvedImports = new Set();
@@ -44,16 +46,17 @@ const getImportsAndExports = (sourceFile, resolveModule, typeChecker, options) =
44
46
  const scripts = new Set();
45
47
  const traceRefs = new Set();
46
48
  const importedInternalSymbols = new Map();
49
+ const referencedSymbolsInExportedTypes = new Set();
47
50
  const visitors = getVisitors(sourceFile);
48
51
  const addInternalImport = (options) => {
49
- const { identifier, symbol, filePath, namespace, specifier, isReExport } = options;
52
+ const { identifier, symbol, filePath, namespace, alias, specifier, isReExport } = options;
50
53
  const isStar = identifier === IMPORT_STAR;
51
54
  specifiers.add([specifier, filePath]);
52
55
  const file = internalImports.get(filePath);
53
56
  const imports = file ?? createImports();
54
57
  if (!file)
55
58
  internalImports.set(filePath, imports);
56
- const nsOrAlias = symbol ? String(symbol.escapedName) : options.alias;
59
+ const nsOrAlias = symbol ? String(symbol.escapedName) : alias;
57
60
  if (isReExport) {
58
61
  if (isStar && namespace) {
59
62
  addValue(imports.reExportedNs, namespace, sourceFile.fileName);
@@ -186,7 +189,7 @@ const getImportsAndExports = (sourceFile, resolveModule, typeChecker, options) =
186
189
  line: line + 1,
187
190
  col: character + 1,
188
191
  fixes: fix ? [fix] : [],
189
- refs: 0,
192
+ refs: [0, false],
190
193
  isReExport,
191
194
  });
192
195
  }
@@ -221,7 +224,10 @@ const getImportsAndExports = (sourceFile, resolveModule, typeChecker, options) =
221
224
  const result = visitor(node, options);
222
225
  result && (Array.isArray(result) ? result.forEach(addImportWithNode) : addImportWithNode(result));
223
226
  }
224
- const isTopLevel = node.parent === sourceFile || node.parent?.parent === sourceFile;
227
+ const isTopLevel = node.parent &&
228
+ ('commonJsModuleIndicator' in sourceFile
229
+ ? node.parent.parent === sourceFile || node.parent === sourceFile
230
+ : node.parent === sourceFile);
225
231
  if (isTopLevel) {
226
232
  for (const visitor of visitors.import) {
227
233
  const result = visitor(node, options);
@@ -282,6 +288,9 @@ const getImportsAndExports = (sourceFile, resolveModule, typeChecker, options) =
282
288
  }
283
289
  }
284
290
  }
291
+ if (ignoreExportsUsedInFile && !isTopLevel && isReferencedInExportedType(node)) {
292
+ referencedSymbolsInExportedTypes.add(symbol.exportSymbol);
293
+ }
285
294
  }
286
295
  }
287
296
  if (isTopLevel &&
@@ -302,37 +311,49 @@ const getImportsAndExports = (sourceFile, resolveModule, typeChecker, options) =
302
311
  const setRefs = (item) => {
303
312
  if (!item.symbol)
304
313
  return;
314
+ if (item.symbol.flags & ts.SymbolFlags.AliasExcludes) {
315
+ item.refs = [1, false];
316
+ return;
317
+ }
305
318
  const symbols = new Set();
306
319
  let index = 0;
307
- while (index < sourceFile.text.length && (index = sourceFile.text.indexOf(item.identifier, index)) !== -1) {
308
- const isDeclaration = index === item.pos || index === item.pos + 1;
309
- if (!isDeclaration) {
310
- const symbol = typeChecker.getSymbolAtLocation(ts.getTokenAtPosition(sourceFile, index));
311
- if (symbol) {
312
- if (item.symbol === symbol) {
313
- item.refs = 1;
314
- break;
315
- }
316
- const declaration = symbol.declarations?.[0];
317
- if (declaration) {
318
- if (item.symbol === declaration.name?.flowNode?.node?.symbol) {
319
- item.refs = 1;
320
- break;
320
+ const text = sourceFile.text;
321
+ const id = item.identifier;
322
+ while (index < text.length && (index = text.indexOf(id, index)) !== -1) {
323
+ if (!isIdChar(text.charAt(index - 1)) && !isIdChar(text.charAt(index + id.length))) {
324
+ const isExportDeclaration = index === item.pos || index === item.pos + 1;
325
+ if (!isExportDeclaration) {
326
+ const symbol = typeChecker.getSymbolAtLocation(ts.getTokenAtPosition(sourceFile, index));
327
+ if (symbol) {
328
+ const isInExportedType = referencedSymbolsInExportedTypes.has(symbol);
329
+ if (item.symbol === symbol) {
330
+ item.refs = [1, isInExportedType];
331
+ if (isInExportedType || isType(item))
332
+ break;
321
333
  }
322
- if (ts.isImportSpecifier(declaration) && symbols.has(symbol)) {
323
- item.refs = 1;
324
- break;
334
+ const declaration = symbol.declarations?.[0];
335
+ if (declaration) {
336
+ if (item.symbol === declaration.name?.flowNode?.node?.symbol) {
337
+ item.refs = [1, isInExportedType];
338
+ break;
339
+ }
340
+ if (ts.isImportSpecifier(declaration) && symbols.has(symbol)) {
341
+ item.refs = [1, isInExportedType];
342
+ break;
343
+ }
325
344
  }
345
+ symbols.add(symbol);
326
346
  }
327
- symbols.add(symbol);
328
347
  }
329
348
  }
330
- index += item.identifier.length;
349
+ index += id.length;
331
350
  }
332
351
  };
352
+ const isSetRefs = ignoreExportsUsedInFile;
333
353
  for (const item of exports.values()) {
334
- if (options.ignoreExportsUsedInFile)
354
+ if (isSetRefs === true || (typeof isSetRefs === 'object' && item.type !== 'unknown' && !!isSetRefs[item.type])) {
335
355
  setRefs(item);
356
+ }
336
357
  for (const member of item.members) {
337
358
  setRefs(member);
338
359
  member.symbol = undefined;
@@ -1,3 +1,3 @@
1
1
  import type ts from 'typescript';
2
- declare const _default: (sourceFile: ts.SourceFile) => ((node: ts.Node, options: import("../../getImportsAndExports.js").GetImportsAndExportsOptions) => undefined | import("../../../types/imports.js").ImportNode | import("../../../types/imports.js").ImportNode[])[];
2
+ declare const _default: (sourceFile: ts.SourceFile) => any;
3
3
  export default _default;
@@ -1,17 +1,20 @@
1
1
  import ts from 'typescript';
2
2
  import { SymbolType } from '../../../types/issues.js';
3
3
  import { compact } from '../../../util/array.js';
4
- import { isGetOrSetAccessorDeclaration, isPrivateMember, stripQuotes } from '../../ast-helpers.js';
4
+ import { getDefaultKeywordNode, getExportKeywordNode, isGetOrSetAccessorDeclaration, isPrivateMember, stripQuotes, } from '../../ast-helpers.js';
5
5
  import { exportVisitor as visit } from '../index.js';
6
6
  export default visit(() => true, (node, { isFixExports, isFixTypes, isReportClassMembers }) => {
7
- const exportKeyword = node.modifiers?.find(mod => mod.kind === ts.SyntaxKind.ExportKeyword);
7
+ const exportKeyword = getExportKeywordNode(node);
8
8
  if (exportKeyword) {
9
+ const getFix = (node, defaultKeyword) => isFixExports ? [node.getStart(), (defaultKeyword ?? node).getEnd() + 1] : undefined;
10
+ const getElementFix = (node) => (isFixExports ? [node.getStart(), node.getEnd()] : undefined);
11
+ const getTypeFix = (node) => (isFixTypes ? [node.getStart(), node.getEnd() + 1] : undefined);
9
12
  if (ts.isVariableStatement(node)) {
10
13
  return node.declarationList.declarations.flatMap(declaration => {
11
14
  if (ts.isObjectBindingPattern(declaration.name)) {
12
15
  return compact(declaration.name.elements.map(element => {
13
16
  if (ts.isIdentifier(element.name)) {
14
- const fix = isFixExports ? [element.getStart(), element.getEnd()] : undefined;
17
+ const fix = getElementFix(element);
15
18
  return {
16
19
  node: element,
17
20
  identifier: element.name.escapedText.toString(),
@@ -25,7 +28,7 @@ export default visit(() => true, (node, { isFixExports, isFixTypes, isReportClas
25
28
  if (ts.isArrayBindingPattern(declaration.name)) {
26
29
  return compact(declaration.name.elements.map(element => {
27
30
  if (ts.isBindingElement(element)) {
28
- const fix = isFixExports ? [element.getStart(), element.getEnd()] : undefined;
31
+ const fix = getElementFix(element);
29
32
  return {
30
33
  node: element,
31
34
  identifier: element.getText(),
@@ -37,34 +40,22 @@ export default visit(() => true, (node, { isFixExports, isFixTypes, isReportClas
37
40
  }));
38
41
  }
39
42
  const identifier = declaration.name.getText();
40
- const fix = isFixExports ? [exportKeyword.getStart(), exportKeyword.getEnd() + 1] : undefined;
41
- return {
42
- node: declaration,
43
- identifier,
44
- type: SymbolType.UNKNOWN,
45
- pos: declaration.name.getStart(),
46
- fix,
47
- };
43
+ const pos = declaration.name.getStart();
44
+ const fix = getFix(exportKeyword);
45
+ return { node: declaration, identifier, type: SymbolType.UNKNOWN, pos, fix };
48
46
  });
49
47
  }
50
- const defaultKeyword = node.modifiers?.find(mod => mod.kind === ts.SyntaxKind.DefaultKeyword);
48
+ const defaultKeyword = getDefaultKeywordNode(node);
51
49
  if (ts.isFunctionDeclaration(node) && node.name) {
52
50
  const identifier = defaultKeyword ? 'default' : node.name.getText();
53
51
  const pos = (node.name ?? node.body ?? node).getStart();
54
- const fix = isFixExports
55
- ? [exportKeyword.getStart(), (defaultKeyword ?? exportKeyword).getEnd() + 1]
56
- : undefined;
57
- return {
58
- node,
59
- identifier,
60
- pos,
61
- type: SymbolType.FUNCTION,
62
- fix,
63
- };
52
+ const fix = getFix(exportKeyword, defaultKeyword);
53
+ return { node, identifier, pos, type: SymbolType.FUNCTION, fix };
64
54
  }
65
55
  if (ts.isClassDeclaration(node) && node.name) {
66
56
  const identifier = defaultKeyword ? 'default' : node.name.getText();
67
57
  const pos = (node.name ?? node).getStart();
58
+ const fix = getFix(exportKeyword, defaultKeyword);
68
59
  const members = isReportClassMembers
69
60
  ? node.members
70
61
  .filter((member) => (ts.isPropertyDeclaration(member) ||
@@ -79,43 +70,24 @@ export default visit(() => true, (node, { isFixExports, isFixTypes, isReportClas
79
70
  fix: undefined,
80
71
  }))
81
72
  : [];
82
- const fix = isFixExports
83
- ? [exportKeyword.getStart(), (defaultKeyword ?? exportKeyword).getEnd() + 1]
84
- : undefined;
85
- return {
86
- node,
87
- identifier,
88
- type: SymbolType.CLASS,
89
- pos,
90
- members,
91
- fix,
92
- };
73
+ return { node, identifier, type: SymbolType.CLASS, pos, members, fix };
93
74
  }
94
75
  if (ts.isTypeAliasDeclaration(node)) {
95
- const identifier = defaultKeyword ? 'default' : node.name.getText();
96
- const fix = isFixTypes ? [exportKeyword.getStart(), exportKeyword.getEnd() + 1] : undefined;
97
- return {
98
- node,
99
- identifier,
100
- type: SymbolType.TYPE,
101
- pos: node.name.getStart(),
102
- fix,
103
- };
76
+ const identifier = node.name.getText();
77
+ const pos = node.name.getStart();
78
+ const fix = getTypeFix(exportKeyword);
79
+ return { node, identifier, type: SymbolType.TYPE, pos, fix };
104
80
  }
105
81
  if (ts.isInterfaceDeclaration(node)) {
106
- const identifier = defaultKeyword ? 'default' : node.name.getText();
107
- const fix = isFixTypes ? [exportKeyword.getStart(), exportKeyword.getEnd() + 1] : undefined;
108
- return {
109
- node,
110
- identifier,
111
- type: SymbolType.INTERFACE,
112
- pos: node.name.getStart(),
113
- fix,
114
- };
82
+ const identifier = node.name.getText();
83
+ const pos = node.name.getStart();
84
+ const fix = getTypeFix(exportKeyword);
85
+ return { node, identifier, type: SymbolType.INTERFACE, pos, fix };
115
86
  }
116
87
  if (ts.isEnumDeclaration(node)) {
117
- const identifier = defaultKeyword ? 'default' : node.name.getText();
88
+ const identifier = node.name.getText();
118
89
  const pos = node.name.getStart();
90
+ const fix = getTypeFix(exportKeyword);
119
91
  const members = node.members.map(member => ({
120
92
  node: member,
121
93
  identifier: stripQuotes(member.name.getText()),
@@ -123,15 +95,7 @@ export default visit(() => true, (node, { isFixExports, isFixTypes, isReportClas
123
95
  type: SymbolType.MEMBER,
124
96
  fix: undefined,
125
97
  }));
126
- const fix = isFixTypes ? [exportKeyword.getStart(), exportKeyword.getEnd() + 1] : undefined;
127
- return {
128
- node,
129
- identifier,
130
- type: SymbolType.ENUM,
131
- pos,
132
- members,
133
- fix,
134
- };
98
+ return { node, identifier, type: SymbolType.ENUM, pos, members, fix };
135
99
  }
136
100
  }
137
101
  });
@@ -1,3 +1,3 @@
1
1
  import type ts from 'typescript';
2
- declare const _default: (sourceFile: ts.SourceFile) => ((node: ts.Node, options: import("../../getImportsAndExports.js").GetImportsAndExportsOptions) => undefined | import("../../../types/exports.js").ExportNode | import("../../../types/exports.js").ExportNode[])[];
2
+ declare const _default: (sourceFile: ts.SourceFile) => any;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
1
  import type ts from 'typescript';
2
- declare const _default: (sourceFile: ts.SourceFile) => ((node: ts.Node, options: import("../../getImportsAndExports.js").GetImportsAndExportsOptions) => undefined | import("../../../types/imports.js").ImportNode | import("../../../types/imports.js").ImportNode[])[];
2
+ declare const _default: (sourceFile: ts.SourceFile) => any;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
1
  import type ts from 'typescript';
2
- declare const _default: (sourceFile: ts.SourceFile) => ((node: ts.Node, options: import("../../getImportsAndExports.js").GetImportsAndExportsOptions) => undefined | string | string[])[];
2
+ declare const _default: (sourceFile: ts.SourceFile) => any;
3
3
  export default _default;
@@ -15,11 +15,11 @@ declare class Performance {
15
15
  private clearMark;
16
16
  private flush;
17
17
  private getEntriesByName;
18
- getTable(): string;
18
+ getTable(): any;
19
19
  getCurrentDurationInMs(startTime?: number): number;
20
20
  getMemHeapUsage(): number;
21
21
  getCurrentMemUsageInMb(): number;
22
- finalize(): Promise<void>;
22
+ finalize(): any;
23
23
  reset(): void;
24
24
  }
25
25
  export declare const perfObserver: Performance;
@@ -1,5 +1,5 @@
1
1
  type Collection<T> = Array<T> | Set<T>;
2
- export declare const compact: <T>(collection: Collection<T | undefined>) => T[];
3
- export declare const arrayify: (value?: string[] | string) => string[];
2
+ export declare const compact: <T>(collection: Collection<T | undefined>) => any;
3
+ export declare const arrayify: (value?: string[] | string) => string | string[] | undefined;
4
4
  export declare const partition: <T>(collection: T[], predicate: (item: T) => unknown) => [T[], T[]];
5
5
  export {};
@@ -9,5 +9,5 @@ export declare class LoaderError extends Error {
9
9
  export declare const isKnownError: (error: Error) => error is ConfigurationError | LoaderError | ZodError<any>;
10
10
  export declare const hasCause: (error: Error) => error is ErrorWithCause;
11
11
  export declare const isConfigurationError: (error: Error) => error is ConfigurationError;
12
- export declare const getKnownError: (error: Error) => Error;
12
+ export declare const getKnownError: (error: Error) => any;
13
13
  export {};
@@ -13,17 +13,14 @@ export type FileDescriptor<T> = {
13
13
  };
14
14
  export declare class FileEntryCache<T> {
15
15
  filePath: string;
16
- cache: Map<string, MetaData<T>>;
17
- normalizedEntries: Map<string, FileDescriptor<T>>;
16
+ cache: any;
17
+ normalizedEntries: any;
18
18
  constructor(cacheId: string, _path: string);
19
19
  removeNotFoundFiles(): void;
20
20
  getFileDescriptor(filePath: string): FileDescriptor<T>;
21
21
  _getFileDescriptorUsingMtimeAndSize(filePath: string, fstat: fs.Stats): FileDescriptor<T>;
22
22
  removeEntry(entryName: string): void;
23
- _getMetaForFileUsingMtimeAndSize(cacheEntry: FileDescriptor<T>): {
24
- size: number;
25
- mtime: number;
26
- };
23
+ _getMetaForFileUsingMtimeAndSize(cacheEntry: FileDescriptor<T>): any;
27
24
  reconcile(): void;
28
25
  }
29
26
  export {};
package/dist/util/fs.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  export declare const isDirectory: (filePath: string) => boolean;
2
2
  export declare const isFile: (filePath: string) => boolean;
3
3
  export declare const findFile: (workingDir: string, fileName: string) => string | undefined;
4
- export declare const loadFile: (filePath: string) => Promise<string>;
5
- export declare const loadJSON: (filePath: string) => Promise<any>;
6
- export declare const loadYAML: (filePath: string) => Promise<unknown>;
7
- export declare const loadTOML: (filePath: string) => Promise<Record<string, import("smol-toml").TomlPrimitive>>;
8
- export declare const parseJSON: (filePath: string, contents: string) => Promise<any>;
4
+ export declare const loadFile: (filePath: string) => unknown;
5
+ export declare const loadJSON: (filePath: string) => unknown;
6
+ export declare const loadYAML: (filePath: string) => unknown;
7
+ export declare const loadTOML: (filePath: string) => unknown;
8
+ export declare const parseJSON: (filePath: string, contents: string) => unknown;
9
9
  export declare const parseYAML: (contents: string) => unknown;
10
10
  export declare function isTypeModule(path: string): boolean;
11
- export declare const _loadJSON: (filePath: string) => Promise<any>;
11
+ export declare const _loadJSON: (filePath: string) => unknown;
@@ -1,4 +1,3 @@
1
- import type { Report } from '../types/issues.js';
2
1
  type CLIArguments = {
3
2
  include: string[];
4
3
  exclude: string[];
@@ -14,5 +13,5 @@ type Options = {
14
13
  exports?: boolean;
15
14
  };
16
15
  export declare const defaultExcludedIssueTypes: string[];
17
- export declare const getIncludedIssueTypes: (cliArgs: CLIArguments, { include, exclude, isProduction }?: Options) => Report;
16
+ export declare const getIncludedIssueTypes: (cliArgs: CLIArguments, { include, exclude, isProduction }?: Options) => any;
18
17
  export {};
@@ -1 +1 @@
1
- export declare const getGitHookPaths: (defaultPath?: string, followGitConfig?: boolean) => string[];
1
+ export declare const getGitHookPaths: (defaultPath?: string, followGitConfig?: boolean) => any;
@@ -1,6 +1,6 @@
1
1
  export declare const prependDirToPattern: (workingDir: string, pattern: string) => string;
2
- export declare const negate: (pattern: string) => string;
3
- export declare const hasProductionSuffix: (pattern: string) => boolean;
2
+ export declare const negate: (pattern: string) => any;
3
+ export declare const hasProductionSuffix: (pattern: string) => any;
4
4
  export declare const hasNoProductionSuffix: (pattern: string) => boolean;
5
5
  interface BaseGlobOptions {
6
6
  cwd: string;
@@ -10,8 +10,8 @@ interface BaseGlobOptions {
10
10
  interface GlobOptions extends BaseGlobOptions {
11
11
  workingDir?: string;
12
12
  }
13
- export declare const _glob: ({ cwd, workingDir, patterns, gitignore }: GlobOptions) => Promise<string[]>;
14
- export declare const _pureGlob: ({ cwd, patterns, gitignore }: BaseGlobOptions) => Promise<string[]>;
15
- export declare const _firstGlob: ({ cwd, patterns }: BaseGlobOptions) => Promise<string | Buffer | undefined>;
16
- export declare const _dirGlob: ({ cwd, patterns, gitignore }: BaseGlobOptions) => Promise<string[]>;
13
+ export declare const _glob: ({ cwd, workingDir, patterns, gitignore }: GlobOptions) => unknown;
14
+ export declare const _pureGlob: ({ cwd, patterns, gitignore }: BaseGlobOptions) => unknown;
15
+ export declare const _firstGlob: ({ cwd, patterns }: BaseGlobOptions) => unknown;
16
+ export declare const _dirGlob: ({ cwd, patterns, gitignore }: BaseGlobOptions) => unknown;
17
17
  export {};
@@ -1,4 +1,4 @@
1
1
  import type { ConfigurationChief, Workspace } from '../ConfigurationChief.js';
2
2
  import type { DependencyDeputy } from '../DependencyDeputy.js';
3
3
  import type { IssueCollector } from '../IssueCollector.js';
4
- export declare const getHandler: (collector: IssueCollector, deputy: DependencyDeputy, chief: ConfigurationChief) => (specifier: string, containingFilePath: string, workspace: Workspace) => string | undefined;
4
+ export declare const getHandler: (collector: IssueCollector, deputy: DependencyDeputy, chief: ConfigurationChief) => (specifier: string, containingFilePath: string, workspace: Workspace) => any;
@@ -5,5 +5,5 @@ type Result = {
5
5
  reExportingEntryFile: undefined | string;
6
6
  traceNode: TraceNode;
7
7
  };
8
- export declare const getIsIdentifierReferencedHandler: (graph: DependencyGraph, entryPaths: Set<string>) => (filePath: string, id: string, isIncludeEntryExports?: boolean, traceNode?: TraceNode, seen?: Set<string>) => Result;
8
+ export declare const getIsIdentifierReferencedHandler: (graph: DependencyGraph, entryPaths: Set<string>) => (filePath: string, id: string, isIncludeEntryExports?: boolean, traceNode?: TraceNode, seen?: any) => Result;
9
9
  export {};
@@ -1 +1 @@
1
- export declare const _load: (filePath: string) => Promise<any>;
1
+ export declare const _load: (filePath: string) => unknown;
@@ -1,2 +1 @@
1
- import type { Package } from '../ConfigurationChief.js';
2
- export default function mapWorkspaces(cwd: string, workspaces: string[]): Promise<Map<string, Package>[]>;
1
+ export default function mapWorkspaces(cwd: string, workspaces: string[]): unknown;
@@ -1,9 +1,9 @@
1
1
  import type { PackageJson } from '../types/package-json.js';
2
- export declare const getPackageNameFromModuleSpecifier: (moduleSpecifier: string) => string | undefined;
3
- export declare const getPackageNameFromFilePath: (value: string) => string;
4
- export declare const normalizeSpecifierFromFilePath: (value: string) => string;
5
- export declare const isStartsLikePackageName: (specifier: string) => boolean;
6
- export declare const isDefinitelyTyped: (packageName: string) => boolean;
2
+ export declare const getPackageNameFromModuleSpecifier: (moduleSpecifier: string) => any;
3
+ export declare const getPackageNameFromFilePath: (value: string) => any;
4
+ export declare const normalizeSpecifierFromFilePath: (value: string) => any;
5
+ export declare const isStartsLikePackageName: (specifier: string) => any;
6
+ export declare const isDefinitelyTyped: (packageName: string) => any;
7
7
  export declare const getDefinitelyTypedFor: (packageName: string) => string;
8
8
  export declare const getPackageFromDefinitelyTyped: (typedDependency: string) => string;
9
9
  export declare const getEntryPathFromManifest: (manifest: PackageJson, sharedGlobOptions: {
@@ -11,5 +11,5 @@ export declare const getEntryPathFromManifest: (manifest: PackageJson, sharedGlo
11
11
  workingDir: string;
12
12
  gitignore: boolean;
13
13
  ignore: string[];
14
- }) => Promise<string[]>;
15
- export declare const sanitizeSpecifier: (specifier: string) => string;
14
+ }) => unknown;
15
+ export declare const sanitizeSpecifier: (specifier: string) => any;
@@ -1,10 +1,6 @@
1
1
  import type { PackageJson } from '../types/package-json.js';
2
- declare const INDENT: unique symbol;
3
- declare const NEWLINE: unique symbol;
4
2
  interface ExtendedPackageJson extends PackageJson {
5
- [INDENT]?: string;
6
- [NEWLINE]?: string;
7
3
  }
8
- export declare const load: (filePath: string) => Promise<ExtendedPackageJson>;
9
- export declare const save: (filePath: string, content: ExtendedPackageJson) => Promise<void>;
4
+ export declare const load: (filePath: string) => unknown;
5
+ export declare const save: (filePath: string, content: ExtendedPackageJson) => any;
10
6
  export {};
@@ -3,11 +3,11 @@ export declare const dirname: (path: string) => string;
3
3
  export declare const extname: (path: string) => string;
4
4
  export declare const basename: (path: string, suffix?: string) => string;
5
5
  export declare const join: (...paths: string[]) => string;
6
- export declare const toPosix: (value: string) => string;
7
- export declare const cwd: string;
6
+ export declare const toPosix: (value: string) => any;
7
+ export declare const cwd: any;
8
8
  export declare const resolve: (...paths: string[]) => string;
9
- export declare const relative: (from: string, to?: string) => string;
10
- export declare const isInNodeModules: (filePath: string) => boolean;
9
+ export declare const relative: (from: string, to?: string) => any;
10
+ export declare const isInNodeModules: (filePath: string) => any;
11
11
  export declare const toAbsolute: (id: string, base?: string) => string;
12
- export declare const toRelative: (id: string) => string;
13
- export declare const isInternal: (id: string) => boolean;
12
+ export declare const toRelative: (id: string) => any;
13
+ export declare const isInternal: (id: string) => any;