knip 6.46.1 → 6.47.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 (59) hide show
  1. package/dist/ConfigurationChief.d.ts +2 -0
  2. package/dist/IssueFixer.js +2 -6
  3. package/dist/WorkspaceWorker.d.ts +1 -0
  4. package/dist/WorkspaceWorker.js +10 -6
  5. package/dist/compilers/mdx.js +7 -1
  6. package/dist/plugins/angular/helpers.d.ts +7 -0
  7. package/dist/plugins/angular/helpers.js +58 -0
  8. package/dist/plugins/angular/index.js +5 -50
  9. package/dist/plugins/angular/types.d.ts +2 -2
  10. package/dist/plugins/astro/index.js +6 -1
  11. package/dist/plugins/cucumber/index.js +19 -7
  12. package/dist/plugins/cucumber/types.d.ts +1 -0
  13. package/dist/plugins/cypress/index.js +5 -0
  14. package/dist/plugins/drizzle/index.js +5 -0
  15. package/dist/plugins/github-action/index.js +13 -3
  16. package/dist/plugins/github-actions/index.d.ts +2 -1
  17. package/dist/plugins/github-actions/index.js +4 -2
  18. package/dist/plugins/github-actions/types.d.ts +5 -0
  19. package/dist/plugins/index.d.ts +2 -0
  20. package/dist/plugins/index.js +4 -0
  21. package/dist/plugins/mocha/index.js +6 -0
  22. package/dist/plugins/mocha/types.d.ts +3 -0
  23. package/dist/plugins/node/index.d.ts +2 -2
  24. package/dist/plugins/node/index.js +14 -3
  25. package/dist/plugins/nx/index.js +14 -1
  26. package/dist/plugins/plop/index.js +4 -0
  27. package/dist/plugins/prisma/index.js +2 -0
  28. package/dist/plugins/rollup/index.js +1 -1
  29. package/dist/plugins/sst/resolveFromAST.js +24 -15
  30. package/dist/plugins/start-server-and-test/index.d.ts +3 -0
  31. package/dist/plugins/start-server-and-test/index.js +10 -0
  32. package/dist/plugins/trigger-dev/index.d.ts +3 -0
  33. package/dist/plugins/trigger-dev/index.js +28 -0
  34. package/dist/plugins/tsx/index.js +1 -1
  35. package/dist/plugins/typedoc/index.js +5 -2
  36. package/dist/plugins/typescript/index.d.ts +12 -1
  37. package/dist/plugins/typescript/index.js +6 -3
  38. package/dist/plugins/vite-plus/index.d.ts +4 -1
  39. package/dist/plugins/vite-plus/index.js +19 -4
  40. package/dist/plugins/vite-plus/types.d.ts +12 -0
  41. package/dist/plugins/vite-plus/types.js +1 -0
  42. package/dist/plugins/vitepress/index.js +14 -0
  43. package/dist/plugins/vitest/index.js +5 -0
  44. package/dist/plugins/vitest/types.d.ts +2 -1
  45. package/dist/plugins/web-test-runner/index.js +8 -2
  46. package/dist/plugins/wrangler/index.js +4 -0
  47. package/dist/session/index.d.ts +1 -0
  48. package/dist/session/index.js +1 -0
  49. package/dist/types/PluginNames.d.ts +2 -2
  50. package/dist/types/PluginNames.js +2 -0
  51. package/dist/util/create-input-handler.js +3 -1
  52. package/dist/util/remove-export.d.ts +1 -0
  53. package/dist/util/remove-export.js +2 -0
  54. package/dist/version.d.ts +1 -1
  55. package/dist/version.js +1 -1
  56. package/package.json +1 -1
  57. package/schema.json +8 -0
  58. package/dist/plugins/vite-plus/resolveFromAST.d.ts +0 -2
  59. package/dist/plugins/vite-plus/resolveFromAST.js +0 -37
@@ -5,10 +5,17 @@ import { get } from '../../util/object.js';
5
5
  import { dirname, isInternal, join, relative, toAbsolute } from '../../util/path.js';
6
6
  import { hasDependency } from '../../util/plugin.js';
7
7
  import { substringBefore } from '../../util/string.js';
8
+ import { getBuilderEntries } from '../angular/helpers.js';
8
9
  const title = 'Nx';
9
10
  const enablers = ['nx', /^@nrwl\//, /^@nx\//];
10
11
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
11
12
  const config = ['nx.json', 'project.json', '{apps,libs}/**/project.json', 'package.json'];
13
+ const angularBuilderPackages = new Set([
14
+ '@angular-devkit/build-angular',
15
+ '@angular/build',
16
+ '@nrwl/angular',
17
+ '@nx/angular',
18
+ ]);
12
19
  const findNxDependenciesInNxJson = async (localConfig) => {
13
20
  const targetsDefault = localConfig.targetDefaults
14
21
  ? Object.keys(localConfig.targetDefaults)
@@ -88,7 +95,13 @@ const resolveConfig = async (localConfig, options) => {
88
95
  }
89
96
  return configs;
90
97
  });
91
- return compact([...executors, ...inputs, ...configInputs]).map(id => typeof id === 'string' ? toDependency(id) : id);
98
+ const angularBuilderInputs = [];
99
+ for (const [targetName, target] of Object.entries(config.targets ?? {})) {
100
+ if (target.executor && angularBuilderPackages.has(substringBefore(target.executor, ':'))) {
101
+ angularBuilderInputs.push(...getBuilderEntries(targetName, target, options.rootCwd, expand));
102
+ }
103
+ }
104
+ return compact([...executors, ...inputs, ...configInputs, ...angularBuilderInputs]).map(id => typeof id === 'string' ? toDependency(id) : id);
92
105
  };
