knip 5.84.0 → 5.85.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.
Files changed (36) hide show
  1. package/dist/ConfigurationChief.d.ts +6 -0
  2. package/dist/JsonCatalogPeeker.d.ts +1 -1
  3. package/dist/JsonCatalogPeeker.js +1 -1
  4. package/dist/PackagePeeker.d.ts +1 -1
  5. package/dist/PackagePeeker.js +1 -1
  6. package/dist/YamlCatalogPeeker.d.ts +1 -1
  7. package/dist/YamlCatalogPeeker.js +1 -1
  8. package/dist/binaries/package-manager/pnpm.js +1 -1
  9. package/dist/compilers/index.d.ts +10 -0
  10. package/dist/plugins/index.d.ts +1 -0
  11. package/dist/plugins/index.js +2 -0
  12. package/dist/plugins/next/index.js +10 -8
  13. package/dist/plugins/payload/index.d.ts +3 -0
  14. package/dist/plugins/payload/index.js +29 -0
  15. package/dist/plugins/payload/types.d.ts +10 -0
  16. package/dist/plugins/payload/types.js +1 -0
  17. package/dist/plugins/tsdown/index.js +12 -7
  18. package/dist/plugins/tsdown/types.d.ts +1 -1
  19. package/dist/plugins/vitest/index.js +4 -5
  20. package/dist/plugins/webpack/visitors/requireContext.js +2 -1
  21. package/dist/run.js +1 -1
  22. package/dist/schema/configuration.d.ts +15 -0
  23. package/dist/schema/plugins.d.ts +5 -0
  24. package/dist/schema/plugins.js +1 -0
  25. package/dist/types/PluginNames.d.ts +2 -2
  26. package/dist/types/PluginNames.js +1 -0
  27. package/dist/typescript/ast-helpers.js +5 -6
  28. package/dist/typescript/visitors/dynamic-imports/importCall.js +16 -0
  29. package/dist/typescript/visitors/dynamic-imports/moduleRegister.js +8 -1
  30. package/dist/util/create-options.d.ts +10 -0
  31. package/dist/util/glob-core.d.ts +2 -2
  32. package/dist/util/glob-core.js +38 -14
  33. package/dist/version.d.ts +1 -1
  34. package/dist/version.js +1 -1
  35. package/package.json +2 -2
  36. package/schema.json +4 -0
@@ -416,6 +416,11 @@ export declare class ConfigurationChief {
416
416
  entry?: string | string[] | undefined;
417
417
  project?: string | string[] | undefined;
418
418
  } | undefined;
