knip 6.16.1 → 6.17.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.
@@ -1,4 +1,4 @@
1
- import type { Configuration, IgnorePatterns, RawConfiguration, SourceMap, WorkspaceConfiguration } from './types/config.ts';
1
+ import type { Configuration, IgnoreIssues, IgnorePatterns, RawConfiguration, SourceMap, WorkspaceConfiguration } from './types/config.ts';
2
2
  import type { ConfigurationHint } from './types/issues.ts';
3
3
  import type { WorkspacePackage } from './types/package-json.ts';
4
4
  import type { MainOptions } from './util/create-options.ts';
@@ -842,6 +842,7 @@ export declare class ConfigurationChief {
842
842
  ignoreMembers?: (string | RegExp)[] | undefined;
843
843
  ignoreUnresolved?: (string | RegExp)[] | undefined;
844
844
  ignoreExportsUsedInFile?: boolean | Record<string, boolean | undefined> | undefined;
845
+ ignoreIssues?: Record<string, ("binaries" | "catalog" | "dependencies" | "devDependencies" | "duplicates" | "enumMembers" | "exports" | "files" | "namespaceMembers" | "nsExports" | "nsTypes" | "optionalPeerDependencies" | "types" | "unlisted" | "unresolved")[]> | undefined;
845
846
  includeEntryExports?: boolean | undefined;
846
847
  };