93
106
  const collections = [
94
107
  ['generators', 'schematics'],
@@ -3,10 +3,14 @@ const title = 'Plop';
3
3
  const enablers = ['plop'];
4
4
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
5
5
  const entry = ['plopfile.{cjs,mjs,js,ts}'];
6
+ const args = {
7
+ config: ['plopfile'],
8
+ };
6
9
  const plugin = {
7
10
  title,
8
11
  enablers,
9
12
  isEnabled,
10
13
  entry,
14
+ args,
11
15
  };
12
16
  export default plugin;
@@ -26,6 +26,8 @@ const resolveConfig = async (config, options) => {
26
26
  else if (config.migrations?.seed) {
27
27
  inputs.push(...options.getInputsFromScripts(config.migrations.seed));
28
28
  }
29
+ for (const input of inputs)
30
+ input.dir ??= options.cwd;
29
31
  if (config.schema) {
30
32
  inputs.push(resolveSchema(config.schema, options.configFileDir));
31
33
  }
@@ -7,7 +7,7 @@ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
7
7
  const config = ['rollup.config.{js,cjs,mjs,ts}'];
8
8
  const args = {
9
9
  alias: { plugin: ['p'] },
10
- config: ['config'],
10
+ config: true,
11
11
  args: (args) => args.map(arg => (arg.startsWith('--watch.onEnd') ? `--_exec${arg.slice(13)}` : arg)),
12
12
  fromArgs: ['_exec'],
13
13
  resolve: ['plugin', 'configPlugin'],
@@ -6,42 +6,51 @@ import { dirname } from '../../util/path.js';
6
6
  import { _resolveSync } from '../../util/resolve.js';
7
7
  export const resolveFromAST = (program, options) => {
8
8
  const entries = new Set();
9
+ const addHandler = (specifier) => entries.add(specifier.substring(0, specifier.lastIndexOf('.')));
9
10
  const addHandlers = (values) => {
10
11
  for (const specifier of values)
11
- entries.add(specifier.substring(0, specifier.lastIndexOf('.')));
12
+ addHandler(specifier);
13
+ };
14
+ const parseImport = (specifier) => {
15
+ const filePath = _resolveSync(specifier, dirname(options.configFilePath));
16
+ const text = filePath ? options.readFile(filePath) : undefined;
17
+ return filePath && text ? _parseFile(filePath, text).program : undefined;
12
18
  };
13
19
  try {
14
20
  const importMap = getImportMap(program);
21
+ const dynamicImports = [];
15
22
  addHandlers(collectPropertyValues(program, 'handler'));
16
23
  const visitor = new Visitor({
24
+ ImportExpression(node) {
25
+ const source = node.source;
26
+ if (source.type === 'Literal' && typeof source.value === 'string' && source.value.startsWith('.'))
27
+ dynamicImports.push(source.value);
28
+ },
17
29
  CallExpression(node) {
18
30
  if (node.callee?.type !== 'MemberExpression')
19
31
  return;
20
32
  const propName = !node.callee.computed ? node.callee.property?.name : undefined;
21
33
  if (propName === 'stack') {
22
34
  const arg = node.arguments?.[0];
23
- if (arg?.type === 'Identifier') {
24
- const importPath = importMap.get(arg.name);
25
- if (importPath) {
26
- const resolvedPath = _resolveSync(importPath, dirname(options.configFilePath));
27
- if (resolvedPath) {
28
- const stackText = options.readFile(resolvedPath);
29
- if (stackText) {
30
- const stackResult = _parseFile('stack.ts', stackText);
31
- addHandlers(collectPropertyValues(stackResult.program, 'handler'));
32
- }
33
- }
34
- }
35
- }
35
+ const importPath = arg?.type === 'Identifier' ? importMap.get(arg.name) : undefined;
36
+ const stack = importPath ? parseImport(importPath) : undefined;
37
+ if (stack)
38
+ addHandlers(collectPropertyValues(stack, 'handler'));
36
39
  }
37
40
  if (propName === 'route' && node.arguments?.length >= 2) {
38
41
  const handlerArg = node.arguments[1];
39
42
  if (handlerArg?.type === 'Literal' && typeof handlerArg.value === 'string')
40
- entries.add(handlerArg.value);
43
+ addHandler(handlerArg.value);
41
44
  }
42
45
  },
43
46
  });
44
47
  visitor.visit(program);
48
+ for (const infra of dynamicImports.map(parseImport)) {
49
+ if (!infra)
50
+ continue;
51
+ addHandlers(collectPropertyValues(infra, 'handler'));
52
+ visitor.visit(infra);
53
+ }
45
54
  }
46
55
  catch { }
47
56
  return Array.from(entries).map(specifier => toEntryPath(specifier, { production: true }));
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from '../../types/config.ts';
2
+ declare const plugin: Plugin;
3
+ export default plugin;
@@ -0,0 +1,10 @@
1
+ const title = 'start-server-and-test';
2
+ const args = {
3
+ binaries: ['server-test', 'start-server-and-test', 'start-test'],
4
+ fromArgs: parsed => [...parsed._, ...(parsed['--'] ?? [])].filter(arg => typeof arg === 'string' && arg.includes(' ')).join('\n'),
5
+ };
6
+ const plugin = {
7
+ title,
8
+ args,
9
+ };
10
+ export default plugin;
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from '../../types/config.ts';
2
+ declare const plugin: Plugin;
3
+ export default plugin;
@@ -0,0 +1,28 @@
1
+ import { collectPropertyValues } from '../../typescript/ast-helpers.js';
2
+ import { toEntry } from '../../util/input.js';
3
+ import { hasDependency } from '../../util/plugin.js';
4
+ const title = 'Trigger.dev';
5
+ const enablers = ['@trigger.dev/sdk'];
6
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
7
+ const config = ['trigger.config.{js,cjs,mjs,ts,cts,mts}'];
8
+ const extensions = '{ts,tsx,mts,cts,js,jsx,mjs,cjs}';
9
+ const defaultDir = '**/trigger';
10
+ const getProductionPatterns = (dirs) => [
11
+ ...Array.from(dirs, dir => `${dir}/**/*.${extensions}`),
12
+ '!**/*.{test,spec}.{ts,mts,cts,js,mjs,cjs}',
13
+ ];
14
+ const production = getProductionPatterns([defaultDir]);
15
+ const resolveFromAST = (program, { configFileDir }) => {
16
+ const dirs = collectPropertyValues(program, 'dirs');
17
+ const patterns = dirs.size > 0 ? getProductionPatterns(dirs) : production;
18
+ return patterns.map(pattern => toEntry(pattern, { dir: configFileDir, production: true }));
19
+ };
20
+ const plugin = {
21
+ title,
22
+ enablers,
23
+ isEnabled,
24
+ config,
25
+ production,
26
+ resolveFromAST,
27
+ };
28
+ export default plugin;
@@ -23,7 +23,7 @@ const resolveConfig = localConfig => {
23
23
  const args = {
24
24
  ...nodeArgs,
25
25
  string: [...nodeArgs.string, 'exclude', 'ignore', 'include', 'tsconfig'],
26
- args: (args) => nodeArgs.args(args[0] === 'watch' ? args.slice(1) : args),
26
+ args: (args) => (args[0] === 'watch' ? args.slice(1) : args),
27
27
  };
28
28
  const plugin = {
29
29
  title,
@@ -14,10 +14,11 @@ const config = [
14
14
  'package.json',
15
15
  'tsconfig.json',
16
16
  ];
17
+ const getThemes = (theme) => arrayify(theme).filter(name => name !== 'default');
17
18
  const resolveConfig = (config, options) => {
18
19
  const cfg = 'typedocOptions' in config ? config.typedocOptions : config;
19
20
  const plugins = arrayify(cfg?.plugin);
20
- const themes = arrayify(cfg?.theme);
21
+ const themes = getThemes(cfg?.theme);
21
22
  const inputs = [...plugins, ...themes].map(id => toModule(id));
22
23
  for (const file of [cfg?.customCss, cfg?.customJs]) {
23
24
  if (file)
@@ -27,7 +28,9 @@ const resolveConfig = (config, options) => {
27
28
  };
28
29
  const args = {
29
30
  config: ['options'],
30
- resolve: ['plugin', 'theme'],
31
+ resolve: ['plugin'],
32
+ string: ['theme'],
33
+ resolveInputs: (parsed) => getThemes(parsed.theme).map(id => toModule(id)),
31
34
  };
32
35
  const plugin = {
33
36
  title,
@@ -1,14 +1,25 @@
1
1
  import type { Plugin, ResolveConfig } from '../../types/config.ts';
2
2
  import type { TsConfigJson } from '../../types/tsconfig-json.ts';
3
+ import type { ParsedArgs } from '../../util/parse-args.ts';
3
4
  export declare const config: string[];
4
5
  export declare const resolveConfig: ResolveConfig<TsConfigJson>;
6
+ declare const toConfigPath: (p: string) => string;
5
7
  export declare const args: {
6
8
  binaries: string[];
7
9
  string: string[];
10
+ boolean: string[];
8
11
  alias: {
9
12
  project: string[];
13
+ build: string[];
14
+ verbose: string[];
15
+ dry: string[];
16
+ force: string[];
17
+ watch: string[];
10
18
  };
11
- config: [string, (p: string) => string][];
19
+ config: [string, typeof toConfigPath][];
20
+ resolveInputs: (parsed: ParsedArgs, { cwd }: {
21
+ cwd: string;
22
+ }) => import("../../util/input.ts").ConfigInput[];
12
23
  };
13
24
  export declare const docs: {
14
25
  note: string;
@@ -27,7 +27,7 @@ export const resolveConfig = (localConfig, options) => {
27
27
  if (!(compilerOptions && localConfig))
28
28
  return compact([...contentMappers, ...extend, ...references]);
29
29
  const jsx = (compilerOptions?.jsxImportSource ? [compilerOptions.jsxImportSource] : []).map(id => toDependency(id, { production: true, dir: options.cwd, alsoReferenceOwner: true }));
30
- const types = compilerOptions.types ?? [];
30
+ const types = compilerOptions.types?.filter(id => id !== '*') ?? [];
31
31
  const plugins = Array.isArray(compilerOptions?.plugins)
32
32
  ? compilerOptions.plugins.map(plugin => (typeof plugin === 'object' && 'name' in plugin ? plugin.name : ''))
33
33
  : [];
@@ -42,11 +42,14 @@ export const resolveConfig = (localConfig, options) => {
42
42
  ...jsx,
43
43
  ]);
44
44
  };
45
+ const toConfigPath = (p) => (p.endsWith('.json') ? p : join(p, 'tsconfig.json'));
45
46
  export const args = {
46
47
  binaries: ['tsc', 'tsgo'],
47
48
  string: ['project'],
48
- alias: { project: ['p'] },
49
- config: [['project', (p) => (p.endsWith('.json') ? p : join(p, 'tsconfig.json'))]],
49
+ boolean: ['build', 'clean', 'dry', 'force', 'stopBuildOnErrors'],
50
+ alias: { project: ['p'], build: ['b'], verbose: ['v'], dry: ['d'], force: ['f'], watch: ['w'] },
51
+ config: [['project', toConfigPath]],
52
+ resolveInputs: (parsed, { cwd }) => parsed.build ? parsed._.map(String).map(p => toConfig('typescript', toConfigPath(p), { dir: cwd })) : [],
50
53
  };
51
54
  const note = `[What's up with that configurable tsconfig.json location?](/reference/faq#whats-up-with-that-configurable-tsconfigjson-location)`;
52
55
  export const docs = { note };
@@ -1,3 +1,6 @@
1
- import type { Plugin } from '../../types/config.ts';
1
+ import type { Plugin, PluginOptions } from '../../types/config.ts';
2
+ import type { Input } from '../../util/input.ts';
3
+ import type { VitePlusConfig } from './types.ts';
4
+ export declare const getTaskInputs: (configs: VitePlusConfig[], options: PluginOptions) => Input[];
2
5
  declare const plugin: Plugin;
3
6
  export default plugin;
@@ -1,14 +1,29 @@
1
1
  import { hasDependency } from '../../util/plugin.js';
2
- import { resolveFromAST } from './resolveFromAST.js';
3
2
  const title = 'vite-plus';
4
3
  const enablers = ['vite-plus'];
5
4
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
6
- const config = ['vite.config.{js,mjs,ts,cjs,mts,cts}'];
5
+ const entry = ['vite.config.{js,mjs,ts,cjs,mts,cts}'];
6
+ export const getTaskInputs = (configs, options) => {
7
+ const commands = new Set();
8
+ const addCommands = (value) => {
9
+ for (const command of [value].flat())
10
+ if (typeof command === 'string')
11
+ commands.add(command);
12
+ };
13
+ for (const { run, staged } of configs) {
14
+ for (const task of Object.values(run?.tasks ?? {})) {
15
+ addCommands(typeof task === 'string' || Array.isArray(task) ? task : task.command);
16
+ }
17
+ if (typeof staged === 'object')
18
+ for (const command of Object.values(staged))
19
+ addCommands(command);
20
+ }
21
+ return options.getInputsFromScripts(commands, { optionalBinaries: true });
22
+ };
7
23
  const plugin = {
8
24
  title,
9
25
  enablers,
10
26
  isEnabled,
11
- config,
12
- resolveFromAST,
27
+ entry,
13
28
  };
14
29
  export default plugin;
@@ -0,0 +1,12 @@
1
+ import type { LintStagedConfig } from '../lint-staged/types.ts';
2
+ type Command = string | string[];
3
+ type Task = {
4
+ command: Command;
5
+ };
6
+ export type VitePlusConfig = {
7
+ run?: {
8
+ tasks?: Record<string, Task | Command>;
9
+ };
10
+ staged?: LintStagedConfig;
11
+ };
12
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,3 +1,5 @@
1
+ import { toEntry } from '../../util/input.js';
2
+ import { join } from '../../util/path.js';
1
3
  import { hasDependency } from '../../util/plugin.js';
2
4
  const title = 'VitePress';
3
5
  const enablers = ['vitepress'];
@@ -7,10 +9,22 @@ const entry = [
7
9
  '.vitepress/config/index.{js,ts,mjs,mts,cjs,cts}',
8
10
  '.vitepress/theme/index.{js,ts,mjs,mts}',
9
11
  ];
12
+ const commands = new Set(['dev', 'build', 'preview', 'serve']);
13
+ const args = {
14
+ resolveInputs: parsed => {
15
+ const [command, root] = parsed._;
16
+ const inputs = [];
17
+ if (root && commands.has(command))
18
+ for (const pattern of entry)
19
+ inputs.push(toEntry(join(root, pattern)));
20
+ return inputs;
21
+ },
22
+ };
10
23
  const plugin = {
11
24
  title,
12
25
  enablers,
13
26
  isEnabled,
14
27
  entry,
28
+ args,
15
29
  };
16
30
  export default plugin;
@@ -7,6 +7,7 @@ import { getPackageNameFromModuleSpecifier } from '../../util/modules.js';
7
7
  import { basename, isAbsolute, isInternal, join, toAbsolute, toPosix } from '../../util/path.js';
8
8
  import { hasDependency } from '../../util/plugin.js';
9
9
  import { resolveExtendedConfig } from '../oxlint/index.js';
10
+ import { getTaskInputs } from '../vite-plus/index.js';
10
11
  import { getHtmlScriptEntries, getIndexHtmlEntries } from '../vite/helpers.js';
11
12
  import { getAliasInputs, getExternalReporters, toEnvDependency } from './helpers.js';
12
13
  import { createVitestMockVisitor } from './visitors/mock.js';
@@ -112,6 +113,10 @@ export const resolveConfig = async (localConfig, options) => {
112
113
  const lintInputs = [];
113
114
  inputs.add(toEntry(join(options.cwd, 'src/vite-env.d.ts')));
114
115
  const configs = await getConfigs(localConfig);
116
+ if (options.enabledPlugins.includes('vite-plus')) {
117
+ for (const input of getTaskInputs(configs, options))
118
+ inputs.add(input);
119
+ }
115
120
  const patterns = new Set();
116
121
  for (const cfg of configs) {
117
122
  for (const project of cfg.test?.projects ?? []) {
@@ -1,4 +1,5 @@
1
1
  import type { OxlintConfig } from '../oxlint/types.ts';
2
+ import type { VitePlusConfig } from '../vite-plus/types.ts';
2
3
  interface Alias {
3
4
  find: string | RegExp;
4
5
  replacement: string;
@@ -34,7 +35,7 @@ interface VitestConfig {
34
35
  alias?: AliasOptions;
35
36
  };
36
37
  }
37
- export interface ViteConfig extends VitestConfig {
38
+ export interface ViteConfig extends VitestConfig, VitePlusConfig {
38
39
  lint?: OxlintConfig;
39
40
  extends?: string | true;
40
41
  root?: string;
@@ -1,5 +1,5 @@
1
1
  import { findProperty, getPropertyValues, resolveObjectArg } from '../../typescript/ast-helpers.js';
2
- import { toEntry } from '../../util/input.js';
2
+ import { toDependency, toEntry } from '../../util/input.js';
3
3
  import { toAbsolute } from '../../util/path.js';
4
4
  import { hasDependency } from '../../util/plugin.js';
5
5
  const title = 'Web Test Runner';
@@ -73,7 +73,13 @@ const args = {
73
73
  'update-snapshots',
74
74
  'watch',
75
75
  ],
76
- resolveInputs: (parsed, { cwd }) => toFileEntries([...parsed._, ...(parsed['--'] ?? []), ...[parsed.files ?? []].flat()].map(String), cwd),
76
+ resolveInputs: (parsed, { cwd }) => {
77
+ const inputs = toFileEntries([...parsed._, ...(parsed['--'] ?? []), ...[parsed.files ?? []].flat()].map(String), cwd);
78
+ const launcher = parsed.puppeteer ? 'puppeteer' : parsed.playwright ? 'playwright' : undefined;
79
+ if (launcher)
80
+ inputs.push(toDependency(`@web/test-runner-${launcher}`));
81
+ return inputs;
82
+ },
77
83
  };
78
84
  const plugin = {
79
85
  title,
@@ -7,11 +7,15 @@ const config = ['wrangler.{json,jsonc,toml}'];
7
7
  const resolveConfig = async (config) => {
8
8
  return (config.main ? [config.main] : []).map(id => toEntryPath(id, { production: true }));
9
9
  };
10
+ const args = {
11
+ config: true,
12
+ };
10
13
  const plugin = {
11
14
  title,
12
15
  enablers,
13
16
  isEnabled,
14
17
  config,
15
18
  resolveConfig,
19
+ args,
16
20
  };
17
21
  export default plugin;
@@ -6,6 +6,7 @@ export type { Results } from '../run.ts';
6
6
  export type { Issue, Issues, IssueType, Rules } from '../types/issues.ts';
7
7
  export type { PackageJson } from '../types/package-json.ts';
8
8
  export { createOptions, type MainOptions } from '../util/create-options.ts';
9
+ export { keepModuleMarker, removeExport } from '../util/remove-export.ts';
9
10
  export { buildFileDescriptor, type FileDescriptorOptions } from './file-descriptor.ts';
10
11
  export { buildPackageJsonDescriptor, type PackageJsonFile } from './package-json-descriptor.ts';
11
12
  export { createSession, type Session } from './session.ts';
@@ -2,6 +2,7 @@ export { IMPORT_STAR, ISSUE_TYPES, KNIP_CONFIG_LOCATIONS, SIDE_EFFECTS } from '.
2
2
  export { finalizeConfigurationHints } from '../reporters/util/configuration-hints.js';
3
3
  export { getIssuePrefix } from '../reporters/util/util.js';
4
4
  export { createOptions } from '../util/create-options.js';
5
+ export { keepModuleMarker, removeExport } from '../util/remove-export.js';
5
6
  export { buildFileDescriptor } from './file-descriptor.js';
6
7
  export { buildPackageJsonDescriptor } from './package-json-descriptor.js';
7
8
  export { createSession } from './session.js';
@@ -1,2 +1,2 @@
1
- export type PluginName = 'angular' | 'astro' | 'astro-db' | 'astro-markdoc' | 'astro-og-canvas' | 'ava' | 'aws-cdk' | 'babel' | 'biome' | 'borp' | 'buf' | 'bumpp' | 'bun' | 'c8' | 'capacitor' | 'catalyst' | 'changelogen' | 'changelogithub' | 'changesets' | 'commitizen' | 'commitlint' | 'convex' | 'create-typescript-app' | 'cspell' | 'cucumber' | 'cypress' | 'danger' | 'dependency-cruiser' | 'docusaurus' | 'dotenv' | 'drizzle' | 'electron-builder' | 'electron-forge' | 'electron-vite' | 'eleventy' | 'ember' | 'ember-template-lint' | 'env-cmd' | 'esbuild' | 'eslint' | 'evalite' | 'eve' | 'execa' | 'expo' | 'expo-router' | 'expressive-code' | 'fast' | 'filesystem-routing' | 'flue' | 'fumadocs' | 'gatsby' | 'github-action' | 'github-actions' | 'glob' | 'graphql-codegen' | 'hardhat' | 'husky' | 'i18next-parser' | 'jasmine' | 'jest' | 'karma' | 'knex' | 'kysely-codegen' | 'ladle' | 'laravel-vite-plugin' | 'lefthook' | 'lingui' | 'lint-staged' | 'linthtml' | 'lit' | 'lockfile-lint' | 'lost-pixel' | 'lunaria' | 'maestro' | 'markdownlint' | 'marko' | 'mastra' | 'mcp' | 'mdx' | 'mdxlint' | 'metro' | 'mikro-orm' | 'mise' | 'mocha' | 'moonrepo' | 'msw' | 'nano-spawn' | 'nano-staged' | 'nest' | 'netlify' | 'next' | 'next-intl' | 'next-mdx' | 'nitro' | 'node' | 'node-modules-inspector' | 'nodemon' | 'npm-package-json-lint' | 'nuxt' | 'nuxtjs-i18n' | 'nx' | 'nyc' | 'oclif' | 'openapi-ts' | 'openclaw' | 'orval' | 'osls' | 'oxfmt' | 'oxlint' | 'panda-css' | 'parcel' | 'payload' | 'pino' | 'playwright' | 'playwright-ct' | 'playwright-test' | 'plop' | 'pm2' | 'pnpm' | 'postcss' | 'pre-commit' | 'preconstruct' | 'prettier' | 'prisma' | 'purgecss' | 'quasar' | 'qwik' | 'railway' | 'raycast' | 'react-cosmos' | 'react-email' | 'react-native' | 'react-router' | 'relay' | 'release-it' | 'remark' | 'remix' | 'retry-cli' | 'rolldown' | 'rollup' | 'rsbuild' | 'rslib' | 'rslint' | 'rspack' | 'rstest' | 'sanity' | 'semantic-release' | 'sentry' | 'serverless-framework' | 'simple-git-hooks' | 'size-limit' | 'solidjs-vite-plugin' | 'sst' | 'starlight' | 'stencil' | 'storybook' | 'stryker' | 'stylelint' | 'svelte' | 'sveltejs-package' | 'sveltekit' | 'svgo' | 'svgr' | 'swc' | 'syncpack' | 'tailwind' | 'tanstack-router' | 'taskfile' | 'tauri' | 'temporal' | 'textlint' | 'travis' | 'ts-node' | 'tsd' | 'tsdown' | 'tsrs' | 'tsup' | 'tsx' | 'turbo' | 'typedoc' | 'typescript' | 'typescript-content-mapper' | 'unbuild' | 'unocss' | 'unplugin-auto-import' | 'unplugin-icons' | 'unplugin-vue-components' | 'unplugin-vue-i18n' | 'unplugin-vue-markdown' | 'unplugin-vue-router' | 'varlock' | 'vercel' | 'vercel-og' | 'vike' | 'vite' | 'vite-plugin-pages' | 'vite-plugin-pwa' | 'vite-plugin-vue-layouts-next' | 'vite-plus' | 'vite-pwa-assets-generator' | 'vitepress' | 'vitest' | 'vue' | 'web-test-runner' | 'webdriver-io' | 'webpack' | 'wireit' | 'wrangler' | 'wxt' | 'xo' | 'yarn' | 'yorkie' | 'zx';
2
- export declare const pluginNames: readonly ['angular', 'astro', 'astro-db', 'astro-markdoc', 'astro-og-canvas', 'ava', 'aws-cdk', 'babel', 'biome', 'borp', 'buf', 'bumpp', 'bun', 'c8', 'capacitor', 'catalyst', 'changelogen', 'changelogithub', 'changesets', 'commitizen', 'commitlint', 'convex', 'create-typescript-app', 'cspell', 'cucumber', 'cypress', 'danger', 'dependency-cruiser', 'docusaurus', 'dotenv', 'drizzle', 'electron-builder', 'electron-forge', 'electron-vite', 'eleventy', 'ember', 'ember-template-lint', 'env-cmd', 'esbuild', 'eslint', 'evalite', 'eve', 'execa', 'expo', 'expo-router', 'expressive-code', 'fast', 'filesystem-routing', 'flue', 'fumadocs', 'gatsby', 'github-action', 'github-actions', 'glob', 'graphql-codegen', 'hardhat', 'husky', 'i18next-parser', 'jasmine', 'jest', 'karma', 'knex', 'kysely-codegen', 'ladle', 'laravel-vite-plugin', 'lefthook', 'lingui', 'lint-staged', 'linthtml', 'lit', 'lockfile-lint', 'lost-pixel', 'lunaria', 'maestro', 'markdownlint', 'marko', 'mastra', 'mcp', 'mdx', 'mdxlint', 'metro', 'mikro-orm', 'mise', 'mocha', 'moonrepo', 'msw', 'nano-spawn', 'nano-staged', 'nest', 'netlify', 'next', 'next-intl', 'next-mdx', 'nitro', 'node', 'node-modules-inspector', 'nodemon', 'npm-package-json-lint', 'nuxt', 'nuxtjs-i18n', 'nx', 'nyc', 'oclif', 'openapi-ts', 'openclaw', 'orval', 'osls', 'oxfmt', 'oxlint', 'panda-css', 'parcel', 'payload', 'pino', 'playwright', 'playwright-ct', 'playwright-test', 'plop', 'pm2', 'pnpm', 'postcss', 'pre-commit', 'preconstruct', 'prettier', 'prisma', 'purgecss', 'quasar', 'qwik', 'railway', 'raycast', 'react-cosmos', 'react-email', 'react-native', 'react-router', 'relay', 'release-it', 'remark', 'remix', 'retry-cli', 'rolldown', 'rollup', 'rsbuild', 'rslib', 'rslint', 'rspack', 'rstest', 'sanity', 'semantic-release', 'sentry', 'serverless-framework', 'simple-git-hooks', 'size-limit', 'solidjs-vite-plugin', 'sst', 'starlight', 'stencil', 'storybook', 'stryker', 'stylelint', 'svelte', 'sveltejs-package', 'sveltekit', 'svgo', 'svgr', 'swc', 'syncpack', 'tailwind', 'tanstack-router', 'taskfile', 'tauri', 'temporal', 'textlint', 'travis', 'ts-node', 'tsd', 'tsdown', 'tsrs', 'tsup', 'tsx', 'turbo', 'typedoc', 'typescript', 'typescript-content-mapper', 'unbuild', 'unocss', 'unplugin-auto-import', 'unplugin-icons', 'unplugin-vue-components', 'unplugin-vue-i18n', 'unplugin-vue-markdown', 'unplugin-vue-router', 'varlock', 'vercel', 'vercel-og', 'vike', 'vite', 'vite-plugin-pages', 'vite-plugin-pwa', 'vite-plugin-vue-layouts-next', 'vite-plus', 'vite-pwa-assets-generator', 'vitepress', 'vitest', 'vue', 'web-test-runner', 'webdriver-io', 'webpack', 'wireit', 'wrangler', 'wxt', 'xo', 'yarn', 'yorkie', 'zx'];
1
+ export type PluginName = 'angular' | 'astro' | 'astro-db' | 'astro-markdoc' | 'astro-og-canvas' | 'ava' | 'aws-cdk' | 'babel' | 'biome' | 'borp' | 'buf' | 'bumpp' | 'bun' | 'c8' | 'capacitor' | 'catalyst' | 'changelogen' | 'changelogithub' | 'changesets' | 'commitizen' | 'commitlint' | 'convex' | 'create-typescript-app' | 'cspell' | 'cucumber' | 'cypress' | 'danger' | 'dependency-cruiser' | 'docusaurus' | 'dotenv' | 'drizzle' | 'electron-builder' | 'electron-forge' | 'electron-vite' | 'eleventy' | 'ember' | 'ember-template-lint' | 'env-cmd' | 'esbuild' | 'eslint' | 'evalite' | 'eve' | 'execa' | 'expo' | 'expo-router' | 'expressive-code' | 'fast' | 'filesystem-routing' | 'flue' | 'fumadocs' | 'gatsby' | 'github-action' | 'github-actions' | 'glob' | 'graphql-codegen' | 'hardhat' | 'husky' | 'i18next-parser' | 'jasmine' | 'jest' | 'karma' | 'knex' | 'kysely-codegen' | 'ladle' | 'laravel-vite-plugin' | 'lefthook' | 'lingui' | 'lint-staged' | 'linthtml' | 'lit' | 'lockfile-lint' | 'lost-pixel' | 'lunaria' | 'maestro' | 'markdownlint' | 'marko' | 'mastra' | 'mcp' | 'mdx' | 'mdxlint' | 'metro' | 'mikro-orm' | 'mise' | 'mocha' | 'moonrepo' | 'msw' | 'nano-spawn' | 'nano-staged' | 'nest' | 'netlify' | 'next' | 'next-intl' | 'next-mdx' | 'nitro' | 'node' | 'node-modules-inspector' | 'nodemon' | 'npm-package-json-lint' | 'nuxt' | 'nuxtjs-i18n' | 'nx' | 'nyc' | 'oclif' | 'openapi-ts' | 'openclaw' | 'orval' | 'osls' | 'oxfmt' | 'oxlint' | 'panda-css' | 'parcel' | 'payload' | 'pino' | 'playwright' | 'playwright-ct' | 'playwright-test' | 'plop' | 'pm2' | 'pnpm' | 'postcss' | 'pre-commit' | 'preconstruct' | 'prettier' | 'prisma' | 'purgecss' | 'quasar' | 'qwik' | 'railway' | 'raycast' | 'react-cosmos' | 'react-email' | 'react-native' | 'react-router' | 'relay' | 'release-it' | 'remark' | 'remix' | 'retry-cli' | 'rolldown' | 'rollup' | 'rsbuild' | 'rslib' | 'rslint' | 'rspack' | 'rstest' | 'sanity' | 'semantic-release' | 'sentry' | 'serverless-framework' | 'simple-git-hooks' | 'size-limit' | 'solidjs-vite-plugin' | 'sst' | 'starlight' | 'start-server-and-test' | 'stencil' | 'storybook' | 'stryker' | 'stylelint' | 'svelte' | 'sveltejs-package' | 'sveltekit' | 'svgo' | 'svgr' | 'swc' | 'syncpack' | 'tailwind' | 'tanstack-router' | 'taskfile' | 'tauri' | 'temporal' | 'textlint' | 'travis' | 'trigger-dev' | 'ts-node' | 'tsd' | 'tsdown' | 'tsrs' | 'tsup' | 'tsx' | 'turbo' | 'typedoc' | 'typescript' | 'typescript-content-mapper' | 'unbuild' | 'unocss' | 'unplugin-auto-import' | 'unplugin-icons' | 'unplugin-vue-components' | 'unplugin-vue-i18n' | 'unplugin-vue-markdown' | 'unplugin-vue-router' | 'varlock' | 'vercel' | 'vercel-og' | 'vike' | 'vite' | 'vite-plugin-pages' | 'vite-plugin-pwa' | 'vite-plugin-vue-layouts-next' | 'vite-plus' | 'vite-pwa-assets-generator' | 'vitepress' | 'vitest' | 'vue' | 'web-test-runner' | 'webdriver-io' | 'webpack' | 'wireit' | 'wrangler' | 'wxt' | 'xo' | 'yarn' | 'yorkie' | 'zx';
2
+ export declare const pluginNames: readonly ['angular', 'astro', 'astro-db', 'astro-markdoc', 'astro-og-canvas', 'ava', 'aws-cdk', 'babel', 'biome', 'borp', 'buf', 'bumpp', 'bun', 'c8', 'capacitor', 'catalyst', 'changelogen', 'changelogithub', 'changesets', 'commitizen', 'commitlint', 'convex', 'create-typescript-app', 'cspell', 'cucumber', 'cypress', 'danger', 'dependency-cruiser', 'docusaurus', 'dotenv', 'drizzle', 'electron-builder', 'electron-forge', 'electron-vite', 'eleventy', 'ember', 'ember-template-lint', 'env-cmd', 'esbuild', 'eslint', 'evalite', 'eve', 'execa', 'expo', 'expo-router', 'expressive-code', 'fast', 'filesystem-routing', 'flue', 'fumadocs', 'gatsby', 'github-action', 'github-actions', 'glob', 'graphql-codegen', 'hardhat', 'husky', 'i18next-parser', 'jasmine', 'jest', 'karma', 'knex', 'kysely-codegen', 'ladle', 'laravel-vite-plugin', 'lefthook', 'lingui', 'lint-staged', 'linthtml', 'lit', 'lockfile-lint', 'lost-pixel', 'lunaria', 'maestro', 'markdownlint', 'marko', 'mastra', 'mcp', 'mdx', 'mdxlint', 'metro', 'mikro-orm', 'mise', 'mocha', 'moonrepo', 'msw', 'nano-spawn', 'nano-staged', 'nest', 'netlify', 'next', 'next-intl', 'next-mdx', 'nitro', 'node', 'node-modules-inspector', 'nodemon', 'npm-package-json-lint', 'nuxt', 'nuxtjs-i18n', 'nx', 'nyc', 'oclif', 'openapi-ts', 'openclaw', 'orval', 'osls', 'oxfmt', 'oxlint', 'panda-css', 'parcel', 'payload', 'pino', 'playwright', 'playwright-ct', 'playwright-test', 'plop', 'pm2', 'pnpm', 'postcss', 'pre-commit', 'preconstruct', 'prettier', 'prisma', 'purgecss', 'quasar', 'qwik', 'railway', 'raycast', 'react-cosmos', 'react-email', 'react-native', 'react-router', 'relay', 'release-it', 'remark', 'remix', 'retry-cli', 'rolldown', 'rollup', 'rsbuild', 'rslib', 'rslint', 'rspack', 'rstest', 'sanity', 'semantic-release', 'sentry', 'serverless-framework', 'simple-git-hooks', 'size-limit', 'solidjs-vite-plugin', 'sst', 'starlight', 'start-server-and-test', 'stencil', 'storybook', 'stryker', 'stylelint', 'svelte', 'sveltejs-package', 'sveltekit', 'svgo', 'svgr', 'swc', 'syncpack', 'tailwind', 'tanstack-router', 'taskfile', 'tauri', 'temporal', 'textlint', 'travis', 'trigger-dev', 'ts-node', 'tsd', 'tsdown', 'tsrs', 'tsup', 'tsx', 'turbo', 'typedoc', 'typescript', 'typescript-content-mapper', 'unbuild', 'unocss', 'unplugin-auto-import', 'unplugin-icons', 'unplugin-vue-components', 'unplugin-vue-i18n', 'unplugin-vue-markdown', 'unplugin-vue-router', 'varlock', 'vercel', 'vercel-og', 'vike', 'vite', 'vite-plugin-pages', 'vite-plugin-pwa', 'vite-plugin-vue-layouts-next', 'vite-plus', 'vite-pwa-assets-generator', 'vitepress', 'vitest', 'vue', 'web-test-runner', 'webdriver-io', 'webpack', 'wireit', 'wrangler', 'wxt', 'xo', 'yarn', 'yorkie', 'zx'];
@@ -153,6 +153,7 @@ export const pluginNames = [
153
153
  'solidjs-vite-plugin',
154
154
  'sst',
155
155
  'starlight',
156
+ 'start-server-and-test',
156
157
  'stencil',
157
158
  'storybook',
158
159
  'stryker',
@@ -171,6 +172,7 @@ export const pluginNames = [
171
172
  'temporal',
172
173
  'textlint',
173
174
  'travis',
175
+ 'trigger-dev',
174
176
  'ts-node',
175
177
  'tsd',
176
178
  'tsdown',
@@ -1,5 +1,6 @@
1
1
  import { IGNORED_GLOBAL_BINARIES } from '../constants.js';
2
2
  import { debugLog } from './debug.js';
3
+ import { isFile } from './fs.js';
3
4
  import { fromBinary, isConfig, isDeferResolveEntry, toDebugString } from './input.js';
4
5
  import { getPackageNameFromFilePath, getPackageNameFromSpecifier } from './modules.js';
5
6
  import { dirname, isAbsolute, isInNodeModules, isInternal, join } from './path.js';
@@ -113,8 +114,9 @@ export const createInputHandler = (deputy, chief, isGitIgnored, addIssue, extern
113
114
  };
114
115
  const handlePackageOrFile = (input, containingFilePath, workspace) => {
115
116
  const packageName = getPackageNameFromSpecifier(input.specifier);
116
- if (!packageName)
117
+ if (!packageName || (isConfig(input) && isFile(input.dir ?? dirname(containingFilePath), input.specifier))) {
117
118
  return handleFile(input, containingFilePath, workspace);
119
+ }
118
120
  const inputWorkspace = getWorkspaceFor(input, containingFilePath, workspace);
119
121
  const isWorkspace = chief.findWorkspaceByPackageName(packageName, containingFilePath) !== undefined;
120
122
  if (!isWorkspace)
@@ -4,5 +4,6 @@ interface FixerOptions {
4
4
  end: number;
5
5
  flags: number;
6
6
  }
7
+ export declare const keepModuleMarker: (source: string, text: string) => string;
7
8
  export declare const removeExport: ({ text, start, end, flags }: FixerOptions) => string;
8
9
  export {};
@@ -1,5 +1,7 @@
1
1
  import { FIX_FLAGS } from '../constants.js';
2
2
  const importAttributesMatcher = /^(?:\s*with|[^\S\r\n\u2028\u2029]*assert)\s*\{[^}]*\}/;
3
+ const MODULE_MARKER = /^[ \t]*(import|export)\b/m;
4
+ export const keepModuleMarker = (source, text) => MODULE_MARKER.test(source) && !MODULE_MARKER.test(text) ? `${text.trimEnd()}\n\nexport {};\n` : text;
3
5
  const getOpeningBracketIndex = (text) => {
4
6
  let bracketOpenIndex = -1;
5
7
  let j = text.length - 1;
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "6.46.1";
1
+ export declare const version = "6.47.0";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '6.46.1';
1
+ export const version = '6.47.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "6.46.1",
3
+ "version": "6.47.0",
4
4
  "description": "Find and fix unused dependencies, exports and files in your TypeScript and JavaScript projects",
5
5
  "keywords": [
6
6
  "analysis",
package/schema.json CHANGED
@@ -1043,6 +1043,10 @@
1043
1043
  "title": "starlight plugin configuration (https://knip.dev/reference/plugins/starlight)",
1044
1044
  "$ref": "#/definitions/plugin"
1045
1045
  },
1046
+ "start-server-and-test": {
1047
+ "title": "start-server-and-test plugin configuration (https://knip.dev/reference/plugins/start-server-and-test)",
1048
+ "$ref": "#/definitions/plugin"
1049
+ },
1046
1050
  "stencil": {
1047
1051
  "title": "stencil plugin configuration (https://knip.dev/reference/plugins/stencil)",
1048
1052
  "$ref": "#/definitions/plugin"
@@ -1115,6 +1119,10 @@
1115
1119
  "title": "travis plugin configuration (https://knip.dev/reference/plugins/travis)",
1116
1120
  "$ref": "#/definitions/plugin"
1117
1121
  },
1122
+ "trigger-dev": {
1123
+ "title": "trigger-dev plugin configuration (https://knip.dev/reference/plugins/trigger-dev)",
1124
+ "$ref": "#/definitions/plugin"
1125
+ },
1118
1126
  "ts-node": {
1119
1127
  "title": "ts-node plugin configuration (https://knip.dev/reference/plugins/ts-node)",
1120
1128
  "$ref": "#/definitions/plugin"
@@ -1,2 +0,0 @@
1
- import type { ResolveFromAST } from '../../types/config.ts';
2
- export declare const resolveFromAST: ResolveFromAST;