419
+ payload?: string | boolean | string[] | {
420
+ config?: string | string[] | undefined;
421
+ entry?: string | string[] | undefined;
422
+ project?: string | string[] | undefined;
423
+ } | undefined;
419
424
  playwright?: string | boolean | string[] | {
420
425
  config?: string | string[] | undefined;
421
426
  entry?: string | string[] | undefined;
@@ -823,6 +828,7 @@ export declare class ConfigurationChief {
823
828
  oclif?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
824
829
  oxlint?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
825
830
  parcel?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
831
+ payload?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
826
832
  playwright?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
827
833
  "playwright-ct"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
828
834
  "playwright-test"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
@@ -1,8 +1,8 @@
1
1
  export declare class JsonCatalogPeeker {
2
- private fileContent;
3
2
  private lines;
4
3
  private sections;
5
4
  private ready;
5
+ private fileContent;
6
6
  constructor(fileContent: string);
7
7
  private init;
8
8
  getLocation(parentSymbol: string, symbol: string): {
@@ -1,9 +1,9 @@
1
1
  import { DEFAULT_CATALOG } from './util/catalog.js';
2
2
  export class JsonCatalogPeeker {
3
- fileContent;
4
3
  lines = [];
5
4
  sections = {};
6
5
  ready = false;
6
+ fileContent;
7
7
  constructor(fileContent) {
8
8
  this.fileContent = fileContent;
9
9
  }
@@ -1,8 +1,8 @@
1
1
  export declare class PackagePeeker {
2
- private manifestStr;
3
2
  private lines;
4
3
  private sections;
5
4
  private ready;
5
+ private manifestStr;
6
6
  constructor(manifestStr: string);
7
7
  private init;
8
8
  getLocation(type: 'dependencies' | 'devDependencies' | 'optionalPeerDependencies', packageName: string): {
@@ -1,8 +1,8 @@
1
1
  export class PackagePeeker {
2
- manifestStr;
3
2
  lines = [];
4
3
  sections = {};
5
4
  ready = false;
5
+ manifestStr;
6
6
  constructor(manifestStr) {
7
7
  this.manifestStr = manifestStr;
8
8
  }
@@ -1,8 +1,8 @@
1
1
  export declare class YamlCatalogPeeker {
2
- private fileContent;
3
2
  private lines;
4
3
  private sections;
5
4
  private ready;
5
+ private fileContent;
6
6
  constructor(fileContent: string);
7
7
  private init;
8
8
  getLocation(parentSymbol: string, symbol: string): {
@@ -5,10 +5,10 @@ function matchesKey(line, indent, key) {
5
5
  line.startsWith(`${indent}'${key}':`));
6
6
  }
7
7
  export class YamlCatalogPeeker {
8
- fileContent;
9
8
  lines = [];
10
9
  sections = {};
11
10
  ready = false;
11
+ fileContent;
12
12
  constructor(fileContent) {
13
13
  this.fileContent = fileContent;
14
14
  }
@@ -63,7 +63,7 @@ const commands = [
63
63
  ];
64
64
  export const resolve = (_binary, args, options) => {
65
65
  const parsed = parseArgs(args, {
66
- boolean: ['recursive', 'silent', 'shell-mode'],
66
+ boolean: ['aggregate-output', 'if-present', 'parallel', 'recursive', 'reverse', 'shell-mode', 'silent', 'stream'],
67
67
  alias: { recursive: 'r', silent: 's', 'shell-mode': 'c', filter: 'F' },
68
68
  '--': true,
69
69
  });
@@ -365,6 +365,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
365
365
  entry?: string | string[] | undefined;
366
366
  project?: string | string[] | undefined;
367
367
  } | undefined;
368
+ payload?: string | boolean | string[] | {
369
+ config?: string | string[] | undefined;
370
+ entry?: string | string[] | undefined;
371
+ project?: string | string[] | undefined;
372
+ } | undefined;
368
373
  playwright?: string | boolean | string[] | {
369
374
  config?: string | string[] | undefined;
370
375
  entry?: string | string[] | undefined;
@@ -1041,6 +1046,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
1041
1046
  entry?: string | string[] | undefined;
1042
1047
  project?: string | string[] | undefined;
1043
1048
  } | undefined;
1049
+ payload?: string | boolean | string[] | {
1050
+ config?: string | string[] | undefined;
1051
+ entry?: string | string[] | undefined;
1052
+ project?: string | string[] | undefined;
1053
+ } | undefined;
1044
1054
  playwright?: string | boolean | string[] | {
1045
1055
  config?: string | string[] | undefined;
1046
1056
  entry?: string | string[] | undefined;
@@ -76,6 +76,7 @@ export declare const Plugins: {
76
76
  oclif: import("../types/config.js").Plugin;
77
77
  oxlint: import("../types/config.js").Plugin;
78
78
  parcel: import("../types/config.js").Plugin;
79
+ payload: import("../types/config.js").Plugin;
79
80
  playwright: import("../types/config.js").Plugin;
80
81
  'playwright-ct': import("../types/config.js").Plugin;
81
82
  'playwright-test': import("../types/config.js").Plugin;
@@ -70,6 +70,7 @@ import { default as nyc } from './nyc/index.js';
70
70
  import { default as oclif } from './oclif/index.js';
71
71
  import { default as oxlint } from './oxlint/index.js';
72
72
  import { default as parcel } from './parcel/index.js';
73
+ import { default as payload } from './payload/index.js';
73
74
  import { default as playwright } from './playwright/index.js';
74
75
  import { default as playwrightCt } from './playwright-ct/index.js';
75
76
  import { default as playwrightTest } from './playwright-test/index.js';
@@ -206,6 +207,7 @@ export const Plugins = {
206
207
  oclif,
207
208
  oxlint,
208
209
  parcel,
210
+ payload,
209
211
  playwright,
210
212
  'playwright-ct': playwrightCt,
211
213
  'playwright-test': playwrightTest,
@@ -8,17 +8,19 @@ const config = ['next.config.{js,ts,cjs,mjs}'];
8
8
  const defaultPageExtensions = ['{js,jsx,ts,tsx}'];
9
9
  const productionEntryFilePatterns = [
10
10
  '{instrumentation,instrumentation-client,middleware,proxy}.{js,ts}',
11
- 'app/{manifest,robots}.{js,ts}',
11
+ 'app/{,[(]*[)]/}{manifest,robots}.{js,ts}',
12
12
  'app/**/sitemap.{js,ts}',
13
- 'app/**/{icon,apple-icon}.{js,jsx,ts,tsx}',
14
- 'app/**/{opengraph,twitter}-image.{js,jsx,ts,tsx}',
13
+ 'app/**/{icon,apple-icon,opengraph-image,twitter-image}.{js,jsx,ts,tsx}',
15
14
  ];
16
15
  const getEntryFilePatterns = (pageExtensions = defaultPageExtensions) => {
17
- const patterns = [...productionEntryFilePatterns];
18
- for (const ext of pageExtensions) {
19
- patterns.push(`app/global-{error,not-found}.${ext}`, `app/**/{error,layout,loading,not-found,page,template,default,forbidden,unauthorized}.${ext}`, `app/**/route.${ext}`, `pages/**/*.${ext}`);
20
- }
21
- return [...patterns, ...patterns.map(pattern => `src/${pattern}`)];
16
+ const ext = pageExtensions.length === 1 ? pageExtensions[0] : `{${pageExtensions.join(',')}}`;
17
+ return [
18
+ ...productionEntryFilePatterns,
19
+ `app/global-{error,not-found}.${ext}`,
20
+ `app/**/{default,error,forbidden,loading,not-found,unauthorized}.${ext}`,
21
+ `app/**/{layout,page,route,template}.${ext}`,
22
+ `pages/**/*.${ext}`,
23
+ ].flatMap(pattern => [pattern, `src/${pattern}`]);
22
24
  };
23
25
  const production = getEntryFilePatterns();
24
26
  const resolveFromAST = sourceFile => {
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from '../../types/config.js';
2
+ declare const plugin: Plugin;
3
+ export default plugin;
@@ -0,0 +1,29 @@
1
+ import { toDeferResolve } from '../../util/input.js';
2
+ import { hasDependency } from '../../util/plugin.js';
3
+ const title = 'Payload CMS';
4
+ const enablers = ['payload'];
5
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
6
+ const config = ['payload.config.ts', 'src/payload.config.ts'];
7
+ const resolveConfig = async (config) => {
8
+ const awaitedConfig = await config;
9
+ const importMapFile = awaitedConfig?.admin?.importMap?.importMapFile;
10
+ if (importMapFile) {
11
+ return [toDeferResolve(importMapFile, { optional: true })];
12
+ }
13
+ const adminRoute = awaitedConfig?.routes?.admin ?? '/admin';
14
+ const possibleImportMapPaths = [
15
+ `app/(payload)${adminRoute}/importMap.js`,
16
+ `src/app/(payload)${adminRoute}/importMap.js`,
17
+ ];
18
+ return possibleImportMapPaths.map(id => toDeferResolve(id, { optional: true }));
19
+ };
20
+ const project = ['!migrations/**', '!src/migrations/**', '!payload-types.ts', '!src/payload-types.ts'];
21
+ const plugin = {
22
+ title,
23
+ enablers,
24
+ isEnabled,
25
+ config,
26
+ resolveConfig,
27
+ project,
28
+ };
29
+ export default plugin;
@@ -0,0 +1,10 @@
1
+ export type PayloadConfig = Promise<{
2
+ admin?: {
3
+ importMap?: {
4
+ importMapFile?: string;
5
+ };
6
+ };
7
+ routes?: {
8
+ admin?: string;
9
+ };
10
+ }>;
@@ -0,0 +1 @@
1
+ export {};
@@ -4,18 +4,23 @@ const title = 'tsdown';
4
4
  const enablers = ['tsdown'];
5
5
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
6
6
  const config = ['tsdown.config.{ts,mts,cts,js,mjs,cjs,json}', 'package.json'];
7
+ const normalizeEntry = (entry) => {
8
+ if (!entry)
9
+ return [];
10
+ if (typeof entry === "string") {
11
+ return [entry];
12
+ }
13
+ if (Array.isArray(entry)) {
14
+ return entry.flatMap(normalizeEntry);
15
+ }
16
+ return Object.values(entry).flatMap(value => Array.isArray(value) ? value : [value]);
17
+ };
7
18
  const resolveConfig = async (config) => {
8
19
  if (typeof config === 'function')
9
20
  config = await config({});
10
21
  const entryPatterns = [config]
11
22
  .flat()
12
- .flatMap(config => {
13
- if (!config.entry)
14
- return [];
15
- if (Array.isArray(config.entry))
16
- return config.entry;
17
- return Object.values(config.entry);
18
- })
23
+ .flatMap(config => normalizeEntry(config.entry))
19
24
  .map(id => toProductionEntry(id, { allowIncludeExports: true }));
20
25
  return entryPatterns;
21
26
  };
@@ -1,4 +1,4 @@
1
- type Entry = string[] | Record<string, string>;
1
+ export type Entry = (string | Record<string, string[] | string>)[] | string | Record<string, string[] | string>;
2
2
  type Options = {
3
3
  entry?: Entry;
4
4
  };
@@ -22,8 +22,8 @@ const findConfigDependencies = (localConfig, options, vitestRoot) => {
22
22
  : [toDependency(getEnvSpecifier(env))]
23
23
  : [];
24
24
  const reporters = getExternalReporters(testConfig.reporters);
25
- const hasCoverageEnabled = testConfig.coverage && testConfig.coverage.enabled !== false;
26
- const coverage = hasCoverageEnabled ? [`@vitest/coverage-${testConfig.coverage?.provider ?? 'v8'}`] : [];
25
+ const hasCoverage = testConfig.coverage && (testConfig.coverage.enabled !== false || testConfig.coverage.provider);
26
+ const coverage = hasCoverage ? [`@vitest/coverage-${testConfig.coverage?.provider ?? 'v8'}`] : [];
27
27
  const setupFiles = [testConfig.setupFiles ?? []]
28
28
  .flat()
29
29
  .map(specifier => ({ ...toDeferResolve(specifier), dir: vitestRoot }));
@@ -165,9 +165,8 @@ const args = {
165
165
  const inputs = [];
166
166
  if (parsed['ui'])
167
167
  inputs.push(toDependency('@vitest/ui', { optional: true }));
168
- if (parsed['coverage']) {
169
- const provider = typeof parsed['coverage'] === 'object' ? parsed['coverage'].provider : undefined;
170
- inputs.push(toDependency(`@vitest/coverage-${provider ?? 'v8'}`));
168
+ if (typeof parsed['coverage'] === 'object' && parsed['coverage'].provider) {
169
+ inputs.push(toDependency(`@vitest/coverage-${parsed['coverage'].provider}`));
171
170
  }
172
171
  if (parsed['reporter']) {
173
172
  for (const reporter of getExternalReporters([parsed['reporter']].flat())) {
@@ -15,7 +15,8 @@ export const requireContextCall = sourceFile => {
15
15
  const pattern = isRecursive ? '**/*' : '*';
16
16
  const files = _syncGlob({ patterns: [pattern], cwd });
17
17
  const filter = regExpArg && ts.isRegularExpressionLiteral(regExpArg) ? regExpArg.text.match(/^\/(.+)\/([gimsuy]*)$/) : null;
18
- const matched = filter ? files.filter(file => new RegExp(filter[1], filter[2]).test(file)) : files;
18
+ const re = filter ? new RegExp(filter[1], filter[2]) : null;
19
+ const matched = re ? files.filter(file => re.test(`./${file}`)) : files;
19
20
  return matched.map(filePath => ({
20
21
  specifier: isAbsolute(filePath) ? filePath : join(cwd, filePath),
21
22
  identifier: undefined,
package/dist/run.js CHANGED
@@ -22,7 +22,7 @@ export const run = async (options) => {
22
22
  const counselor = new CatalogCounselor(options);
23
23
  streamer.cast('Reading workspace configuration');
24
24
  const workspaces = await chief.getWorkspaces();
25
- const isGitIgnored = await getGitIgnoredHandler(options);
25
+ const isGitIgnored = await getGitIgnoredHandler(options, new Set(workspaces.map(w => w.dir)));
26
26
  collector.setWorkspaceFilter(chief.workspaceFilePathFilter);
27
27
  collector.setIgnoreIssues(chief.config.ignoreIssues);
28
28
  debugLogObject('*', 'Included workspaces', () => workspaces.map(w => w.pkgName));
@@ -362,6 +362,11 @@ export declare const workspaceConfigurationSchema: z.ZodMiniObject<{
362
362
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
363
363
  project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
364
364
  }, z.core.$strip>]>>;
365
+ payload: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
366
+ config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
367
+ entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
368
+ project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
369
+ }, z.core.$strip>]>>;
365
370
  playwright: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
366
371
  config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
367
372
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
@@ -1049,6 +1054,11 @@ export declare const knipConfigurationSchema: z.ZodMiniObject<{
1049
1054
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1050
1055
  project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1051
1056
  }, z.core.$strip>]>>;
1057
+ payload: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
1058
+ config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1059
+ entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1060
+ project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1061
+ }, z.core.$strip>]>>;
1052
1062
  playwright: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
1053
1063
  config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1054
1064
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
@@ -1725,6 +1735,11 @@ export declare const knipConfigurationSchema: z.ZodMiniObject<{
1725
1735
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1726
1736
  project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1727
1737
  }, z.core.$strip>]>>;
1738
+ payload: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
1739
+ config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1740
+ entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1741
+ project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1742
+ }, z.core.$strip>]>>;
1728
1743
  playwright: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
1729
1744
  config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
1730
1745
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
@@ -366,6 +366,11 @@ export declare const pluginsSchema: z.ZodMiniObject<{
366
366
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
367
367
  project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
368
368
  }, z.core.$strip>]>;
369
+ payload: z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
370
+ config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
371
+ entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
372
+ project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
373
+ }, z.core.$strip>]>;
369
374
  playwright: z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
370
375
  config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
371
376
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
@@ -82,6 +82,7 @@ export const pluginsSchema = z.object({
82
82
  oclif: pluginSchema,
83
83
  oxlint: pluginSchema,
84
84
  parcel: pluginSchema,
85
+ payload: pluginSchema,
85
86
  playwright: pluginSchema,
86
87
  'playwright-ct': pluginSchema,
87
88
  'playwright-test': 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' | 'oxlint' | 'parcel' | 'playwright' | 'playwright-ct' | 'playwright-test' | 'plop' | 'pm2' | 'pnpm' | 'postcss' | 'preconstruct' | 'prettier' | 'prisma' | 'react-cosmos' | 'react-native' | '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' | '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", "oxlint", "parcel", "playwright", "playwright-ct", "playwright-test", "plop", "pm2", "pnpm", "postcss", "preconstruct", "prettier", "prisma", "react-cosmos", "react-native", "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", "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' | 'oxlint' | 'parcel' | 'payload' | 'playwright' | 'playwright-ct' | 'playwright-test' | 'plop' | 'pm2' | 'pnpm' | 'postcss' | 'preconstruct' | 'prettier' | 'prisma' | 'react-cosmos' | 'react-native' | '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' | '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", "oxlint", "parcel", "payload", "playwright", "playwright-ct", "playwright-test", "plop", "pm2", "pnpm", "postcss", "preconstruct", "prettier", "prisma", "react-cosmos", "react-native", "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", "zx"];
@@ -71,6 +71,7 @@ export const pluginNames = [
71
71
  'oclif',
72
72
  'oxlint',
73
73
  'parcel',
74
+ 'payload',
74
75
  'playwright',
75
76
  'playwright-ct',
76
77
  'playwright-test',
@@ -76,12 +76,11 @@ export function stripQuotes(name) {
76
76
  }
77
77
  return name;
78
78
  }
79
- var CharacterCodes;
80
- (function (CharacterCodes) {
81
- CharacterCodes[CharacterCodes["backtick"] = 96] = "backtick";
82
- CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote";
83
- CharacterCodes[CharacterCodes["singleQuote"] = 39] = "singleQuote";
84
- })(CharacterCodes || (CharacterCodes = {}));
79
+ const CharacterCodes = {
80
+ backtick: 0x60,
81
+ doubleQuote: 0x22,
82
+ singleQuote: 0x27,
83
+ };
85
84
  function isQuoteOrBacktick(charCode) {
86
85
  return (charCode === CharacterCodes.singleQuote ||
87
86
  charCode === CharacterCodes.doubleQuote ||
@@ -97,6 +97,22 @@ export default visit(() => true, node => {
97
97
  namespace: undefined,
98
98
  }));
99
99
  }
100
+ const hasFunctionBoundary = findAncestor(node, _node => {
101
+ if (_node === variableDeclaration)
102
+ return 'STOP';
103
+ return ts.isArrowFunction(_node);
104
+ });
105
+ if (hasFunctionBoundary) {
106
+ return {
107
+ identifier: undefined,
108
+ specifier,
109
+ pos: node.arguments[0].pos,
110
+ modifiers: IMPORT_FLAGS.OPAQUE,
111
+ alias: undefined,
112
+ namespace: undefined,
113
+ symbol: undefined,
114
+ };
115
+ }
100
116
  return {
101
117
  identifier: 'default',
102
118
  alias,
@@ -10,7 +10,14 @@ export default visit(sourceFile => sourceFile.statements.some(isNodeModuleImport
10
10
  isPropertyAccessCall(node, 'module.register')) {
11
11
  if (node.arguments[0] && ts.isStringLiteralLike(node.arguments[0])) {
12
12
  const specifier = node.arguments[0].text;
13
- if (specifier)
13
+ const arg1 = node.arguments[1];
14
+ if (specifier &&
15
+ (!specifier.startsWith('.') ||
16
+ (arg1 &&
17
+ ts.isPropertyAccessExpression(arg1) &&
18
+ ts.isMetaProperty(arg1.expression) &&
19
+ arg1.expression.keywordToken === ts.SyntaxKind.ImportKeyword &&
20
+ arg1.name.text === 'url')))
14
21
  return {
15
22
  specifier,
16
23
  identifier: undefined,
@@ -405,6 +405,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
405
405
  entry?: string | string[] | undefined;
406
406
  project?: string | string[] | undefined;
407
407
  } | undefined;
408
+ payload?: string | boolean | string[] | {
409
+ config?: string | string[] | undefined;
410
+ entry?: string | string[] | undefined;
411
+ project?: string | string[] | undefined;
412
+ } | undefined;
408
413
  playwright?: string | boolean | string[] | {
409
414
  config?: string | string[] | undefined;
410
415
  entry?: string | string[] | undefined;
@@ -1081,6 +1086,11 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
1081
1086
  entry?: string | string[] | undefined;
1082
1087
  project?: string | string[] | undefined;
1083
1088
  } | undefined;
1089
+ payload?: string | boolean | string[] | {
1090
+ config?: string | string[] | undefined;
1091
+ entry?: string | string[] | undefined;
1092
+ project?: string | string[] | undefined;
1093
+ } | undefined;
1084
1094
  playwright?: string | boolean | string[] | {
1085
1095
  config?: string | string[] | undefined;
1086
1096
  entry?: string | string[] | undefined;
@@ -9,11 +9,11 @@ interface GlobOptions extends FastGlobOptions {
9
9
  dir: string;
10
10
  label?: string;
11
11
  }
12
- export declare const findAndParseGitignores: (cwd: string) => Promise<{
12
+ export declare const findAndParseGitignores: (cwd: string, workspaceDirs?: Set<string>) => Promise<{
13
13
  gitignoreFiles: string[];
14
14
  ignores: Set<string>;
15
15
  unignores: string[];
16
16
  }>;
17
17
  export declare function glob(_patterns: string[], options: GlobOptions): Promise<string[]>;
18
- export declare function getGitIgnoredHandler(options: Options): Promise<(path: string) => boolean>;
18
+ export declare function getGitIgnoredHandler(options: Options, workspaceDirs?: Set<string>): Promise<(path: string) => boolean>;
19
19
  export {};
@@ -45,20 +45,17 @@ const findAncestorGitignoreFiles = (cwd) => {
45
45
  }
46
46
  return gitignorePaths;
47
47
  };
48
- export const findAndParseGitignores = async (cwd) => {
48
+ export const findAndParseGitignores = async (cwd, workspaceDirs) => {
49
49
  const init = ['.git', ...GLOBAL_IGNORE_PATTERNS];
50
50
  const ignores = new Set(init);
51
51
  const unignores = [];
52
52
  const gitignoreFiles = [];
53
53
  const pmOptions = { ignore: unignores };
54
- const matchers = new Set(init.map(pattern => _picomatch(pattern, pmOptions)));
55
- const matcher = (str) => {
56
- for (const isMatch of matchers) {
57
- const state = isMatch(str);
58
- if (state)
59
- return state;
60
- }
61
- return false;
54
+ let deepFilterMatcher;
55
+ const getMatcher = () => {
56
+ if (!deepFilterMatcher)
57
+ deepFilterMatcher = _picomatch(Array.from(ignores), pmOptions);
58
+ return deepFilterMatcher;
62
59
  };
63
60
  const addFile = (filePath, baseDir) => {
64
61
  gitignoreFiles.push(relative(cwd, filePath));
@@ -116,8 +113,7 @@ export const findAndParseGitignores = async (cwd) => {
116
113
  else {
117
114
  cachedGitIgnores.set(cacheDir, { ignores: ignoresForDir, unignores: unignoresForDir });
118
115
  }
119
- for (const pattern of ignoresForDir)
120
- matchers.add(_picomatch(pattern, pmOptions));
116
+ deepFilterMatcher = undefined;
121
117
  };
122
118
  for (const filePath of findAncestorGitignoreFiles(cwd))
123
119
  addFile(filePath);
@@ -127,6 +123,33 @@ export const findAndParseGitignores = async (cwd) => {
127
123
  if (isFile(excludePath))
128
124
  addFile(excludePath, cwd);
129
125
  }
126
+ let isRelevantDir;
127
+ if (workspaceDirs && workspaceDirs.size > 0) {
128
+ const relevantAncestors = new Set();
129
+ const nonRootDirs = new Set();
130
+ for (const wsDir of workspaceDirs) {
131
+ if (wsDir !== cwd)
132
+ nonRootDirs.add(wsDir);
133
+ let dir = wsDir;
134
+ while (dir.length >= cwd.length) {
135
+ relevantAncestors.add(dir);
136
+ const parent = dirname(dir);
137
+ if (parent === dir)
138
+ break;
139
+ dir = parent;
140
+ }
141
+ }
142
+ if (nonRootDirs.size > 0) {
143
+ isRelevantDir = (absPath) => {
144
+ if (relevantAncestors.has(absPath))
145
+ return true;
146
+ for (const wsDir of nonRootDirs)
147
+ if (absPath.startsWith(wsDir + '/'))
148
+ return true;
149
+ return false;
150
+ };
151
+ }
152
+ }
130
153
  const entryFilter = (entry) => {
131
154
  if (entry.dirent.isFile() && entry.name === '.gitignore') {
132
155
  addFile(entry.path);
@@ -134,8 +157,9 @@ export const findAndParseGitignores = async (cwd) => {
134
157
  }
135
158
  return false;
136
159
  };
137
- const deepFilter = (entry) => !matcher(relative(cwd, entry.path));
160
+ const deepFilter = (entry) => (!isRelevantDir || isRelevantDir(toPosix(entry.path))) && !getMatcher()(relative(cwd, entry.path));
138
161
  await walk(cwd, {
162
+ concurrency: 16,
139
163
  entryFilter: timerify(entryFilter),
140
164
  deepFilter: timerify(deepFilter),
141
165
  });
@@ -184,11 +208,11 @@ export async function glob(_patterns, options) {
184
208
  }));
185
209
  return paths;
186
210
  }
187
- export async function getGitIgnoredHandler(options) {
211
+ export async function getGitIgnoredHandler(options, workspaceDirs) {
188
212
  cachedGitIgnores.clear();
189
213
  if (options.gitignore === false)
190
214
  return () => false;
191
- const { ignores, unignores } = await _parseFindGitignores(options.cwd);
215
+ const { ignores, unignores } = await _parseFindGitignores(options.cwd, workspaceDirs);
192
216
  const matcher = _picomatch(Array.from(ignores), { ignore: unignores });
193
217
  const isGitIgnored = (filePath) => matcher(relative(options.cwd, filePath));
194
218
  return timerify(isGitIgnored);
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "5.84.0";
1
+ export declare const version = "5.85.0";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '5.84.0';
1
+ export const version = '5.85.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "5.84.0",
3
+ "version": "5.85.0",
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": {
@@ -75,7 +75,7 @@
75
75
  "codeclimate-types": "^0.3.1",
76
76
  "glob-bin": "^1.0.0",
77
77
  "tsx": "^4.20.3",
78
- "typescript": "^5.5.2"
78
+ "typescript": "^5.8.3"
79
79
  },
80
80
  "engines": {
81
81
  "node": ">=18.18.0"
package/schema.json CHANGED
@@ -624,6 +624,10 @@
624
624
  "title": "oxlint plugin configuration (https://knip.dev/reference/plugins/oxlint)",
625
625
  "$ref": "#/definitions/plugin"
626
626
  },
627
+ "payload": {
628
+ "title": "payload plugin configuration (https://knip.dev/reference/plugins/payload)",
629
+ "$ref": "#/definitions/plugin"
630
+ },
627
631
  "playwright": {
628
632
  "title": "Playwright plugin configuration (https://knip.dev/reference/plugins/playwright)",
629
633
  "$ref": "#/definitions/plugin"