knip 6.0.5 → 6.1.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.
@@ -587,6 +587,11 @@ export declare class ConfigurationChief {
587
587
  entry?: string | string[] | undefined;
588
588
  project?: string | string[] | undefined;
589
589
  } | undefined;
590
+ stencil?: string | boolean | string[] | {
591
+ config?: string | string[] | undefined;
592
+ entry?: string | string[] | undefined;
593
+ project?: string | string[] | undefined;
594
+ } | undefined;
590
595
  storybook?: string | boolean | string[] | {
591
596
  config?: string | string[] | undefined;
592
597
  entry?: string | string[] | undefined;
@@ -887,6 +892,7 @@ export declare class ConfigurationChief {
887
892
  "size-limit"?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
888
893
  sst?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
889
894
  starlight?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
895
+ stencil?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
890
896
  storybook?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
891
897
  stryker?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
892
898
  stylelint?: (boolean | import("./types/config.ts").EnsuredPluginConfiguration) | undefined;
@@ -535,6 +535,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
535
535
  entry?: string | string[] | undefined;
536
536
  project?: string | string[] | undefined;
537
537
  } | undefined;
538
+ stencil?: string | boolean | string[] | {
539
+ config?: string | string[] | undefined;
540
+ entry?: string | string[] | undefined;
541
+ project?: string | string[] | undefined;
542
+ } | undefined;
538
543
  storybook?: string | boolean | string[] | {
539
544
  config?: string | string[] | undefined;
540
545
  entry?: string | string[] | undefined;
@@ -1241,6 +1246,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
1241
1246
  entry?: string | string[] | undefined;
1242
1247
  project?: string | string[] | undefined;
1243
1248
  } | undefined;
1249
+ stencil?: string | boolean | string[] | {
1250
+ config?: string | string[] | undefined;
1251
+ entry?: string | string[] | undefined;
1252
+ project?: string | string[] | undefined;
1253
+ } | undefined;
1244
1254
  storybook?: string | boolean | string[] | {
1245
1255
  config?: string | string[] | undefined;
1246
1256
  entry?: string | string[] | undefined;
@@ -310,14 +310,18 @@ export async function build({ chief, collector, counselor, deputy, principal, is
310
310
  if (!isIgnored)
311
311
  pp.addEntryPath(filePath, { skipExportsAnalysis: true });
312
312
  }
313
+ const wsDependencies = deputy.getDependencies(workspace.name);
313
314
  for (const _import of file.imports.imports) {
314
- if (_import.filePath) {
315
- const packageName = getPackageNameFromModuleSpecifier(_import.specifier);
316
- if (packageName && isInternalWorkspace(packageName)) {
317
- file.imports.external.add({ ..._import, specifier: packageName });
318
- if (!isGitIgnored(_import.filePath)) {
319
- pp.addProgramPath(_import.filePath);
320
- }
315
+ if (!_import.filePath)
316
+ continue;
317
+ const packageName = getPackageNameFromModuleSpecifier(_import.specifier);
318
+ if (!packageName)
319
+ continue;
320
+ const isWorkspace = isInternalWorkspace(packageName);
321
+ if (isWorkspace || wsDependencies.has(packageName)) {
322
+ file.imports.external.add({ ..._import, specifier: packageName });
323
+ if (isWorkspace && !isGitIgnored(_import.filePath)) {
324
+ pp.addProgramPath(_import.filePath);
321
325
  }
322
326
  }
323
327
  }
@@ -2,7 +2,7 @@ import { toDependency, toEntry, toProductionEntry } from "../../util/input.js";
2
2
  import { hasDependency } from "../../util/plugin.js";
3
3
  import compiler from "./compiler.js";
4
4
  import mdxCompiler from "./compiler-mdx.js";
5
- import { getSrcDir, usesSharpImageService } from "./resolveFromAST.js";
5
+ import { getSrcDir, usesPassthroughImageService } from "./resolveFromAST.js";
6
6
  const title = 'Astro';
7
7
  const enablers = ['astro'];
8
8
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
@@ -23,8 +23,8 @@ const resolveFromAST = program => {
23
23
  ...entry.map(setSrcDir).map(path => toEntry(path)),
24
24
  ...production.map(setSrcDir).map(path => toProductionEntry(path)),
25
25
  ];
26
- if (usesSharpImageService(program))
27
- inputs.push(toDependency('sharp'));
26
+ if (!usesPassthroughImageService(program))
27
+ inputs.push(toDependency('sharp', { optional: true }));
28
28
  return inputs;
29
29
  };
30
30
  const registerCompilers = ({ registerCompiler, hasDependency }) => {
@@ -1,3 +1,3 @@
1
1
  import type { Program } from 'oxc-parser';
2
2
  export declare const getSrcDir: (program: Program) => string;
3
- export declare const usesSharpImageService: (program: Program) => boolean;
3
+ export declare const usesPassthroughImageService: (program: Program) => boolean;
@@ -3,4 +3,4 @@ export const getSrcDir = (program) => {
3
3
  const values = collectPropertyValues(program, 'srcDir');
4
4
  return values.size > 0 ? Array.from(values)[0] : 'src';
5
5
  };
6
- export const usesSharpImageService = (program) => hasImportSpecifier(program, 'astro/config', 'sharpImageService');
6
+ export const usesPassthroughImageService = (program) => hasImportSpecifier(program, 'astro/config', 'passthroughImageService');
@@ -110,6 +110,7 @@ export declare const Plugins: {
110
110
  'size-limit': import("../types/config.ts").Plugin;
111
111
  sst: import("../types/config.ts").Plugin;
112
112
  starlight: import("../types/config.ts").Plugin;
113
+ stencil: import("../types/config.ts").Plugin;
113
114
  storybook: import("../types/config.ts").Plugin;
114
115
  stryker: import("../types/config.ts").Plugin;
115
116
  stylelint: import("../types/config.ts").Plugin;
@@ -104,6 +104,7 @@ import { default as simpleGitHooks } from "./simple-git-hooks/index.js";
104
104
  import { default as sizeLimit } from "./size-limit/index.js";
105
105
  import { default as sst } from "./sst/index.js";
106
106
  import { default as starlight } from "./starlight/index.js";
107
+ import { default as stencil } from "./stencil/index.js";
107
108
  import { default as storybook } from "./storybook/index.js";
108
109
  import { default as stryker } from "./stryker/index.js";
109
110
  import { default as stylelint } from "./stylelint/index.js";
@@ -246,6 +247,7 @@ export const Plugins = {
246
247
  'size-limit': sizeLimit,
247
248
  sst,
248
249
  starlight,
250
+ stencil,
249
251
  storybook,
250
252
  stryker,
251
253
  stylelint,
@@ -3,9 +3,13 @@ import { toDeferResolve, toProductionEntry } from "../../util/input.js";
3
3
  import { join } from "../../util/path.js";
4
4
  import { hasDependency } from "../../util/plugin.js";
5
5
  const title = 'Metro';
6
- const enablers = ['metro', '@react-native/metro-config'];
6
+ const enablers = ['metro', '@react-native/metro-config', 'expo'];
7
7
  const isEnabled = options => hasDependency(options.dependencies, enablers);
8
- const config = ['metro.config.{js,cjs,json}', 'package.json'];
8
+ const config = [
9
+ 'metro.config.{js,cjs,mjs,ts,cts,mts,json}',
10
+ '.config/metro.{js,cjs,mjs,ts,cts,mts,json}',
11
+ 'package.json',
12
+ ];
9
13
  const DEFAULT_PLATFORMS = ['ios', 'android', 'windows', 'web'];
10
14
  const PLATFORMS = [...DEFAULT_PLATFORMS, 'native', 'default'];
11
15
  const DEFAULT_EXTENSIONS = ['js', 'jsx', 'json', 'ts', 'tsx'];
@@ -1,3 +1,5 @@
1
+ import { toDependency, toEntry } from "../../util/input.js";
2
+ import { isInternal } from "../../util/path.js";
1
3
  import { hasDependency } from "../../util/plugin.js";
2
4
  const title = 'Oxlint';
3
5
  const enablers = ['oxlint'];
@@ -6,11 +8,31 @@ const config = ['.oxlintrc.json', 'oxlint.config.ts'];
6
8
  const args = {
7
9
  config: true,
8
10
  };
11
+ const resolveJsPlugins = (jsPlugins) => {
12
+ const inputs = [];
13
+ for (const plugin of jsPlugins ?? []) {
14
+ const specifier = typeof plugin === 'string' ? plugin : plugin.specifier;
15
+ if (!isInternal(specifier))
16
+ inputs.push(toDependency(specifier));
17
+ else
18
+ inputs.push(toEntry(specifier));
19
+ }
20
+ return inputs;
21
+ };
22
+ const resolveConfig = config => {
23
+ const inputs = resolveJsPlugins(config.jsPlugins);
24
+ for (const override of config.overrides ?? []) {
25
+ for (const input of resolveJsPlugins(override.jsPlugins))
26
+ inputs.push(input);
27
+ }
28
+ return inputs;
29
+ };
9
30
  const plugin = {
10
31
  title,
11
32
  enablers,
12
33
  isEnabled,
13
34
  config,
35
+ resolveConfig,
14
36
  args,
15
37
  };
16
38
  export default plugin;
@@ -0,0 +1,12 @@
1
+ type JsPlugin = string | {
2
+ name: string;
3
+ specifier: string;
4
+ };
5
+ type Override = {
6
+ jsPlugins?: JsPlugin[];
7
+ };
8
+ export type OxlintConfig = {
9
+ jsPlugins?: JsPlugin[];
10
+ overrides?: Override[];
11
+ };
12
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from '../../types/config.ts';
2
+ declare const plugin: Plugin;
3
+ export default plugin;
@@ -0,0 +1,30 @@
1
+ import { toConfig, toProductionEntry } from "../../util/input.js";
2
+ import { hasDependency } from "../../util/plugin.js";
3
+ import { collectPropertyValues } from "../../typescript/ast-helpers.js";
4
+ const title = 'Stencil';
5
+ const enablers = ['@stencil/core'];
6
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
7
+ const config = ['stencil.config.{ts,js}'];
8
+ const production = ['src/**/*.tsx'];
9
+ const resolveFromAST = program => {
10
+ const inputs = [];
11
+ const srcDirs = collectPropertyValues(program, 'srcDir');
12
+ const srcDir = srcDirs.size > 0 ? [...srcDirs][0] : 'src';
13
+ inputs.push(toProductionEntry(`${srcDir}/**/*.tsx`));
14
+ for (const script of collectPropertyValues(program, 'globalScript')) {
15
+ inputs.push(toProductionEntry(script));
16
+ }
17
+ for (const tsconfig of collectPropertyValues(program, 'tsconfig')) {
18
+ inputs.push(toConfig('typescript', tsconfig));
19
+ }
20
+ return inputs;
21
+ };
22
+ const plugin = {
23
+ title,
24
+ enablers,
25
+ isEnabled,
26
+ config,
27
+ production,
28
+ resolveFromAST,
29
+ };
30
+ export default plugin;
@@ -106,7 +106,7 @@ export const finalizeConfigurationHints = (results, options) => {
106
106
  const hints = hintsByType.get(hintType) ?? [];
107
107
  const topHints = hints.length > 10 ? Array.from(hints).slice(0, 10) : hints;
108
108
  const row = topHints.map(hint => {
109
- hint.filePath = relative(options.cwd, hint.filePath ?? options.configFilePath ?? '');
109
+ hint.filePath = relative(options.cwd, hint.filePath || options.configFilePath || options.cwd);
110
110
  const hintPrinter = hintPrinters.get(hint.type);
111
111
  const message = hintPrinter ? hintPrinter.print({ ...hint, configFilePath: options.configFilePath }) : '';
112
112
  return { ...hint, message };
@@ -532,6 +532,11 @@ export declare const workspaceConfigurationSchema: z.ZodMiniObject<{
532
532
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
533
533
  project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
534
534
  }, z.core.$strip>]>>;
535
+ stencil: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
536
+ config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
537
+ entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
538
+ project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
539
+ }, z.core.$strip>]>>;
535
540
  storybook: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
536
541
  config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
537
542
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
@@ -1249,6 +1254,11 @@ export declare const knipConfigurationSchema: z.ZodMiniObject<{
1249
1254
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1250
1255
  project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1251
1256
  }, z.core.$strip>]>>;
1257
+ stencil: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
1258
+ config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1259
+ entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1260
+ project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1261
+ }, z.core.$strip>]>>;
1252
1262
  storybook: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
1253
1263
  config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1254
1264
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
@@ -1955,6 +1965,11 @@ export declare const knipConfigurationSchema: z.ZodMiniObject<{
1955
1965
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1956
1966
  project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1957
1967
  }, z.core.$strip>]>>;
1968
+ stencil: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
1969
+ config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1970
+ entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1971
+ project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1972
+ }, z.core.$strip>]>>;
1958
1973
  storybook: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
1959
1974
  config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1960
1975
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
@@ -536,6 +536,11 @@ export declare const pluginsSchema: z.ZodMiniObject<{
536
536
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
537
537
  project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
538
538
  }, z.core.$strip>]>;
