knip 3.0.0-canary.3 → 3.0.0

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.
@@ -5,6 +5,7 @@ import type { PrincipalOptions } from './PrincipalFactory.js';
5
5
  import type { SyncCompilers, AsyncCompilers } from './types/compilers.js';
6
6
  import type { ExportItem, ExportItemMember } from './types/exports.js';
7
7
  import type { UnresolvedImport } from './types/imports.js';
8
+ import type { ProgramMaybe53 } from './typescript/SourceFile.js';
8
9
  import type { GlobbyFilterFunction } from 'globby';
9
10
  export declare class ProjectPrincipal {
10
11
  entryPaths: Set<string>;
@@ -21,7 +22,7 @@ export declare class ProjectPrincipal {
21
22
  compilerHost: ts.CompilerHost;
22
23
  resolveModuleNames: ReturnType<typeof createCustomModuleResolver>;
23
24
  lsFindReferences: ts.LanguageService['findReferences'];
24
- program?: ts.Program;
25
+ program?: ProgramMaybe53;
25
26
  };
26
27
  constructor({ compilerOptions, cwd, compilers, isGitIgnored }: PrincipalOptions);
27
28
  private createProgram;
@@ -111,7 +111,13 @@ export class ProjectPrincipal {
111
111
  if (!sourceFile)
112
112
  throw new Error(`Unable to find ${filePath}`);
113
113
  const skipExports = this.skipExportsAnalysis.has(filePath);
114
- const { imports, exports, scripts } = getImportsAndExports(sourceFile, { skipTypeOnly, skipExports });
114
+ const getResolvedModule = specifier => this.backend.program?.getResolvedModule
115
+ ? this.backend.program.getResolvedModule(sourceFile, specifier, undefined)
116
+ : sourceFile.resolvedModules?.get(specifier, undefined);
117
+ const { imports, exports, scripts } = getImportsAndExports(sourceFile, getResolvedModule, {
118
+ skipTypeOnly,
119
+ skipExports,
120
+ });
115
121
  const { internal, unresolved, external } = imports;
116
122
  const unresolvedImports = new Set();
117
123
  unresolved.forEach(unresolvedImport => {
@@ -4,7 +4,7 @@ import { tryResolveFilePath, tryResolveSpecifiers } from '../util.js';
4
4
  export const resolve = (binary, args, { cwd }) => {
5
5
  const parsed = parseArgs(args, {
6
6
  string: ['r'],
7
- alias: { require: ['r', 'loader', 'experimental-loader', 'test-reporter', 'watch'] },
7
+ alias: { require: ['r', 'loader', 'experimental-loader', 'test-reporter', 'watch', 'import'] },
8
8
  });
9
9
  return compact([tryResolveFilePath(cwd, parsed._[0]), ...tryResolveSpecifiers(cwd, [parsed.require].flat())]);
10
10
  };
@@ -5,7 +5,6 @@ export declare const DEFAULT_EXTENSIONS: string[];
5
5
  export declare const GLOBAL_IGNORE_PATTERNS: string[];
6
6
  export declare const IGNORED_GLOBAL_BINARIES: string[];
7
7
  export declare const IGNORED_DEPENDENCIES: string[];
8
- export declare const VIRTUAL_FILE_EXTENSIONS: string[];
9
8
  export declare const IGNORED_FILE_EXTENSIONS: string[];
10
9
  export declare const IGNORE_DEFINITELY_TYPED: string[];
11
10
  export declare const ISSUE_TYPES: IssueType[];
package/dist/constants.js CHANGED
@@ -35,12 +35,12 @@ export const IGNORED_GLOBAL_BINARIES = [
35
35
  'yarn',
36
36
  ];
37
37
  export const IGNORED_DEPENDENCIES = ['knip', 'typescript'];
38
- export const VIRTUAL_FILE_EXTENSIONS = ['.css', '.html', '.svg'];
39
38
  export const IGNORED_FILE_EXTENSIONS = [
40
- ...VIRTUAL_FILE_EXTENSIONS,
41
39
  '.avif',
40
+ '.css',
42
41
  '.eot',
43
42
  '.gif',
43
+ '.html',
44
44
  '.ico',
45
45
  '.jpeg',
46
46
  '.jpg',
@@ -49,6 +49,7 @@ export const IGNORED_FILE_EXTENSIONS = [
49
49
  '.sass',
50
50
  '.scss',
51
51
  '.sh',
52
+ '.svg',
52
53
  '.ttf',
53
54
  '.webp',
54
55
  '.woff',
@@ -1,5 +1,4 @@
1
- export declare const resolvePluginName: (pluginName: string) => string;
2
- export declare const resolvePresetName: (pluginName: string) => string;
1
+ export declare const resolveName: (identifier: string, namespace: 'preset' | 'plugin') => string;
3
2
  export declare const api: {
4
3
  assertVersion: () => boolean;
5
4
  cache: {
@@ -1,24 +1,32 @@
1
- export const resolvePluginName = (pluginName) => {
2
- if (!/babel/.test(pluginName))
3
- return `babel-plugin-${pluginName}`;
4
- if (pluginName.startsWith('@babel/')) {
5
- if (pluginName.startsWith('@babel/plugin'))
6
- return pluginName;
7
- const [, name] = pluginName.split('/');
8
- return `@babel/plugin-${name}`;
1
+ import { isAbsolute, isInternal } from '../../util/path.js';
2
+ export const resolveName = (identifier, namespace) => {
3
+ if (isAbsolute(identifier) || isInternal(identifier))
4
+ return identifier;
5
+ if (identifier.startsWith('module:'))
6
+ return identifier.replace(/^module:/, '');
7
+ if (identifier.startsWith('@')) {
8
+ const [scope, name, ...rest] = identifier.split('/');
9
+ if (rest.length > 0)
10
+ return identifier;
11
+ if (scope) {
12
+ if (!name)
13
+ return [scope, `babel-${namespace}`].join('/');
14
+ if (scope === '@babel') {
15
+ if (name.startsWith(namespace))
16
+ return identifier;
17
+ return `@babel/${namespace}-${name}`;
18
+ }
19
+ if (name.includes(`babel-${namespace}`))
20
+ return identifier;
21
+ return [scope, `babel-${namespace}-${name}`].join('/');
22
+ }
9
23
  }
10
- return pluginName;
11
- };
12
- export const resolvePresetName = (pluginName) => {
13
- if (!/babel/.test(pluginName))
14
- return `babel-preset-${pluginName}`;
15
- if (pluginName.startsWith('@babel/')) {
16
- if (pluginName.startsWith('@babel/preset'))
17
- return pluginName;
18
- const [, name] = pluginName.split('/');
19
- return `@babel/preset-${name}`;
20
- }
21
- return pluginName;
24
+ const [name, ...rest] = identifier.split('/');
25
+ if (rest.length > 0)
26
+ return identifier;
27
+ if (name.startsWith(`babel-${namespace}`))
28
+ return identifier;
29
+ return `babel-${namespace}-${name}`;
22
30
  };
23
31
  const cacheFn = () => void 0;
24
32
  cacheFn.forever = () => cacheFn;
@@ -1,22 +1,20 @@
1
1
  import { compact } from '../../util/array.js';
2
2
  import { timerify } from '../../util/Performance.js';
3
3
  import { hasDependency, load } from '../../util/plugin.js';
4
- import { resolvePresetName, resolvePluginName, api } from './helpers.js';
4
+ import { resolveName, api } from './helpers.js';
5
5
  export const NAME = 'Babel';
6
6
  export const ENABLERS = [/^@babel\//];
7
7
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
8
8
  export const CONFIG_FILE_PATTERNS = [
9
- 'babel.config.json',
10
- 'babel.config.js',
11
- '.babelrc.json',
12
- '.babelrc.js',
9
+ 'babel.config.{json,js,cjs,mjs,cts}',
10
+ '.babelrc.{json,js,cjs,mjs,cts}',
13
11
  '.babelrc',
14
12
  'package.json',
15
13
  ];
16
- const getItemName = (value) => typeof value === 'string' ? [value] : Array.isArray(value) ? [value[0]] : [];
14
+ const getName = (value) => typeof value === 'string' ? [value] : Array.isArray(value) ? [value[0]] : [];
17
15
  export const getDependenciesFromConfig = (config) => {
18
- const presets = config.presets?.flatMap(getItemName).map(resolvePresetName) ?? [];
19
- const plugins = config.plugins?.flatMap(getItemName).map(resolvePluginName) ?? [];
16
+ const presets = config.presets?.flatMap(getName).map(name => resolveName(name, 'preset')) ?? [];
17
+ const plugins = config.plugins?.flatMap(getName).map(name => resolveName(name, 'plugin')) ?? [];
20
18
  const nested = config.env ? Object.values(config.env).flatMap(getDependenciesFromConfig) : [];
21
19
  return compact([...presets, ...plugins, ...nested]);
22
20
  };
@@ -3,6 +3,7 @@ import { getPackageNameFromModuleSpecifier } from '../../util/modules.js';
3
3
  import { isInternal, dirname, toAbsolute } from '../../util/path.js';
4
4
  import { load } from '../../util/plugin.js';
5
5
  import { _resolve } from '../../util/require.js';
6
+ import { getDependenciesFromConfig } from '../babel/index.js';
6
7
  import { fallback } from './fallback.js';
7
8
  import { PACKAGE_JSON_PATH } from './index.js';
8
9
  const getDependencies = (config) => {
@@ -11,19 +12,12 @@ const getDependencies = (config) => {
11
12
  extendsSpecifiers.push('eslint-config-prettier');
12
13
  const plugins = config.plugins ? config.plugins.map(resolvePluginSpecifier) : [];
13
14
  const parser = config.parser;
14
- const extraPlugins = config.parserOptions?.babelOptions?.plugins ?? [];
15
- const extraParsers = config.parserOptions?.babelOptions?.presets ?? [];
15
+ const babelDependencies = config.parserOptions?.babelOptions
16
+ ? getDependenciesFromConfig(config.parserOptions.babelOptions)
17
+ : [];
16
18
  const settings = config.settings ? getDependenciesFromSettings(config.settings) : [];
17
19
  const overrides = config.overrides ? [config.overrides].flat().flatMap(getDependencies) : [];
18
- return compact([
19
- ...extendsSpecifiers,
20
- ...plugins,
21
- ...extraPlugins,
22
- parser,
23
- ...extraParsers,
24
- ...settings,
25
- ...overrides,
26
- ]);
20
+ return compact([...extendsSpecifiers, ...plugins, parser, ...babelDependencies, ...settings, ...overrides]);
27
21
  };
28
22
  export const getDependenciesDeep = async (configFilePath, options, dependencies = new Set()) => {
29
23
  const addAll = (deps) => deps.forEach(dependency => dependencies.add(dependency));
@@ -1,11 +1,18 @@
1
+ import { isInternal } from '../../util/path.js';
1
2
  import { timerify } from '../../util/Performance.js';
2
3
  import { hasDependency, load } from '../../util/plugin.js';
4
+ import { toEntryPattern } from '../../util/protocols.js';
3
5
  import { isConfigurationOutput } from './types.js';
4
6
  export const NAME = 'GraphQL Codegen';
5
7
  export const ENABLERS = [/^@graphql-codegen\//];
6
8
  export const PACKAGE_JSON_PATH = 'codegen';
7
9
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
8
- export const CONFIG_FILE_PATTERNS = ['codegen.{ts,js,json,yml,mjs,cts}', 'package.json'];
10
+ export const CONFIG_FILE_PATTERNS = [
11
+ 'codegen.{json,yml,yaml,js,ts,mjs,cts}',
12
+ '.codegenrc.{json,yml,yaml,js,ts}',
13
+ 'codegen.config.js',
14
+ 'package.json',
15
+ ];
9
16
  const findPluginDependencies = async (configFilePath, options) => {
10
17
  const { manifest, isProduction } = options;
11
18
  if (isProduction)
@@ -27,7 +34,13 @@ const findPluginDependencies = async (configFilePath, options) => {
27
34
  .map(plugin => `@graphql-codegen/${plugin}`);
28
35
  const nestedPlugins = configurationOutput
29
36
  .flatMap(configOutput => (configOutput.plugins ? configOutput.plugins : []))
30
- .map(plugin => `@graphql-codegen/${plugin}`);
37
+ .flatMap(plugin => {
38
+ if (typeof plugin !== 'string')
39
+ return [];
40
+ if (isInternal(plugin))
41
+ return [toEntryPattern(plugin)];
42
+ return [`@graphql-codegen/${plugin}`];
43
+ });
31
44
  return [...presets, ...flatPlugins, ...nestedPlugins];
32
45
  };
33
46
  export const findDependencies = timerify(findPluginDependencies);
@@ -7,7 +7,10 @@ import { getEnvPackageName, getExternalReporters } from './helpers.js';
7
7
  export const NAME = 'Vitest';
8
8
  export const ENABLERS = ['vitest'];
9
9
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
10
- export const CONFIG_FILE_PATTERNS = ['vitest.config.ts', 'vitest.{workspace,projects}.{ts,js,json}'];
10
+ export const CONFIG_FILE_PATTERNS = [
11
+ 'vitest.config.{js,mjs,ts,cjs,mts,cts}',
12
+ 'vitest.{workspace,projects}.{ts,js,json}',
13
+ ];
11
14
  export const ENTRY_FILE_PATTERNS = ['**/*.{test,spec}.?(c|m)[jt]s?(x)'];
12
15
  const resolveEntry = (containingFilePath, specifier) => {
13
16
  const dir = dirname(containingFilePath);
@@ -24,7 +27,9 @@ const findConfigDependencies = (configFilePath, localConfig, options) => {
24
27
  return entryPatterns;
25
28
  const environments = testConfig.environment ? [getEnvPackageName(testConfig.environment)] : [];
26
29
  const reporters = getExternalReporters(testConfig.reporters);
27
- const coverage = testConfig.coverage ? [`@vitest/coverage-${testConfig.coverage.provider ?? 'v8'}`] : [];
30
+ const coverage = testConfig.coverage && testConfig.coverage.enabled !== false
31
+ ? [`@vitest/coverage-${testConfig.coverage.provider ?? 'v8'}`]
32
+ : [];
28
33
  const setupFiles = [testConfig.setupFiles ?? []].flat().map(v => resolveEntry(configFilePath, v));
29
34
  const globalSetup = [testConfig.globalSetup ?? []].flat().map(v => resolveEntry(configFilePath, v));
30
35
  return [...entryPatterns, ...environments, ...reporters, ...coverage, ...setupFiles, ...globalSetup];
@@ -2,6 +2,7 @@ interface VitestConfig {
2
2
  test: {
3
3
  include: string[];
4
4
  coverage?: {
5
+ enabled?: boolean;
5
6
  provider: string;
6
7
  };
7
8
  environment?: string;
@@ -12,7 +12,8 @@ const logIssueRecord = (issues) => {
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));
14
14
  issue.symbolType && table.cell('symbolType', print(issue.symbolType));
15
- table.cell('filePath', print(relative(issue.filePath)));
15
+ const filePath = `${relative(issue.filePath)}${issue.line === undefined ? '' : `:${issue.line}${issue.col === undefined ? '' : `:${issue.col}`}`}`;
16
+ table.cell('filePath', print(filePath));
16
17
  table.newRow();
17
18
  });
18
19
  console.log(table.sort(['filePath', 'parentSymbol', 'symbol']).print().trim());
@@ -7,4 +7,4 @@ export var SymbolType;
7
7
  SymbolType["CLASS"] = "class";
8
8
  SymbolType["MEMBER"] = "member";
9
9
  SymbolType["UNKNOWN"] = "unknown";
10
- })(SymbolType = SymbolType || (SymbolType = {}));
10
+ })(SymbolType || (SymbolType = {}));
@@ -15,4 +15,8 @@ export interface BoundSourceFile extends ts.SourceFile {
15
15
  scriptKind?: ts.ScriptKind;
16
16
  pragmas?: Map<string, PragmaMap | PragmaMap[]>;
17
17
  }
18
+ export interface ProgramMaybe53 extends ts.Program {
19
+ getResolvedModule?: (f: ts.SourceFile, moduleName: string, mode: ts.ResolutionMode) => ts.ResolvedModuleWithFailedLookupLocations | undefined;
20
+ }
21
+ export type GetResolvedModule = (name: string) => ts.ResolvedModuleWithFailedLookupLocations | undefined;
18
22
  export {};
@@ -1,7 +1,6 @@
1
1
  import { EOL } from 'node:os';
2
2
  import path from 'node:path';
3
3
  import ts from 'typescript';
4
- import { VIRTUAL_FILE_EXTENSIONS } from '../constants.js';
5
4
  import { createCustomModuleResolver } from './resolveModuleNames.js';
6
5
  import { SourceFileManager } from './SourceFileManager.js';
7
6
  import { createCustomSys } from './sys.js';
@@ -9,7 +8,7 @@ const libLocation = path.dirname(ts.getDefaultLibFilePath({}));
9
8
  const fileManager = new SourceFileManager();
10
9
  export const createHosts = ({ cwd, compilerOptions, entryPaths, compilers }) => {
11
10
  fileManager.installCompilers(compilers);
12
- const virtualFileExtensions = [...VIRTUAL_FILE_EXTENSIONS, ...compilers[0].keys(), ...compilers[1].keys()];
11
+ const virtualFileExtensions = [...compilers[0].keys(), ...compilers[1].keys()];
13
12
  const sys = createCustomSys(cwd, virtualFileExtensions);
14
13
  const resolveModuleNames = createCustomModuleResolver(sys, compilerOptions, virtualFileExtensions);
15
14
  const languageServiceHost = {
@@ -1,5 +1,5 @@
1
1
  import ts from 'typescript';
2
- import type { BoundSourceFile } from './SourceFile.js';
2
+ import type { BoundSourceFile, GetResolvedModule } from './SourceFile.js';
3
3
  import type { ExportItems as Exports, ExportItem } from '../types/exports.js';
4
4
  import type { Imports, UnresolvedImport } from '../types/imports.js';
5
5
  import type { IssueSymbol } from '../types/issues.js';
@@ -17,7 +17,7 @@ export type AddImportOptions = {
17
17
  export type AddExportOptions = ExportItem & {
18
18
  identifier: string;
19
19
  };
20
- export declare const getImportsAndExports: (sourceFile: BoundSourceFile, options: GetImportsAndExportsOptions) => {
20
+ export declare const getImportsAndExports: (sourceFile: BoundSourceFile, getResolvedModule: GetResolvedModule, options: GetImportsAndExportsOptions) => {
21
21
  imports: {
22
22
  internal: Imports;
23
23
  external: Set<string>;
@@ -13,7 +13,7 @@ const getVisitors = (sourceFile) => ({
13
13
  import: getImportVisitors(sourceFile),
14
14
  script: getScriptVisitors(sourceFile),
15
15
  });
16
- export const getImportsAndExports = (sourceFile, options) => {
16
+ export const getImportsAndExports = (sourceFile, getResolvedModule, options) => {
17
17
  const internalImports = new Map();
18
18
  const externalImports = new Set();
19
19
  const unresolvedImports = new Set();
@@ -50,7 +50,7 @@ export const getImportsAndExports = (sourceFile, options) => {
50
50
  const { specifier, symbol, identifier = '__anonymous', isReExport = false, pos } = options;
51
51
  if (isBuiltin(specifier))
52
52
  return;
53
- const module = sourceFile.resolvedModules?.get(specifier, undefined);
53
+ const module = getResolvedModule(specifier);
54
54
  if (module?.resolvedModule) {
55
55
  const filePath = module.resolvedModule.resolvedFileName;
56
56
  if (filePath) {
@@ -1,16 +1,17 @@
1
1
  import { existsSync } from 'node:fs';
2
+ import { isBuiltin } from 'node:module';
2
3
  import ts from 'typescript';
3
4
  import { sanitizeSpecifier } from '../util/modules.js';
4
5
  import { dirname, extname, isAbsolute, isInternal, join } from '../util/path.js';
5
6
  import { isDeclarationFileExtension } from './ast-helpers.js';
6
7
  import { ensureRealFilePath, isVirtualFilePath } from './utils.js';
7
8
  const resolutionCache = new Map();
8
- const simpleResolver = (name, containingFile) => {
9
+ const fileExists = (name, containingFile) => {
9
10
  const resolvedFileName = isAbsolute(name) ? name : join(dirname(containingFile), name);
10
11
  if (existsSync(resolvedFileName)) {
11
12
  return {
12
13
  resolvedFileName,
13
- extension: extname(resolvedFileName),
14
+ extension: extname(name),
14
15
  isExternalLibraryImport: false,
15
16
  resolvedUsingTsExtension: false,
16
17
  };
@@ -29,11 +30,13 @@ export function createCustomModuleResolver(customSys, compilerOptions, virtualFi
29
30
  }
30
31
  function resolveModuleName(name, containingFile) {
31
32
  const sanitizedSpecifier = sanitizeSpecifier(name);
33
+ if (isBuiltin(sanitizedSpecifier))
34
+ return undefined;
32
35
  const tsResolvedModule = ts.resolveModuleName(sanitizedSpecifier, containingFile, compilerOptions, ts.sys).resolvedModule;
33
36
  if (!tsResolvedModule) {
34
37
  const extension = extname(sanitizedSpecifier);
35
- if (extension && isInternal(sanitizedSpecifier) && !virtualFileExtensions.includes(extension)) {
36
- const module = simpleResolver(sanitizedSpecifier, containingFile);
38
+ if (extension && !virtualFileExtensions.includes(extension)) {
39
+ const module = fileExists(sanitizedSpecifier, containingFile);
37
40
  if (module)
38
41
  return module;
39
42
  }
@@ -41,7 +44,7 @@ export function createCustomModuleResolver(customSys, compilerOptions, virtualFi
41
44
  if (tsResolvedModule &&
42
45
  isDeclarationFileExtension(tsResolvedModule?.extension) &&
43
46
  isInternal(tsResolvedModule.resolvedFileName)) {
44
- const module = simpleResolver(sanitizedSpecifier, containingFile);
47
+ const module = fileExists(sanitizedSpecifier, containingFile);
45
48
  if (module)
46
49
  return module;
47
50
  }
@@ -6,7 +6,12 @@ export default visit(() => true, node => {
6
6
  if (node.exportClause && ts.isNamedExports(node.exportClause)) {
7
7
  const type = node.isTypeOnly ? SymbolType.TYPE : SymbolType.UNKNOWN;
8
8
  return node.exportClause.elements.map(element => {
9
- return { node: element, identifier: element.name.getText(), type, pos: element.name.pos };
9
+ return {
10
+ node: element,
11
+ identifier: element.name.getText(),
12
+ type,
13
+ pos: element.name.flowNode?.node?.pos ?? element.name.pos,
14
+ };
10
15
  });
11
16
  }
12
17
  }
package/dist/util/fs.js CHANGED
@@ -34,7 +34,7 @@ export const parseJSON = async (filePath, contents) => {
34
34
  return JSON.parse(stripJsonComments(contents, { trailingCommas: true }));
35
35
  }
36
36
  catch (error) {
37
- throw new LoaderError(`Error loading ${filePath}`, { cause: error });
37
+ throw new LoaderError(`Error parsing ${filePath}`, { cause: error });
38
38
  }
39
39
  };
40
40
  export const parseYAML = async (contents) => {
@@ -26,7 +26,7 @@ const load = async (filePath) => {
26
26
  const imported = await import(fileUrl.href);
27
27
  return imported.default ?? imported;
28
28
  }
29
- if (isTypeModule(filePath)) {
29
+ if (ext === '.mts' || (ext === '.ts' && isTypeModule(filePath))) {
30
30
  return await jitiESM(filePath);
31
31
  }
32
32
  else {
@@ -1,6 +1,7 @@
1
+ import { isBuiltin } from 'module';
1
2
  import { _glob } from './glob.js';
2
3
  import { getStringValues } from './object.js';
3
- import { toPosix } from './path.js';
4
+ import { isAbsolute, toPosix } from './path.js';
4
5
  export const getPackageNameFromModuleSpecifier = (moduleSpecifier) => {
5
6
  if (!isMaybePackageName(moduleSpecifier))
6
7
  return;
@@ -52,7 +53,9 @@ export const getEntryPathFromManifest = (manifest, sharedGlobOptions) => {
52
53
  return _glob({ ...sharedGlobOptions, patterns: Array.from(entryPaths) });
53
54
  };
54
55
  export const sanitizeSpecifier = (specifier) => {
55
- if (specifier.startsWith('node:'))
56
+ if (isBuiltin(specifier))
57
+ return specifier;
58
+ if (isAbsolute(specifier))
56
59
  return specifier;
57
60
  return specifier.replace(/^([?!|-]+)?([^!?:]+).*/, '$2');
58
61
  };
@@ -1,2 +1,3 @@
1
+ /// <reference types="node" resolution-mode="require"/>
1
2
  declare let parseArgs: typeof import('node:util').parseArgs;
2
3
  export { parseArgs };
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "3.0.0-canary.3";
1
+ export declare const version = "3.0.0";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '3.0.0-canary.3';
1
+ export const version = '3.0.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "3.0.0-canary.3",
3
+ "version": "3.0.0",
4
4
  "description": "Find unused files, dependencies and exports in your TypeScript and JavaScript projects",
5
5
  "homepage": "https://knip.dev",
6
6
  "repository": {
@@ -46,7 +46,7 @@
46
46
  "@npmcli/map-workspaces": "3.0.4",
47
47
  "@pkgjs/parseargs": "0.11.0",
48
48
  "@pnpm/logger": "5.0.0",
49
- "@pnpm/workspace.pkgs-graph": "2.0.10",
49
+ "@pnpm/workspace.pkgs-graph": "^2.0.10",
50
50
  "@snyk/github-codeowners": "1.1.0",
51
51
  "chalk": "^5.2.0",
52
52
  "easy-table": "1.2.0",
@@ -70,24 +70,24 @@
70
70
  "@knip/eslint-config": "0.0.0",
71
71
  "@npmcli/package-json": "5.0.0",
72
72
  "@release-it/bumper": "^6.0.1",
73
- "@swc/cli": "0.1.62",
74
- "@swc/core": "^1.3.96",
73
+ "@swc/cli": "^0.1.63",
74
+ "@swc/core": "^1.3.99",
75
75
  "@types/js-yaml": "^4.0.9",
76
- "@types/micromatch": "^4.0.5",
76
+ "@types/micromatch": "^4.0.6",
77
77
  "@types/minimist": "^1.2.5",
78
- "@types/node": "^20.9.0",
78
+ "@types/node": "^20.10.0",
79
79
  "@types/npmcli__map-workspaces": "^3.0.4",
80
80
  "@types/npmcli__package-json": "^4.0.3",
81
81
  "@types/pkgjs__parseargs": "^0.10.3",
82
82
  "@types/webpack": "^5.28.5",
83
83
  "c8": "8.0.1",
84
- "eslint": "8.53.0",
85
- "playwright": "1.39.0",
84
+ "eslint": "^8.54.0",
85
+ "playwright": "^1.40.0",
86
86
  "prettier": "^3.1.0",
87
87
  "release-it": "^17.0.0",
88
- "tsx": "^4.1.2",
89
- "type-fest": "^4.7.1",
90
- "typescript": "5.0.4"
88
+ "tsx": "^4.5.0",
89
+ "type-fest": "^4.8.2",
90
+ "typescript": "5.3.2"
91
91
  },
92
92
  "engines": {
93
93
  "node": ">=18.6.0"