847
848
  getIgnores(workspaceName: string): {
@@ -849,6 +850,7 @@ export declare class ConfigurationChief {
849
850
  ignoreDependencies: (string | RegExp)[];
850
851
  ignoreUnresolved: (string | RegExp)[];
851
852
  };
853
+ getIgnoreIssues(): IgnoreIssues;
852
854
  getConfigForWorkspace(workspaceName: string, extensions?: string[]): {
853
855
  entry: string[];
854
856
  project: string[];
@@ -4,7 +4,7 @@ import { pluginNames } from './types/PluginNames.js';
4
4
  import { arrayify, compact, partition } from './util/array.js';
5
5
  import { createWorkspaceGraph } from './util/create-workspace-graph.js';
6
6
  import { isDirectory, isFile } from './util/fs.js';
7
- import { _dirGlob, removeProductionSuffix } from './util/glob.js';
7
+ import { _dirGlob, prependDirToPattern, removeProductionSuffix } from './util/glob.js';
8
8
  import { graphSequencer } from './util/graph-sequencer.js';
9
9
  import mapWorkspaces from './util/map-workspaces.js';
10
10
  import { join, relative } from './util/path.js';
@@ -324,6 +324,21 @@ export class ConfigurationChief {
324
324
  }
325
325
  return { ignoreBinaries, ignoreDependencies, ignoreUnresolved };
326
326
  }
327
+ getIgnoreIssues() {
328
+ const ignoreIssues = { ...this.config.ignoreIssues };
329
+ for (const name of this.availableWorkspaceNames) {
330
+ if (name === ROOT_WORKSPACE_NAME)
331
+ continue;
332
+ const workspaceIgnoreIssues = this.getWorkspaceConfig(name).ignoreIssues;
333
+ if (!workspaceIgnoreIssues)
334
+ continue;
335
+ for (const [pattern, issueTypes] of Object.entries(workspaceIgnoreIssues)) {
336
+ const id = prependDirToPattern(name, pattern);
337
+ ignoreIssues[id] = ignoreIssues[id] ? [...ignoreIssues[id], ...issueTypes] : issueTypes;
338
+ }
339
+ }
340
+ return ignoreIssues;
341
+ }
327
342
  getConfigForWorkspace(workspaceName, extensions) {
328
343
  const baseConfig = getDefaultWorkspaceConfig(extensions);
329
344
  const workspaceConfig = this.getWorkspaceConfig(workspaceName);
@@ -37,6 +37,7 @@ export declare class DependencyDeputy {
37
37
  requiredPeerDependencies: DependencyArray;
38
38
  allDependencies: DependencySet;
39
39
  engines: Record<string, string>;
40
+ isPrivate: boolean;
40
41
  ignoreDependencies: (string | RegExp)[];
41
42
  ignoreBinaries: (string | RegExp)[];
42
43
  ignoreUnresolved: (string | RegExp)[];
@@ -71,6 +71,7 @@ export class DependencyDeputy {
71
71
  requiredPeerDependencies,
72
72
  allDependencies: new Set(allDependencies),
73
73
  engines: manifest.engines ?? {},
74
+ isPrivate: Boolean(manifest.private),
74
75
  });
75
76
  }
76
77
  getWorkspaceManifest(workspaceName) {
@@ -145,7 +146,7 @@ export class DependencyDeputy {
145
146
  return true;
146
147
  if (this._manifests.get(workspace.name)?.engines[packageName])
147
148
  return true;
148
- if (!this.isStrict && this.workspacePkgNames.has(packageName)) {
149
+ if (!this.isStrict && this.workspacePkgNames.has(packageName) && this._manifests.get(workspace.name)?.isPrivate) {
149
150
  this.addReferencedDependency(workspace.name, packageName);
150
151
  return true;
151
152
  }
@@ -1,5 +1,6 @@
1
1
  import picomatch from 'picomatch';
2
2
  import { partition } from './util/array.js';
3
+ import { prependDirToPattern } from './util/glob.js';
3
4
  import { initCounters, initIssues } from './util/issue-initializers.js';
4
5
  import { relative } from './util/path.js';
5
6
  const createMatcher = (patterns) => {
@@ -75,11 +76,12 @@ export class IssueCollector {
75
76
  return;
76
77
  const issueTypePatterns = new Map();
77
78
  for (const [pattern, issueTypes] of Object.entries(ignoreIssues)) {
79
+ const id = prependDirToPattern(this.cwd, pattern);
78
80
  for (const issueType of issueTypes) {
79
81
  if (!issueTypePatterns.has(issueType)) {
80
82
  issueTypePatterns.set(issueType, []);
81
83
  }
82
- issueTypePatterns.get(issueType)?.push(pattern);
84
+ issueTypePatterns.get(issueType)?.push(id);
83
85
  }
84
86
  }
85
87
  for (const [issueType, patterns] of issueTypePatterns) {
@@ -90,7 +92,7 @@ export class IssueCollector {
90
92
  const matcher = this.issueMatchers.get(issueType);
91
93
  if (!matcher)
92
94
  return false;
93
- return matcher(relative(this.cwd, filePath));
95
+ return matcher(filePath);
94
96
  }
95
97
  addFileCounts({ processed, unused }) {
96
98
  this.counters.processed += processed;
@@ -20,6 +20,7 @@ export declare class ProjectPrincipal {
20
20
  asyncCompilers: AsyncCompilers;
21
21
  private paths;
22
22
  private rootDirs;
23
+ private tsConfigFile;
23
24
  private extensions;
24
25
  cache: CacheConsultant<FileNode>;
25
26
  toSourceFilePath: ToSourceFilePath;
@@ -30,6 +30,7 @@ export class ProjectPrincipal {
30
30
  asyncCompilers = new Map();
31
31
  paths = new Map();
32
32
  rootDirs = new Map();
33
+ tsConfigFile;
33
34
  extensions = new Set(DEFAULT_EXTENSIONS);
34
35
  cache;
35
36
  toSourceFilePath;
@@ -43,6 +44,7 @@ export class ProjectPrincipal {
43
44
  this.cache = new CacheConsultant('root', options);
44
45
  this.toSourceFilePath = toSourceFilePath;
45
46
  this.findWorkspaceManifestImports = findWorkspaceManifestImports;
47
+ this.tsConfigFile = options.tsConfigFile ? toAbsolute(options.tsConfigFile, options.cwd) : undefined;
46
48
  this.pluginVisitorObjects.push(createBunShellVisitor(this.pluginCtx));
47
49
  this.fileManager = new SourceFileManager({
48
50
  compilers: [this.syncCompilers, this.asyncCompilers],
@@ -87,7 +89,7 @@ export class ProjectPrincipal {
87
89
  const customCompilerExtensions = getCompilerExtensions([this.syncCompilers, this.asyncCompilers]);
88
90
  const scopedPaths = this.paths.size > 0 ? Array.from(this.paths, ([scope, paths]) => ({ scope, paths })) : undefined;
89
91
  const scopedRootDirs = this.rootDirs.size > 0 ? Array.from(this.rootDirs, ([scope, rootDirs]) => ({ scope, rootDirs })) : undefined;
90
- this.resolveModule = createCustomModuleResolver({ scopedPaths, scopedRootDirs }, customCompilerExtensions, this.toSourceFilePath, this.findWorkspaceManifestImports);
92
+ this.resolveModule = createCustomModuleResolver({ scopedPaths, scopedRootDirs }, customCompilerExtensions, this.toSourceFilePath, this.findWorkspaceManifestImports, this.tsConfigFile);
91
93
  }
92
94
  readFile(filePath) {
93
95
  return this.fileManager.readFile(filePath);
@@ -1585,6 +1585,7 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
1585
1585
  ignoreMembers?: (string | RegExp)[] | undefined;
1586
1586
  ignoreUnresolved?: (string | RegExp)[] | undefined;
1587
1587
  ignoreExportsUsedInFile?: boolean | Record<string, boolean | undefined> | undefined;
1588
+ ignoreIssues?: Record<string, ("binaries" | "catalog" | "dependencies" | "devDependencies" | "duplicates" | "enumMembers" | "exports" | "files" | "namespaceMembers" | "nsExports" | "nsTypes" | "optionalPeerDependencies" | "types" | "unlisted" | "unresolved")[]> | undefined;
1588
1589
  includeEntryExports?: boolean | undefined;
1589
1590
  }> | undefined;
1590
1591
  syncCompilers: Record<string, true | CompilerSync>;
@@ -2,6 +2,8 @@ import { basename, dirname } from '../util/path.js';
2
2
  const condition = (hasDependency) => hasDependency('sass') || hasDependency('sass-embedded') || hasDependency('node-sass');
3
3
  const importMatcher = /@(?:use|import|forward)\s+['"](pkg:)?([^'"]+)['"]/g;
4
4
  const isAlias = (s) => (s.charCodeAt(0) === 64 && s.charCodeAt(1) === 47) || s.charCodeAt(0) === 126 || s.charCodeAt(0) === 35;
5
+ const isScopedPackage = (s) => s.charCodeAt(0) === 64 && s.charCodeAt(1) !== 47;
6
+ const isTildePackage = (s) => s.charCodeAt(0) === 126 && s.charCodeAt(1) !== 47;
5
7
  const candidates = (specifier) => {
6
8
  const spec = specifier.startsWith('.') || isAlias(specifier) ? specifier : `./${specifier}`;
7
9
  const name = basename(spec);
@@ -20,10 +22,15 @@ const compiler = text => {
20
22
  const out = [];
21
23
  let i = 0;
22
24
  for (const match of text.matchAll(importMatcher)) {
23
- const spec = match[2];
25
+ let spec = match[2];
24
26
  if (!spec || spec.startsWith('sass:'))
25
27
  continue;
26
- const specs = match[1] ? [spec] : candidates(spec);
28
+ let isBare = Boolean(match[1]) || isScopedPackage(spec);
29
+ if (isTildePackage(spec)) {
30
+ spec = spec.slice(1);
31
+ isBare = true;
32
+ }
33
+ const specs = isBare ? [spec] : candidates(spec);
27
34
  for (const s of specs)
28
35
  out.push(`import _$${i++} from '${s}';`);
29
36
  }
package/dist/constants.js CHANGED
@@ -111,6 +111,7 @@ export const IGNORED_GLOBAL_BINARIES = new Set([
111
111
  'sudo',
112
112
  'sync',
113
113
  'tac',
114
+ 'tar',
114
115
  'tee',
115
116
  'test',
116
117
  'time',
@@ -8,7 +8,8 @@ const config = ['capacitor.config.{json,ts}'];
8
8
  const resolveConfig = async (config, { configFileDir }) => {
9
9
  const plugins = config.includePlugins ?? [];
10
10
  const android = isFile(configFileDir, 'android/capacitor.settings.gradle') ? ['@capacitor/android'] : [];
11
- const ios = isFile(configFileDir, 'ios/App/Podfile') ? ['@capacitor/ios'] : [];
11
+ const hasIOS = isFile(configFileDir, 'ios/App/Podfile') || isFile(configFileDir, 'ios/App/CapApp-SPM/Package.swift');
12
+ const ios = hasIOS ? ['@capacitor/ios'] : [];
12
13
  return [...plugins, ...android, ...ios].map(id => toDependency(id));
13
14
  };
14
15
  const plugin = {
@@ -4,7 +4,7 @@ import { toCosmiconfig } from '../../util/plugin-config.js';
4
4
  const title = 'commitlint';
5
5
  const enablers = ['@commitlint/cli'];
6
6
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
7
- const config = ['package.json', 'package.yaml', ...toCosmiconfig('commitlint', { additionalExtensions: ['cts'] })];
7
+ const config = ['package.json', 'package.yaml', ...toCosmiconfig('commitlint', { additionalExtensions: ['cts', 'mts'] })];
8
8
  const resolveConfig = async (config) => {
9
9
  const extendsConfigs = config.extends
10
10
  ? [config.extends]
@@ -70,8 +70,12 @@ const hintTypesOrder = [
70
70
  ['project-extension-unregistered'],
71
71
  ['package-entry'],
72
72
  ];
73
+ const UNCONFIGURED_MIN_FILES = 20;
74
+ const UNCONFIGURED_MIN_RATIO = 0.2;
73
75
  export const finalizeConfigurationHints = (results, options) => {
74
- if (results.counters.files > 20) {
76
+ const { files, processed } = results.counters;
77
+ const unusedFileRatio = processed > 0 ? files / processed : 0;
78
+ if (files > UNCONFIGURED_MIN_FILES && unusedFileRatio > UNCONFIGURED_MIN_RATIO) {
75
79
  const workspaces = results.includedWorkspaceDirs
76
80
  .sort(byPathDepth)
77
81
  .reverse()
package/dist/run.js CHANGED
@@ -33,7 +33,7 @@ export const run = async (options) => {
33
33
  const findWorkspaceManifestImports = getWorkspaceManifestHandler(chief);
34
34
  const principal = new ProjectPrincipal(options, toSourceFilePath, findWorkspaceManifestImports);
35
35
  collector.setWorkspaceFilter(chief.workspaceFilePathFilter);
36
- collector.setIgnoreIssues(chief.config.ignoreIssues);
36
+ collector.setIgnoreIssues(chief.getIgnoreIssues());
37
37
  debugLogObject('*', 'Included workspaces', () => workspaces.map(w => w.pkgName));
38
38
  debugLogObject('*', 'Included workspace configs', () => workspaces.map(w => ({ pkgName: w.pkgName, name: w.name, config: w.config, ancestors: w.ancestors })));
39
39
  const { graph, entryPaths, analyzedFiles, unreferencedFiles, analyzeSourceFile, enabledPluginsStore } = await build({
@@ -788,6 +788,7 @@ export declare const workspaceConfigurationSchema: z.ZodMiniObject<{
788
788
  ignoreExportsUsedInFile: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniObject<{
789
789
  [x: string]: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
790
790
  }, z.core.$strict>]>>;
791
+ ignoreIssues: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"files">, z.ZodMiniLiteral<"dependencies">, z.ZodMiniLiteral<"devDependencies">, z.ZodMiniLiteral<"optionalPeerDependencies">, z.ZodMiniLiteral<"unlisted">, z.ZodMiniLiteral<"binaries">, z.ZodMiniLiteral<"unresolved">, z.ZodMiniLiteral<"exports">, z.ZodMiniLiteral<"types">, z.ZodMiniLiteral<"nsExports">, z.ZodMiniLiteral<"nsTypes">, z.ZodMiniLiteral<"duplicates">, z.ZodMiniLiteral<"enumMembers">, z.ZodMiniLiteral<"namespaceMembers">, z.ZodMiniLiteral<"catalog">]>>>>;
791
792
  includeEntryExports: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
792
793
  }, z.core.$strict>;
793
794
  export declare const knipConfigurationSchema: z.ZodMiniObject<{
@@ -2383,6 +2384,7 @@ export declare const knipConfigurationSchema: z.ZodMiniObject<{
2383
2384
  ignoreExportsUsedInFile: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniObject<{
2384
2385
  [x: string]: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
2385
2386
  }, z.core.$strict>]>>;
2387
+ ignoreIssues: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"files">, z.ZodMiniLiteral<"dependencies">, z.ZodMiniLiteral<"devDependencies">, z.ZodMiniLiteral<"optionalPeerDependencies">, z.ZodMiniLiteral<"unlisted">, z.ZodMiniLiteral<"binaries">, z.ZodMiniLiteral<"unresolved">, z.ZodMiniLiteral<"exports">, z.ZodMiniLiteral<"types">, z.ZodMiniLiteral<"nsExports">, z.ZodMiniLiteral<"nsTypes">, z.ZodMiniLiteral<"duplicates">, z.ZodMiniLiteral<"enumMembers">, z.ZodMiniLiteral<"namespaceMembers">, z.ZodMiniLiteral<"catalog">]>>>>;
2386
2388
  includeEntryExports: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
2387
2389
  }, z.core.$strict>>>;
2388
2390
  }, z.core.$strict>;
@@ -67,6 +67,7 @@ const baseWorkspaceConfigurationSchema = z.object({
67
67
  ignoreMembers: z.optional(stringOrRegexSchema),
68
68
  ignoreUnresolved: z.optional(stringOrRegexSchema),
69
69
  ignoreExportsUsedInFile: z.optional(ignoreExportsUsedInFileSchema),
70
+ ignoreIssues: z.optional(ignoreIssuesSchema),
70
71
  includeEntryExports: z.optional(z.boolean()),
71
72
  });
72
73
  const partialPluginsSchema = z.partial(pluginsSchema);
@@ -30,6 +30,7 @@ export type PackageJson = {
30
30
  main?: string;
31
31
  bin?: string | Record<string, string>;
32
32
  version?: string;
33
+ private?: boolean;
33
34
  workspaces?: string[] | {
34
35
  packages?: string[];
35
36
  catalog?: Catalog;
@@ -17,7 +17,6 @@ export interface CompilerOptions {
17
17
  noEmit?: boolean;
18
18
  outDir?: string;
19
19
  paths?: Record<string, string[]>;
20
- pathsBasePath?: string;
21
20
  plugins?: Array<{
22
21
  name: string;
23
22
  } | string>;
@@ -11,6 +11,7 @@ type WorkspaceManifest = {
11
11
  requiredPeerDependencies: DependencyArray;
12
12
  allDependencies: DependencySet;
13
13
  engines: Record<string, string>;
14
+ isPrivate: boolean;
14
15
  ignoreDependencies: (string | RegExp)[];
15
16
  ignoreBinaries: (string | RegExp)[];
16
17
  ignoreUnresolved: (string | RegExp)[];
@@ -12,5 +12,5 @@ export declare function clearModuleResolutionCaches(): void;
12
12
  export declare function createCustomModuleResolver(compilerOptions: {
13
13
  scopedPaths?: ScopedPaths;
14
14
  scopedRootDirs?: ScopedRootDirs;
15
- }, customCompilerExtensions: string[], toSourceFilePath: ToSourceFilePath, findWorkspaceManifestImports?: WorkspaceManifestHandler): ResolveModule;
15
+ }, customCompilerExtensions: string[], toSourceFilePath: ToSourceFilePath, findWorkspaceManifestImports?: WorkspaceManifestHandler, tsConfigFile?: string): ResolveModule;
16
16
  export {};
@@ -56,11 +56,11 @@ function compileRootDirs(scopedRootDirs) {
56
56
  scoped.sort((a, b) => b.scope.length - a.scope.length);
57
57
  return scoped;
58
58
  }
59
- export function createCustomModuleResolver(compilerOptions, customCompilerExtensions, toSourceFilePath, findWorkspaceManifestImports) {
59
+ export function createCustomModuleResolver(compilerOptions, customCompilerExtensions, toSourceFilePath, findWorkspaceManifestImports, tsConfigFile) {
60
60
  const customCompilerExtensionsSet = new Set(customCompilerExtensions);
61
61
  const hasCustomExts = customCompilerExtensionsSet.size > 0;
62
- const extensions = [...DEFAULT_EXTENSIONS, ...customCompilerExtensions, ...DTS_EXTENSIONS];
63
- const resolveSync = hasCustomExts ? _createSyncModuleResolver(extensions) : _resolveModuleSync;
62
+ const extensions = [...DEFAULT_EXTENSIONS, ...customCompilerExtensions, ...DTS_EXTENSIONS, '.json', '.jsonc'];
63
+ const resolveSync = hasCustomExts || tsConfigFile ? _createSyncModuleResolver(extensions, tsConfigFile) : _resolveModuleSync;
64
64
  const pathMappings = compilePathMappings(compilerOptions.scopedPaths);
65
65
  const rootDirMappings = compileRootDirs(compilerOptions.scopedRootDirs);
66
66
  function toSourcePath(resolvedFileName) {
@@ -1627,6 +1627,7 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
1627
1627
  ignoreMembers?: (string | RegExp)[] | undefined;
1628
1628
  ignoreUnresolved?: (string | RegExp)[] | undefined;
1629
1629
  ignoreExportsUsedInFile?: boolean | Record<string, boolean | undefined> | undefined;
1630
+ ignoreIssues?: Record<string, ("binaries" | "catalog" | "dependencies" | "devDependencies" | "duplicates" | "enumMembers" | "exports" | "files" | "namespaceMembers" | "nsExports" | "nsTypes" | "optionalPeerDependencies" | "types" | "unlisted" | "unresolved")[]> | undefined;
1630
1631
  includeEntryExports?: boolean | undefined;
1631
1632
  }> | undefined;
1632
1633
  };
@@ -88,7 +88,7 @@ export const createOptions = async (options) => {
88
88
  if (!value)
89
89
  rules[key] = 'off';
90
90
  }
91
- const fixTypes = options.fixTypes ?? args['fix-type'] ?? [];
91
+ const fixTypes = (options.fixTypes ?? args['fix-type'] ?? []).flatMap(type => type.split(','));
92
92
  const isFixFiles = args['allow-remove-files'] && (fixTypes.length === 0 || fixTypes.includes('files'));
93
93
  const tags = splitTags(args.tags ?? options.tags ?? parsedConfig.tags ?? []);
94
94
  const workspace = options.workspace ?? args.workspace;
@@ -96,9 +96,6 @@ export const loadTSConfig = async (tsConfigFilePath) => {
96
96
  compilerOptions.rootDir = absDir(compilerOptions.rootDir, dir);
97
97
  if (compilerOptions.rootDirs)
98
98
  compilerOptions.rootDirs = compilerOptions.rootDirs.map(d => absDir(d, dir));
99
- if (compilerOptions.paths) {
100
- compilerOptions.pathsBasePath ??= dir;
101
- }
102
99
  const sourceMapPairs = [];
103
100
  if (config.references?.length) {
104
101
  walkReferences(compilerOptions, config.references, dir, new Set([tsConfigFilePath]), sourceMapPairs);
@@ -1,4 +1,4 @@
1
1
  export declare const _resolveModuleSync: (specifier: string, basePath: string) => string | undefined;
2
- export declare const _createSyncModuleResolver: (extensions: string[]) => (specifier: string, basePath: string) => string | undefined;
2
+ export declare const _createSyncModuleResolver: (extensions: string[], tsConfigFile?: string) => (specifier: string, basePath: string) => string | undefined;
3
3
  export declare function clearResolverCache(): void;
4
4
  export declare const _resolveSync: (specifier: string, baseDir: string) => string | undefined;
@@ -9,16 +9,17 @@ const extensionAlias = {
9
9
  '.cjs': ['.cjs', '.cts', '.d.cts'],
10
10
  };
11
11
  const resolverInstances = [];
12
- const createSyncModuleResolver = (extensions, alias) => {
13
- const aliasOpt = alias && { alias };
12
+ const createSyncModuleResolver = (extensions, tsConfigFile) => {
14
13
  const baseOptions = {
15
14
  extensions,
16
15
  extensionAlias,
17
16
  conditionNames: ['require', 'import', 'node', 'default'],
18
17
  nodePath: false,
19
- ...aliasOpt,
20
18
  };
21
- const resolver = new ResolverFactory({ tsconfig: 'auto', ...baseOptions });
19
+ const resolver = new ResolverFactory({
20
+ tsconfig: tsConfigFile ? { configFile: tsConfigFile, references: 'auto' } : 'auto',
21
+ ...baseOptions,
22
+ });
22
23
  const fallbackResolver = new ResolverFactory(baseOptions);
23
24
  resolverInstances.push(resolver, fallbackResolver);
24
25
  return function resolveSync(specifier, basePath) {
@@ -34,7 +35,7 @@ const createSyncModuleResolver = (extensions, alias) => {
34
35
  };
35
36
  const resolveModuleSync = createSyncModuleResolver([...DEFAULT_EXTENSIONS, ...DTS_EXTENSIONS, '.json', '.jsonc']);
36
37
  export const _resolveModuleSync = timerify(resolveModuleSync, 'resolveModuleSync');
37
- export const _createSyncModuleResolver = (extensions) => timerify(createSyncModuleResolver(extensions), 'resolveModuleSync');
38
+ export const _createSyncModuleResolver = (extensions, tsConfigFile) => timerify(createSyncModuleResolver(extensions, tsConfigFile), 'resolveModuleSync');
38
39
  const createSyncResolver = (extensions) => {
39
40
  const resolver = new ResolverFactory({
40
41
  extensions,
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "6.16.1";
1
+ export declare const version = "6.17.1";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '6.16.1';
1
+ export const version = '6.17.1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "6.16.1",
3
+ "version": "6.17.1",
4
4
  "description": "Find and fix unused dependencies, exports and files in your TypeScript and JavaScript projects",
5
5
  "keywords": [
6
6
  "analysis",
@@ -81,25 +81,25 @@
81
81
  "formatly": "^0.3.0",
82
82
  "get-tsconfig": "4.14.0",
83
83
  "jiti": "^2.7.0",
84
- "oxc-parser": "^0.133.0",
84
+ "oxc-parser": "^0.135.0",
85
85
  "oxc-resolver": "^11.20.0",
86
86
  "picomatch": "^4.0.4",
87
87
  "smol-toml": "^1.6.1",
88
88
  "strip-json-comments": "5.0.3",
89
- "tinyglobby": "^0.2.16",
90
- "unbash": "^3.0.0",
89
+ "tinyglobby": "^0.2.17",
90
+ "unbash": "^4.0.1",
91
91
  "yaml": "^2.9.0",
92
92
  "zod": "^4.1.11"
93
93
  },
94
94
  "devDependencies": {
95
- "@jest/types": "^29.6.3",
96
- "@types/bun": "^1.3.3",
97
- "@types/picomatch": "^4.0.1",
95
+ "@jest/types": "^30.4.1",
96
+ "@types/bun": "^1.3.14",
97
+ "@types/picomatch": "^4.0.3",
98
98
  "@types/webpack": "^5.28.5",
99
- "@typescript/native-preview": "7.0.0-dev.20260512.1",
99
+ "@typescript/native-preview": "7.0.0-dev.20260612.1",
100
100
  "codeclimate-types": "^0.3.1",
101
- "prettier": "^3.8.1",
102
- "tsx": "^4.21.0"
101
+ "prettier": "^3.8.4",
102
+ "tsx": "^4.22.4"
103
103
  },
104
104
  "engines": {
105
105
  "node": "^20.19.0 || >=22.12.0"
package/schema.json CHANGED
@@ -316,6 +316,19 @@
316
316
  "ignoreExportsUsedInFile": {
317
317
  "$ref": "#/definitions/ignoreExportsUsedInFile"
318
318
  },
319
+ "ignoreIssues": {
320
+ "title": " Ignore specific issue types for specific file patterns (relative to the workspace root)",
321
+ "examples": [
322
+ {
323
+ "src/generated/**": ["exports", "types"],
324
+ "**/*.generated.ts": ["exports"]
325
+ }
326
+ ],
327
+ "type": "object",
328
+ "additionalProperties": {
329
+ "$ref": "#/definitions/issueTypes"
330
+ }
331
+ },
319
332
  "includeEntryExports": {
320
333
  "$ref": "#/definitions/includeEntryExports"
321
334
  }