539
+ stencil: z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
540
+ config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
541
+ entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
542
+ project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
543
+ }, z.core.$strip>]>;
539
544
  storybook: z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
540
545
  config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
541
546
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
@@ -116,6 +116,7 @@ export const pluginsSchema = z.object({
116
116
  'size-limit': pluginSchema,
117
117
  sst: pluginSchema,
118
118
  starlight: pluginSchema,
119
+ stencil: pluginSchema,
119
120
  storybook: pluginSchema,
120
121
  stryker: pluginSchema,
121
122
  stylelint: 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' | 'execa' | 'expo' | 'expressive-code' | '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' | 'openapi-ts' | 'oxfmt' | 'oxlint' | 'parcel' | 'payload' | 'playwright' | 'playwright-ct' | 'playwright-test' | 'plop' | 'pm2' | 'pnpm' | 'postcss' | 'preconstruct' | 'prettier' | 'prisma' | 'qwik' | 'raycast' | 'react-cosmos' | 'react-native' | 'react-router' | 'relay' | 'release-it' | 'remark' | 'remix' | 'rollup' | 'rsbuild' | 'rslib' | 'rspack' | 'rstest' | 'sanity' | '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' | 'zx';
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", "execa", "expo", "expressive-code", "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", "openapi-ts", "oxfmt", "oxlint", "parcel", "payload", "playwright", "playwright-ct", "playwright-test", "plop", "pm2", "pnpm", "postcss", "preconstruct", "prettier", "prisma", "qwik", "raycast", "react-cosmos", "react-native", "react-router", "relay", "release-it", "remark", "remix", "rollup", "rsbuild", "rslib", "rspack", "rstest", "sanity", "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", "zx"];
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' | 'execa' | 'expo' | 'expressive-code' | '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' | 'openapi-ts' | 'oxfmt' | 'oxlint' | 'parcel' | 'payload' | 'playwright' | 'playwright-ct' | 'playwright-test' | 'plop' | 'pm2' | 'pnpm' | 'postcss' | 'preconstruct' | 'prettier' | 'prisma' | 'qwik' | 'raycast' | 'react-cosmos' | 'react-native' | 'react-router' | 'relay' | 'release-it' | 'remark' | 'remix' | 'rollup' | 'rsbuild' | 'rslib' | 'rspack' | 'rstest' | 'sanity' | 'semantic-release' | 'sentry' | 'simple-git-hooks' | 'size-limit' | 'sst' | 'starlight' | 'stencil' | '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' | 'zx';
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", "execa", "expo", "expressive-code", "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", "openapi-ts", "oxfmt", "oxlint", "parcel", "payload", "playwright", "playwright-ct", "playwright-test", "plop", "pm2", "pnpm", "postcss", "preconstruct", "prettier", "prisma", "qwik", "raycast", "react-cosmos", "react-native", "react-router", "relay", "release-it", "remark", "remix", "rollup", "rsbuild", "rslib", "rspack", "rstest", "sanity", "semantic-release", "sentry", "simple-git-hooks", "size-limit", "sst", "starlight", "stencil", "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", "zx"];
@@ -105,6 +105,7 @@ export const pluginNames = [
105
105
  'size-limit',
106
106
  'sst',
107
107
  'starlight',
108
+ 'stencil',
108
109
  'storybook',
109
110
  'stryker',
110
111
  'stylelint',
@@ -4,14 +4,28 @@ import { DEFAULT_EXTENSIONS, DTS_EXTENSIONS } from "../constants.js";
4
4
  import { sanitizeSpecifier } from "../util/modules.js";
5
5
  import { timerify } from "../util/Performance.js";
6
6
  import { dirname, extname, isAbsolute, isInNodeModules, join } from "../util/path.js";
7
- import { _createSyncModuleResolver, _resolveModuleSync, convertPathsToAlias } from "../util/resolve.js";
7
+ import { _createSyncModuleResolver, _resolveModuleSync } from "../util/resolve.js";
8
+ function compilePathMappings(paths) {
9
+ if (!paths)
10
+ return undefined;
11
+ const mappings = [];
12
+ for (const key in paths) {
13
+ const starIdx = key.indexOf('*');
14
+ if (starIdx >= 0) {
15
+ mappings.push({ prefix: key.slice(0, starIdx), wildcard: true, values: paths[key] });
16
+ }
17
+ else {
18
+ mappings.push({ prefix: key, wildcard: false, values: paths[key] });
19
+ }
20
+ }
21
+ return mappings.length > 0 ? mappings : undefined;
22
+ }
8
23
  export function createCustomModuleResolver(compilerOptions, customCompilerExtensions, toSourceFilePath) {
9
24
  const customCompilerExtensionsSet = new Set(customCompilerExtensions);
10
25
  const hasCustomExts = customCompilerExtensionsSet.size > 0;
11
26
  const extensions = [...DEFAULT_EXTENSIONS, ...customCompilerExtensions, ...DTS_EXTENSIONS];
12
- const alias = convertPathsToAlias(compilerOptions.paths);
13
27
  const resolveSync = hasCustomExts ? _createSyncModuleResolver(extensions) : _resolveModuleSync;
14
- const resolveWithAlias = alias ? _createSyncModuleResolver(extensions, alias) : undefined;
28
+ const pathMappings = compilePathMappings(compilerOptions.paths);
15
29
  const rootDirs = compilerOptions.rootDirs;
16
30
  function toSourcePath(resolvedFileName) {
17
31
  if (!hasCustomExts || !customCompilerExtensionsSet.has(extname(resolvedFileName))) {
@@ -27,24 +41,27 @@ export function createCustomModuleResolver(compilerOptions, customCompilerExtens
27
41
  };
28
42
  }
29
43
  function resolveModuleName(name, containingFile) {
30
- const sanitizedSpecifier = sanitizeSpecifier(name);
31
- if (isBuiltin(sanitizedSpecifier))
44
+ const specifier = sanitizeSpecifier(name);
45
+ if (isBuiltin(specifier))
32
46
  return undefined;
33
- const resolvedFileName = resolveSync(sanitizedSpecifier, containingFile);
47
+ const resolvedFileName = resolveSync(specifier, containingFile);
34
48
  if (resolvedFileName)
35
49
  return toResult(resolvedFileName);
36
- if (resolveWithAlias) {
37
- const aliasResolved = resolveWithAlias(sanitizedSpecifier, containingFile);
38
- if (aliasResolved)
39
- return toResult(aliasResolved);
40
- }
41
- const candidate = isAbsolute(sanitizedSpecifier)
42
- ? sanitizedSpecifier
43
- : join(dirname(containingFile), sanitizedSpecifier);
44
- if (existsSync(candidate)) {
45
- return { resolvedFileName: candidate, isExternalLibraryImport: false };
50
+ if (pathMappings) {
51
+ for (const { prefix, wildcard, values } of pathMappings) {
52
+ if (wildcard ? specifier.startsWith(prefix) : specifier === prefix) {
53
+ const captured = wildcard ? specifier.slice(prefix.length) : '';
54
+ for (const value of values) {
55
+ const starIdx = value.indexOf('*');
56
+ const mapped = starIdx >= 0 ? value.slice(0, starIdx) + captured + value.slice(starIdx + 1) : value;
57
+ const resolved = resolveSync(mapped, containingFile);
58
+ if (resolved)
59
+ return toResult(resolved);
60
+ }
61
+ }
62
+ }
46
63
  }
47
- if (rootDirs && !isAbsolute(sanitizedSpecifier)) {
64
+ if (rootDirs && !isAbsolute(specifier)) {
48
65
  const containingDir = dirname(containingFile);
49
66
  for (const srcRoot of rootDirs) {
50
67
  if (!containingDir.startsWith(srcRoot))
@@ -53,13 +70,17 @@ export function createCustomModuleResolver(compilerOptions, customCompilerExtens
53
70
  for (const targetRoot of rootDirs) {
54
71
  if (targetRoot === srcRoot)
55
72
  continue;
56
- const mapped = join(targetRoot, relPath, sanitizedSpecifier);
73
+ const mapped = join(targetRoot, relPath, specifier);
57
74
  const resolved = resolveSync(mapped, containingFile);
58
75
  if (resolved)
59
76
  return toResult(resolved);
60
77
  }
61
78
  }
62
79
  }
80
+ const candidate = isAbsolute(specifier) ? specifier : join(dirname(containingFile), specifier);
81
+ if (existsSync(candidate)) {
82
+ return { resolvedFileName: candidate, isExternalLibraryImport: false };
83
+ }
63
84
  }
64
85
  return timerify(resolveModuleName);
65
86
  }
@@ -150,7 +150,7 @@ const _addParamShadows = (params, body) => {
150
150
  if (!body || !params)
151
151
  return;
152
152
  const range = [body.start, body.end];
153
- const items = Array.isArray(params) ? params : params.items ?? params;
153
+ const items = Array.isArray(params) ? params : (params.items ?? params);
154
154
  for (const param of items)
155
155
  _collectBindingNames(param, range);
156
156
  };
@@ -572,6 +572,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
572
572
  entry?: string | string[] | undefined;
573
573
  project?: string | string[] | undefined;
574
574
  } | undefined;
575
+ stencil?: string | boolean | string[] | {
576
+ config?: string | string[] | undefined;
577
+ entry?: string | string[] | undefined;
578
+ project?: string | string[] | undefined;
579
+ } | undefined;
575
580
  storybook?: string | boolean | string[] | {
576
581
  config?: string | string[] | undefined;
577
582
  entry?: string | string[] | undefined;
@@ -1278,6 +1283,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
1278
1283
  entry?: string | string[] | undefined;
1279
1284
  project?: string | string[] | undefined;
1280
1285
  } | undefined;
1286
+ stencil?: string | boolean | string[] | {
1287
+ config?: string | string[] | undefined;
1288
+ entry?: string | string[] | undefined;
1289
+ project?: string | string[] | undefined;
1290
+ } | undefined;
1281
1291
  storybook?: string | boolean | string[] | {
1282
1292
  config?: string | string[] | undefined;
1283
1293
  entry?: string | string[] | undefined;
@@ -1,5 +1,4 @@
1
1
  export declare const _resolveModuleSync: (specifier: string, basePath: string) => string | undefined;
2
- export declare const _createSyncModuleResolver: (extensions: string[], alias?: Record<string, string[]>) => (specifier: string, basePath: string) => string | undefined;
3
- export declare function convertPathsToAlias(paths: Record<string, string[]> | undefined): Record<string, string[]> | undefined;
2
+ export declare const _createSyncModuleResolver: (extensions: string[]) => (specifier: string, basePath: string) => string | undefined;
4
3
  export declare function clearResolverCache(): void;
5
4
  export declare const _resolveSync: (specifier: string, baseDir: string) => string | undefined;
@@ -34,18 +34,7 @@ const createSyncModuleResolver = (extensions, alias) => {
34
34
  };
35
35
  const resolveModuleSync = createSyncModuleResolver([...DEFAULT_EXTENSIONS, ...DTS_EXTENSIONS, '.json', '.jsonc']);
36
36
  export const _resolveModuleSync = timerify(resolveModuleSync, 'resolveModuleSync');
37
- export const _createSyncModuleResolver = (extensions, alias) => timerify(createSyncModuleResolver(extensions, alias), 'resolveModuleSync');
38
- export function convertPathsToAlias(paths) {
39
- if (!paths)
40
- return undefined;
41
- const alias = {};
42
- for (const key in paths) {
43
- const stripWildcard = key.endsWith('/*');
44
- const aliasKey = stripWildcard ? key.slice(0, -2) : key;
45
- alias[aliasKey] = stripWildcard ? paths[key].map(v => (v.endsWith('/*') ? v.slice(0, -2) : v)) : paths[key];
46
- }
47
- return alias;
48
- }
37
+ export const _createSyncModuleResolver = (extensions) => timerify(createSyncModuleResolver(extensions), 'resolveModuleSync');
49
38
  const createSyncResolver = (extensions) => {
50
39
  const resolver = new ResolverFactory({
51
40
  extensions,
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "6.0.5";
1
+ export declare const version = "6.1.0";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '6.0.5';
1
+ export const version = '6.1.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "6.0.5",
3
+ "version": "6.1.0",
4
4
  "description": "Find and fix unused dependencies, exports and files in your TypeScript and JavaScript projects",
5
5
  "keywords": [
6
6
  "analysis",
@@ -83,11 +83,11 @@
83
83
  "get-tsconfig": "4.13.7",
84
84
  "jiti": "^2.6.0",
85
85
  "minimist": "^1.2.8",
86
- "oxc-parser": "^0.120.0",
86
+ "oxc-parser": "^0.121.0",
87
87
  "oxc-resolver": "^11.19.1",
88
88
  "picocolors": "^1.1.1",
89
89
  "picomatch": "^4.0.1",
90
- "smol-toml": "^1.5.2",
90
+ "smol-toml": "^1.6.1",
91
91
  "strip-json-comments": "5.0.3",
92
92
  "unbash": "^2.2.0",
93
93
  "yaml": "^2.8.2",
package/schema.json CHANGED
@@ -752,6 +752,10 @@
752
752
  "title": "starlight plugin configuration (https://knip.dev/reference/plugins/starlight)",
753
753
  "$ref": "#/definitions/plugin"
754
754
  },
755
+ "stencil": {
756
+ "title": "stencil plugin configuration (https://knip.dev/reference/plugins/stencil)",
757
+ "$ref": "#/definitions/plugin"
758
+ },
755
759
  "storybook": {
756
760
  "title": "Storybook plugin configuration (https://knip.dev/reference/plugins/storybook)",
757
761
  "$ref": "#/definitions/plugin"