knip 5.81.0 → 5.82.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.
@@ -556,6 +556,11 @@ export declare class ConfigurationChief {
556
556
  entry?: string | string[] | undefined;
557
557
  project?: string | string[] | undefined;
558
558
  } | undefined;
559
+ sveltekit?: string | boolean | string[] | {
560
+ config?: string | string[] | undefined;
561
+ entry?: string | string[] | undefined;
562
+ project?: string | string[] | undefined;
563
+ } | undefined;
559
564
  svgo?: string | boolean | string[] | {
560
565
  config?: string | string[] | undefined;
561
566
  entry?: string | string[] | undefined;
@@ -820,6 +825,7 @@ export declare class ConfigurationChief {
820
825
  stryker?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
821
826
  stylelint?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
822
827
  svelte?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
828
+ sveltekit?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
823
829
  svgo?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
824
830
  svgr?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
825
831
  swc?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
@@ -75,4 +75,5 @@ export declare class DependencyDeputy {
75
75
  getConfigurationHints(): ConfigurationHint[];
76
76
  addIgnoredDependencies(workspaceName: string, identifier: string): void;
77
77
  addIgnoredBinaries(workspaceName: string, identifier: string): void;
78
+ addIgnoredUnresolved(workspaceName: string, identifier: string): void;
78
79
  }
@@ -372,4 +372,7 @@ export class DependencyDeputy {
372
372
  addIgnoredBinaries(workspaceName, identifier) {
373
373
  this._manifests.get(workspaceName)?.ignoreBinaries.push(toRegexOrString(identifier));
374
374
  }
375
+ addIgnoredUnresolved(workspaceName, identifier) {
376
+ this._manifests.get(workspaceName)?.ignoreUnresolved.push(toRegexOrString(identifier));
377
+ }
375
378
  }
package/dist/cli.js CHANGED
@@ -2,7 +2,7 @@ import { fix } from './IssueFixer.js';
2
2
  import { run } from './run.js';
3
3
  import parseArgs, { helpText } from './util/cli-arguments.js';
4
4
  import { createOptions } from './util/create-options.js';
5
- import { getKnownErrors, hasErrorCause, isConfigurationError, isKnownError, isModuleNotFoundError, } from './util/errors.js';
5
+ import { getKnownErrors, hasErrorCause, isConfigurationError, isKnownError, isLoaderError, isModuleNotFoundError, } from './util/errors.js';
6
6
  import { logError, logWarning } from './util/log.js';
7
7
  import { perfObserver } from './util/Performance.js';
8
8
  import { runPreprocessors, runReporters } from './util/reporter.js';
@@ -93,6 +93,8 @@ const main = async () => {
93
93
  console.error('Reason:', knownErrors[0].cause.message);
94
94
  if (isModuleNotFoundError(knownErrors[0].cause))
95
95
  console.log('Module load error? Visit https://knip.dev/reference/known-issues');
96
+ if (isLoaderError(knownErrors[0]))
97
+ console.log('Configuration file load error? Visit https://knip.dev/reference/known-issues');
96
98
  }
97
99
  if (isConfigurationError(knownErrors[0]))
98
100
  console.log('\nRun `knip --help` or visit https://knip.dev for help');
@@ -1,9 +1,9 @@
1
- import { fencedCodeBlockMatcher, importMatcher, importsWithinFrontmatter } from './compilers.js';
1
+ import { fencedCodeBlockMatcher, importMatcher, importsWithinFrontmatter, inlineCodeMatcher } from './compilers.js';
2
2
  const astroMDXDependencies = ['@astrojs/mdx', '@astrojs/starlight'];
3
3
  const frontmatterImportFields = ['layout'];
4
4
  const condition = (hasDependency) => astroMDXDependencies.some(hasDependency);
5
5
  const compiler = (text) => {
6
- const imports = text.replace(fencedCodeBlockMatcher, '').matchAll(importMatcher);
6
+ const imports = text.replace(fencedCodeBlockMatcher, '').replace(inlineCodeMatcher, '').matchAll(importMatcher);
7
7
  const frontmatterImports = importsWithinFrontmatter(text, frontmatterImportFields);
8
8
  return [...imports, frontmatterImports].join('\n');
9
9
  };
@@ -1,5 +1,6 @@
1
1
  import type { SyncCompilerFn } from './types.js';
2
2
  export declare const fencedCodeBlockMatcher: RegExp;
3
+ export declare const inlineCodeMatcher: RegExp;
3
4
  export declare const importMatcher: RegExp;
4
5
  export declare const importsWithinScripts: SyncCompilerFn;
5
6
  export declare const scriptBodies: SyncCompilerFn;
@@ -1,4 +1,5 @@
1
1
  export const fencedCodeBlockMatcher = /```[\s\S]*?```/g;
2
+ export const inlineCodeMatcher = /`[^`]+`/g;
2
3
  const scriptExtractor = /<script\b[^>]*>([\s\S]*?)<\/script>/gm;
3
4
  export const importMatcher = /import[^'"]+['"][^'"]+['"]/g;
4
5
  export const importsWithinScripts = (text) => {
@@ -504,6 +504,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
504
504
  entry?: string | string[] | undefined;
505
505
  project?: string | string[] | undefined;
506
506
  } | undefined;
507
+ sveltekit?: string | boolean | string[] | {
508
+ config?: string | string[] | undefined;
509
+ entry?: string | string[] | undefined;
510
+ project?: string | string[] | undefined;
511
+ } | undefined;
507
512
  svgo?: string | boolean | string[] | {
508
513
  config?: string | string[] | undefined;
509
514
  entry?: string | string[] | undefined;
@@ -1150,6 +1155,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
1150
1155
  entry?: string | string[] | undefined;
1151
1156
  project?: string | string[] | undefined;
1152
1157
  } | undefined;
1158
+ sveltekit?: string | boolean | string[] | {
1159
+ config?: string | string[] | undefined;
1160
+ entry?: string | string[] | undefined;
1161
+ project?: string | string[] | undefined;
1162
+ } | undefined;
1153
1163
  svgo?: string | boolean | string[] | {
1154
1164
  config?: string | string[] | undefined;
1155
1165
  entry?: string | string[] | undefined;
@@ -1,4 +1,4 @@
1
- import { fencedCodeBlockMatcher, importMatcher } from './compilers.js';
1
+ import { fencedCodeBlockMatcher, importMatcher, inlineCodeMatcher } from './compilers.js';
2
2
  const mdxDependencies = [
3
3
  '@mdx-js/esbuild',
4
4
  '@mdx-js/loader',
@@ -11,5 +11,5 @@ const mdxDependencies = [
11
11
  'remark-mdx',
12
12
  ];
13
13
  const condition = (hasDependency) => mdxDependencies.some(hasDependency);
14
- const compiler = (text) => [...text.replace(fencedCodeBlockMatcher, '').matchAll(importMatcher)].join('\n');
14
+ const compiler = (text) => [...text.replace(fencedCodeBlockMatcher, '').replace(inlineCodeMatcher, '').matchAll(importMatcher)].join('\n');
15
15
  export default { condition, compiler };
@@ -150,6 +150,9 @@ export async function build({ chief, collector, counselor, deputy, factory, isGi
150
150
  else if (input.issueType === 'binaries') {
151
151
  deputy.addIgnoredBinaries(name, input.specifier);
152
152
  }
153
+ else if (input.issueType === 'unresolved') {
154
+ deputy.addIgnoredUnresolved(name, input.specifier);
155
+ }
153
156
  }
154
157
  else if (!isConfig(input)) {
155
158
  const ws = (input.containingFilePath && chief.findWorkspaceByFilePath(input.containingFilePath)) || workspace;
@@ -99,6 +99,7 @@ export declare const Plugins: {
99
99
  stryker: import("../types/config.js").Plugin;
100
100
  stylelint: import("../types/config.js").Plugin;
101
101
  svelte: import("../types/config.js").Plugin;
102
+ sveltekit: import("../types/config.js").Plugin;
102
103
  svgo: import("../types/config.js").Plugin;
103
104
  svgr: import("../types/config.js").Plugin;
104
105
  swc: import("../types/config.js").Plugin;
@@ -98,6 +98,7 @@ import { default as storybook } from './storybook/index.js';
98
98
  import { default as stryker } from './stryker/index.js';
99
99
  import { default as stylelint } from './stylelint/index.js';
100
100
  import { default as svelte } from './svelte/index.js';
101
+ import { default as sveltekit } from './sveltekit/index.js';
101
102
  import { default as svgo } from './svgo/index.js';
102
103
  import { default as svgr } from './svgr/index.js';
103
104
  import { default as swc } from './swc/index.js';
@@ -228,6 +229,7 @@ export const Plugins = {
228
229
  stryker,
229
230
  stylelint,
230
231
  svelte,
232
+ sveltekit,
231
233
  svgo,
232
234
  svgr,
233
235
  swc,
@@ -1,32 +1,13 @@
1
- import { toAlias } from '../../util/input.js';
2
- import { join } from '../../util/path.js';
3
1
  import { hasDependency } from '../../util/plugin.js';
4
2
  import { config as viteConfig } from '../vite/index.js';
5
3
  const title = 'Svelte';
6
4
  const enablers = ['svelte'];
7
5
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
8
6
  const entry = ['svelte.config.js', ...viteConfig];
9
- const production = [
10
- 'src/routes/**/+{page,server,page.server,error,layout,layout.server}{,@*}.{js,ts,svelte}',
11
- 'src/hooks.{server,client}.{js,ts}',
12
- 'src/params/*.{js,ts}',
13
- 'src/service-worker.{js,ts}',
14
- 'src/service-worker/index.{js,ts}',
15
- 'src/instrumentation.server.{js,ts}',
16
- ];
17
- const resolve = options => {
18
- const alias = toAlias('$app/*', [join(options.cwd, 'node_modules/@sveltejs/kit/src/runtime/app/*')]);
19
- const serviceWorkerAlias = toAlias('$service-worker', [
20
- join(options.cwd, 'node_modules/@sveltejs/kit/src/runtime/service-worker.js'),
21
- ]);
22
- return [alias, serviceWorkerAlias];
23
- };
24
7
  const plugin = {
25
8
  title,
26
9
  enablers,
27
10
  isEnabled,
28
11
  entry,
29
- production,
30
- resolve,
31
12
  };
32
13
  export default plugin;
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from '../../types/config.js';
2
+ declare const plugin: Plugin;
3
+ export default plugin;
@@ -0,0 +1,44 @@
1
+ import ts from 'typescript';
2
+ import { findDescendants, stripQuotes } from '../../typescript/ast-helpers.js';
3
+ import { toAlias, toIgnore, toProductionEntry } from '../../util/input.js';
4
+ import { hasDependency } from '../../util/plugin.js';
5
+ const title = 'SvelteKit';
6
+ const enablers = ['@sveltejs/kit'];
7
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
8
+ const config = ['svelte.config.js'];
9
+ const production = [
10
+ 'src/routes/**/+{page,server,page.server,error,layout,layout.server}{,@*}.{js,ts,svelte}',
11
+ 'src/hooks.{server,client}.{js,ts}',
12
+ 'src/params/*.{js,ts}',
13
+ 'src/service-worker.{js,ts}',
14
+ 'src/service-worker/index.{js,ts}',
15
+ 'src/instrumentation.server.{js,ts}',
16
+ ];
17
+ const getLibPath = (sourceFile) => {
18
+ const assignments = findDescendants(sourceFile, node => ts.isPropertyAssignment(node));
19
+ for (const assignment of assignments) {
20
+ if (assignment.name.getText() === 'lib' && ts.isStringLiteral(assignment.initializer)) {
21
+ return stripQuotes(assignment.initializer.getText());
22
+ }
23
+ }
24
+ return 'src/lib';
25
+ };
26
+ const resolveFromAST = sourceFile => {
27
+ const lib = getLibPath(sourceFile);
28
+ return [
29
+ ...production.map(pattern => toProductionEntry(pattern)),
30
+ toAlias('$lib', [`./${lib}`]),
31
+ toAlias('$lib/*', [`./${lib}/*`]),
32
+ toIgnore('\\$app/.+', 'unresolved'),
33
+ toIgnore('\\$env/.+', 'unresolved'),
34
+ toIgnore('\\$service-worker', 'unresolved'),
35
+ ];
36
+ };
37
+ const plugin = {
38
+ title,
39
+ enablers,
40
+ isEnabled,
41
+ config,
42
+ resolveFromAST,
43
+ };
44
+ export default plugin;
@@ -9,7 +9,13 @@ const getWorkspaceName = (hint) => hint.workspaceName &&
9
9
  hint.type !== 'package-entry'
10
10
  ? hint.workspaceName
11
11
  : '';
12
- const getIdentifier = (hint) => hint.identifier === '.' ? `. ${dim('(root)')}` : hint.identifier.toString();
12
+ const getIdentifier = (hint) => {
13
+ if (hint.identifier === '.')
14
+ return `. ${dim('(root)')}`;
15
+ if (hint.identifier instanceof RegExp)
16
+ return hint.identifier.source.replaceAll('\\/', '/');
17
+ return hint.identifier.toString();
18
+ };
13
19
  const getTableForHints = (hints) => {
14
20
  const table = new Table({ truncateStart: ['identifier', 'workspace', 'filePath'] });
15
21
  for (const hint of hints) {
@@ -502,6 +502,11 @@ export declare const workspaceConfigurationSchema: z.ZodMiniObject<{
502
502
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
503
503
  project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
504
504
  }, z.core.$strip>]>>;
505
+ sveltekit: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
506
+ config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
507
+ entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
508
+ project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
509
+ }, z.core.$strip>]>>;
505
510
  svgo: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
506
511
  config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
507
512
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
@@ -1159,6 +1164,11 @@ export declare const knipConfigurationSchema: z.ZodMiniObject<{
1159
1164
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1160
1165
  project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1161
1166
  }, z.core.$strip>]>>;
1167
+ sveltekit: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
1168
+ config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1169
+ entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1170
+ project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1171
+ }, z.core.$strip>]>>;
1162
1172
  svgo: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
1163
1173
  config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1164
1174
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
@@ -1805,6 +1815,11 @@ export declare const knipConfigurationSchema: z.ZodMiniObject<{
1805
1815
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1806
1816
  project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1807
1817
  }, z.core.$strip>]>>;
1818
+ sveltekit: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
1819
+ config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1820
+ entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1821
+ project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1822
+ }, z.core.$strip>]>>;
1808
1823
  svgo: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
1809
1824
  config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1810
1825
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
@@ -506,6 +506,11 @@ export declare const pluginsSchema: z.ZodMiniObject<{
506
506
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
507
507
  project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
508
508
  }, z.core.$strip>]>;
509
+ sveltekit: z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
510
+ config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
511
+ entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
512
+ project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
513
+ }, z.core.$strip>]>;
509
514
  svgo: z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
510
515
  config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
511
516
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
@@ -110,6 +110,7 @@ export const pluginsSchema = z.object({
110
110
  stryker: pluginSchema,
111
111
  stylelint: pluginSchema,
112
112
  svelte: pluginSchema,
113
+ sveltekit: pluginSchema,
113
114
  svgo: pluginSchema,
114
115
  svgr: pluginSchema,
115
116
  swc: pluginSchema,
@@ -1,2 +1,2 @@
1
- export type PluginName = 'angular' | 'astro' | 'astro-db' | 'astro-og-canvas' | 'ava' | 'babel' | 'biome' | 'bumpp' | 'bun' | 'c8' | 'capacitor' | 'changelogen' | 'changelogithub' | 'changesets' | 'commitizen' | 'commitlint' | 'convex' | 'create-typescript-app' | 'cspell' | 'cucumber' | 'cypress' | 'danger' | 'dependency-cruiser' | 'docusaurus' | 'dotenv' | 'drizzle' | 'eleventy' | 'eslint' | 'expo' | 'gatsby' | 'github-action' | 'github-actions' | 'glob' | 'graphql-codegen' | 'hardhat' | 'husky' | 'i18next-parser' | 'jest' | 'karma' | 'knex' | 'ladle' | 'lefthook' | 'lint-staged' | 'linthtml' | 'lockfile-lint' | 'lost-pixel' | 'markdownlint' | 'mdx' | 'mdxlint' | 'metro' | 'mocha' | 'moonrepo' | 'msw' | 'nano-staged' | 'nest' | 'netlify' | 'next' | 'next-intl' | 'next-mdx' | 'nitro' | 'node' | 'node-modules-inspector' | 'nodemon' | 'npm-package-json-lint' | 'nuxt' | 'nx' | 'nyc' | 'oclif' | 'oxlint' | 'parcel' | 'playwright' | 'playwright-ct' | 'playwright-test' | 'plop' | 'pnpm' | 'postcss' | 'preconstruct' | 'prettier' | 'prisma' | 'react-cosmos' | 'react-router' | 'relay' | 'release-it' | 'remark' | 'remix' | 'rollup' | 'rsbuild' | 'rslib' | 'rspack' | 'rstest' | 'semantic-release' | 'sentry' | 'simple-git-hooks' | 'size-limit' | 'sst' | 'starlight' | 'storybook' | 'stryker' | 'stylelint' | 'svelte' | 'svgo' | 'svgr' | 'swc' | 'syncpack' | 'tailwind' | 'tanstack-router' | 'taskfile' | 'travis' | 'ts-node' | 'tsdown' | 'tsup' | 'tsx' | 'typedoc' | 'typescript' | 'unbuild' | 'unocss' | 'vercel-og' | 'vike' | 'vite' | 'vitepress' | 'vitest' | 'vue' | 'webdriver-io' | 'webpack' | 'wireit' | 'wrangler' | 'xo' | 'yarn' | 'yorkie';
2
- export declare const pluginNames: readonly ["angular", "astro", "astro-db", "astro-og-canvas", "ava", "babel", "biome", "bumpp", "bun", "c8", "capacitor", "changelogen", "changelogithub", "changesets", "commitizen", "commitlint", "convex", "create-typescript-app", "cspell", "cucumber", "cypress", "danger", "dependency-cruiser", "docusaurus", "dotenv", "drizzle", "eleventy", "eslint", "expo", "gatsby", "github-action", "github-actions", "glob", "graphql-codegen", "hardhat", "husky", "i18next-parser", "jest", "karma", "knex", "ladle", "lefthook", "lint-staged", "linthtml", "lockfile-lint", "lost-pixel", "markdownlint", "mdx", "mdxlint", "metro", "mocha", "moonrepo", "msw", "nano-staged", "nest", "netlify", "next", "next-intl", "next-mdx", "nitro", "node", "node-modules-inspector", "nodemon", "npm-package-json-lint", "nuxt", "nx", "nyc", "oclif", "oxlint", "parcel", "playwright", "playwright-ct", "playwright-test", "plop", "pnpm", "postcss", "preconstruct", "prettier", "prisma", "react-cosmos", "react-router", "relay", "release-it", "remark", "remix", "rollup", "rsbuild", "rslib", "rspack", "rstest", "semantic-release", "sentry", "simple-git-hooks", "size-limit", "sst", "starlight", "storybook", "stryker", "stylelint", "svelte", "svgo", "svgr", "swc", "syncpack", "tailwind", "tanstack-router", "taskfile", "travis", "ts-node", "tsdown", "tsup", "tsx", "typedoc", "typescript", "unbuild", "unocss", "vercel-og", "vike", "vite", "vitepress", "vitest", "vue", "webdriver-io", "webpack", "wireit", "wrangler", "xo", "yarn", "yorkie"];
1
+ export type PluginName = 'angular' | 'astro' | 'astro-db' | 'astro-og-canvas' | 'ava' | 'babel' | 'biome' | 'bumpp' | 'bun' | 'c8' | 'capacitor' | 'changelogen' | 'changelogithub' | 'changesets' | 'commitizen' | 'commitlint' | 'convex' | 'create-typescript-app' | 'cspell' | 'cucumber' | 'cypress' | 'danger' | 'dependency-cruiser' | 'docusaurus' | 'dotenv' | 'drizzle' | 'eleventy' | 'eslint' | 'expo' | 'gatsby' | 'github-action' | 'github-actions' | 'glob' | 'graphql-codegen' | 'hardhat' | 'husky' | 'i18next-parser' | 'jest' | 'karma' | 'knex' | 'ladle' | 'lefthook' | 'lint-staged' | 'linthtml' | 'lockfile-lint' | 'lost-pixel' | 'markdownlint' | 'mdx' | 'mdxlint' | 'metro' | 'mocha' | 'moonrepo' | 'msw' | 'nano-staged' | 'nest' | 'netlify' | 'next' | 'next-intl' | 'next-mdx' | 'nitro' | 'node' | 'node-modules-inspector' | 'nodemon' | 'npm-package-json-lint' | 'nuxt' | 'nx' | 'nyc' | 'oclif' | 'oxlint' | 'parcel' | 'playwright' | 'playwright-ct' | 'playwright-test' | 'plop' | 'pnpm' | 'postcss' | 'preconstruct' | 'prettier' | 'prisma' | 'react-cosmos' | 'react-router' | 'relay' | 'release-it' | 'remark' | 'remix' | 'rollup' | 'rsbuild' | 'rslib' | 'rspack' | 'rstest' | 'semantic-release' | 'sentry' | 'simple-git-hooks' | 'size-limit' | 'sst' | 'starlight' | 'storybook' | 'stryker' | 'stylelint' | 'svelte' | 'sveltekit' | 'svgo' | 'svgr' | 'swc' | 'syncpack' | 'tailwind' | 'tanstack-router' | 'taskfile' | 'travis' | 'ts-node' | 'tsdown' | 'tsup' | 'tsx' | 'typedoc' | 'typescript' | 'unbuild' | 'unocss' | 'vercel-og' | 'vike' | 'vite' | 'vitepress' | 'vitest' | 'vue' | 'webdriver-io' | 'webpack' | 'wireit' | 'wrangler' | 'xo' | 'yarn' | 'yorkie';
2
+ export declare const pluginNames: readonly ["angular", "astro", "astro-db", "astro-og-canvas", "ava", "babel", "biome", "bumpp", "bun", "c8", "capacitor", "changelogen", "changelogithub", "changesets", "commitizen", "commitlint", "convex", "create-typescript-app", "cspell", "cucumber", "cypress", "danger", "dependency-cruiser", "docusaurus", "dotenv", "drizzle", "eleventy", "eslint", "expo", "gatsby", "github-action", "github-actions", "glob", "graphql-codegen", "hardhat", "husky", "i18next-parser", "jest", "karma", "knex", "ladle", "lefthook", "lint-staged", "linthtml", "lockfile-lint", "lost-pixel", "markdownlint", "mdx", "mdxlint", "metro", "mocha", "moonrepo", "msw", "nano-staged", "nest", "netlify", "next", "next-intl", "next-mdx", "nitro", "node", "node-modules-inspector", "nodemon", "npm-package-json-lint", "nuxt", "nx", "nyc", "oclif", "oxlint", "parcel", "playwright", "playwright-ct", "playwright-test", "plop", "pnpm", "postcss", "preconstruct", "prettier", "prisma", "react-cosmos", "react-router", "relay", "release-it", "remark", "remix", "rollup", "rsbuild", "rslib", "rspack", "rstest", "semantic-release", "sentry", "simple-git-hooks", "size-limit", "sst", "starlight", "storybook", "stryker", "stylelint", "svelte", "sveltekit", "svgo", "svgr", "swc", "syncpack", "tailwind", "tanstack-router", "taskfile", "travis", "ts-node", "tsdown", "tsup", "tsx", "typedoc", "typescript", "unbuild", "unocss", "vercel-og", "vike", "vite", "vitepress", "vitest", "vue", "webdriver-io", "webpack", "wireit", "wrangler", "xo", "yarn", "yorkie"];
@@ -99,6 +99,7 @@ export const pluginNames = [
99
99
  'stryker',
100
100
  'stylelint',
101
101
  'svelte',
102
+ 'sveltekit',
102
103
  'svgo',
103
104
  'svgr',
104
105
  'swc',
@@ -419,16 +419,16 @@ const getImportsAndExports = (sourceFile, resolveModule, typeChecker, options, i
419
419
  }
420
420
  }
421
421
  }
422
- if (!isTopLevel && symbol.exportSymbol) {
423
- const containingExport = isReferencedInExport(node);
424
- if (containingExport) {
425
- const referencedId = String(symbol.exportSymbol.escapedName);
426
- const refs = referencedInExport.get(referencedId);
427
- if (refs)
428
- refs.add(containingExport);
429
- else
430
- referencedInExport.set(referencedId, new Set([containingExport]));
431
- }
422
+ }
423
+ if (ts.isTypeReferenceNode(node.parent) || ts.isTypeQueryNode(node.parent)) {
424
+ const containingExport = isReferencedInExport(node);
425
+ if (containingExport && containingExport !== id) {
426
+ const refId = symbol?.exportSymbol ? String(symbol.exportSymbol.escapedName) : id;
427
+ const refs = referencedInExport.get(refId);
428
+ if (refs)
429
+ refs.add(containingExport);
430
+ else
431
+ referencedInExport.set(refId, new Set([containingExport]));
432
432
  }
433
433
  }
434
434
  }
@@ -545,6 +545,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
545
545
  entry?: string | string[] | undefined;
546
546
  project?: string | string[] | undefined;
547
547
  } | undefined;
548
+ sveltekit?: string | boolean | string[] | {
549
+ config?: string | string[] | undefined;
550
+ entry?: string | string[] | undefined;
551
+ project?: string | string[] | undefined;
552
+ } | undefined;
548
553
  svgo?: string | boolean | string[] | {
549
554
  config?: string | string[] | undefined;
550
555
  entry?: string | string[] | undefined;
@@ -1191,6 +1196,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
1191
1196
  entry?: string | string[] | undefined;
1192
1197
  project?: string | string[] | undefined;
1193
1198
  } | undefined;
1199
+ sveltekit?: string | boolean | string[] | {
1200
+ config?: string | string[] | undefined;
1201
+ entry?: string | string[] | undefined;
1202
+ project?: string | string[] | undefined;
1203
+ } | undefined;
1194
1204
  svgo?: string | boolean | string[] | {
1195
1205
  config?: string | string[] | undefined;
1196
1206
  entry?: string | string[] | undefined;
@@ -10,5 +10,6 @@ export declare const isKnownError: (error: Error) => error is core.$ZodError<any
10
10
  export declare const hasErrorCause: (error: Error) => error is ErrorWithCause;
11
11
  export declare const isConfigurationError: (error: Error) => error is ConfigurationError;
12
12
  export declare const isModuleNotFoundError: (error: Error) => boolean;
13
+ export declare const isLoaderError: (error: Error) => error is LoaderError;
13
14
  export declare const getKnownErrors: (error: Error) => Error[];
14
15
  export {};
@@ -8,6 +8,7 @@ export const isKnownError = (error) => error instanceof ConfigurationError || er
8
8
  export const hasErrorCause = (error) => !isZodErrorLike(error) && error.cause instanceof Error;
9
9
  export const isConfigurationError = (error) => error instanceof ConfigurationError;
10
10
  export const isModuleNotFoundError = (error) => 'code' in error && error.code === 'MODULE_NOT_FOUND';
11
+ export const isLoaderError = (error) => error instanceof LoaderError;
11
12
  export const getKnownErrors = (error) => {
12
13
  if (isZodErrorLike(error))
13
14
  return [...error.issues].map(error => {
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "5.81.0";
1
+ export declare const version = "5.82.1";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '5.81.0';
1
+ export const version = '5.82.1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "5.81.0",
3
+ "version": "5.82.1",
4
4
  "description": "Find and fix unused dependencies, exports and files in your TypeScript and JavaScript projects",
5
5
  "homepage": "https://knip.dev",
6
6
  "repository": {
package/schema.json CHANGED
@@ -729,6 +729,10 @@
729
729
  "title": "svelte plugin configuration (https://knip.dev/reference/plugins/svelte)",
730
730
  "$ref": "#/definitions/plugin"
731
731
  },
732
+ "sveltekit": {
733
+ "title": "sveltekit plugin configuration (https://knip.dev/reference/plugins/sveltekit)",
734
+ "$ref": "#/definitions/plugin"
735
+ },
732
736
  "svgo": {
733
737
  "title": "svgo plugin configuration (https://knip.dev/reference/plugins/svgo)",
734
738
  "$ref": "#/definitions/plugin"