knip 6.47.0 → 6.48.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 (54) hide show
  1. package/dist/ConfigurationChief.d.ts +4 -0
  2. package/dist/binaries/create-script-parser-context.js +2 -1
  3. package/dist/binaries/fallback.js +2 -3
  4. package/dist/binaries/plugins.js +1 -5
  5. package/dist/binaries/resolvers/npx.js +6 -8
  6. package/dist/binaries/resolvers/pnpx.js +3 -7
  7. package/dist/binaries/util.d.ts +4 -0
  8. package/dist/binaries/util.js +12 -2
  9. package/dist/plugins/docusaurus/helpers.js +19 -5
  10. package/dist/plugins/ember/index.js +4 -8
  11. package/dist/plugins/env/index.d.ts +3 -0
  12. package/dist/plugins/env/index.js +27 -0
  13. package/dist/plugins/esbuild/index.js +5 -0
  14. package/dist/plugins/firebase/index.d.ts +3 -0
  15. package/dist/plugins/firebase/index.js +12 -0
  16. package/dist/plugins/graphql-codegen/index.js +2 -0
  17. package/dist/plugins/index.d.ts +4 -0
  18. package/dist/plugins/index.js +8 -0
  19. package/dist/plugins/netlify/index.js +12 -2
  20. package/dist/plugins/netlify/types.d.ts +3 -0
  21. package/dist/plugins/nodemon/index.js +19 -0
  22. package/dist/plugins/remark/helpers.js +1 -8
  23. package/dist/plugins/serverless-framework/index.js +14 -5
  24. package/dist/plugins/serverless-framework/types.d.ts +4 -1
  25. package/dist/plugins/sst/index.js +13 -0
  26. package/dist/plugins/sst/resolveFromAST.js +11 -1
  27. package/dist/plugins/storybook/index.js +3 -3
  28. package/dist/plugins/storybook/types.d.ts +5 -3
  29. package/dist/plugins/textlint/helpers.js +1 -5
  30. package/dist/plugins/ts-node/index.d.ts +6 -0
  31. package/dist/plugins/ts-node/index.js +19 -0
  32. package/dist/plugins/ts-node-dev/index.d.ts +3 -0
  33. package/dist/plugins/ts-node-dev/index.js +46 -0
  34. package/dist/plugins/tsup/index.js +2 -0
  35. package/dist/plugins/typescript/index.js +6 -1
  36. package/dist/plugins/vite/helpers.js +1 -4
  37. package/dist/plugins/vite-node/index.d.ts +3 -0
  38. package/dist/plugins/vite-node/index.js +11 -0
  39. package/dist/plugins/webdriver-io/index.js +6 -2
  40. package/dist/types/PluginNames.d.ts +2 -2
  41. package/dist/types/PluginNames.js +4 -0
  42. package/dist/types/tsconfig-json.d.ts +5 -0
  43. package/dist/typescript/ast-helpers.d.ts +3 -1
  44. package/dist/typescript/ast-helpers.js +14 -4
  45. package/dist/typescript/visitors/exports.js +11 -8
  46. package/dist/typescript/visitors/imports.js +10 -8
  47. package/dist/typescript/visitors/members.js +10 -8
  48. package/dist/util/create-input-handler.js +2 -2
  49. package/dist/util/package-json.d.ts +1 -0
  50. package/dist/util/package-json.js +21 -9
  51. package/dist/version.d.ts +1 -1
  52. package/dist/version.js +1 -1
  53. package/package.json +1 -1
  54. package/schema.json +16 -0
@@ -1,5 +1,5 @@
1
1
  import { Visitor } from 'oxc-parser';
2
- import { collectPropertyValues, getImportMap } from '../../typescript/ast-helpers.js';
2
+ import { collectPropertyValues, findProperty, getImportMap } from '../../typescript/ast-helpers.js';
3
3
  import { _parseFile } from '../../typescript/ast-nodes.js';
4
4
  import { toEntryPath } from '../../util/input.js';
5
5
  import { dirname } from '../../util/path.js';
@@ -42,6 +42,16 @@ export const resolveFromAST = (program, options) => {
42
42
  if (handlerArg?.type === 'Literal' && typeof handlerArg.value === 'string')
43
43
  addHandler(handlerArg.value);
44
44
  }
45
+ if (propName === 'subscribe') {
46
+ const [first, second] = node.arguments;
47
+ const subscriber = second?.type === 'Literal'
48
+ ? second
49
+ : !second || (second.type === 'ObjectExpression' && !findProperty(second, 'handler'))
50
+ ? first
51
+ : undefined;
52
+ if (subscriber?.type === 'Literal' && typeof subscriber.value === 'string' && subscriber.value.includes('.'))
53
+ addHandler(subscriber.value);
54
+ }
45
55
  },
46
56
  });
47
57
  visitor.visit(program);
@@ -40,9 +40,9 @@ const resolveConfig = async (localConfig, options) => {
40
40
  const framework = localConfig.framework;
41
41
  const frameworkName = typeof framework === 'string' ? framework : framework?.name;
42
42
  const frameworks = frameworkName ? [frameworkName] : [];
43
- const viteConfigPath = typeof framework === 'object' &&
44
- framework?.name === '@storybook/react-vite' &&
45
- framework?.options?.builder?.viteConfigPath;
43
+ const builderOptions = (typeof framework === 'object' && framework?.options?.builder) ||
44
+ (typeof localConfig?.core?.builder === 'object' && localConfig.core.builder.options);
45
+ const viteConfigPath = builderOptions && builderOptions.viteConfigPath;
46
46
  const configs = viteConfigPath ? [toConfig('vite', viteConfigPath, { dir: cwd })] : [];
47
47
  const hasVitestAddon = addons.some(addon => addon === '@storybook/addon-vitest');
48
48
  const coverageDeps = hasVitestAddon
@@ -1,3 +1,6 @@
1
+ type BuilderOptions = {
2
+ viteConfigPath?: string | null;
3
+ };
1
4
  type Stories = (string | {
2
5
  directory: string;
3
6
  files?: string;
@@ -11,14 +14,13 @@ export type StorybookConfig = {
11
14
  core?: {
12
15
  builder?: string | {
13
16
  name?: string;
17
+ options?: BuilderOptions;
14
18
  };
15
19
  };
16
20
  framework?: string | {
17
21
  name?: string;
18
22
  options?: {
19
- builder?: {
20
- viteConfigPath?: string;
21
- };
23
+ builder?: BuilderOptions;
22
24
  };
23
25
  };
24
26
  };
@@ -14,11 +14,7 @@ const createFullPackageName = (prefix, name) => {
14
14
  return `${prefix}${name}`;
15
15
  };
16
16
  const hasPrefix = (prefix, name) => (name.charAt(0) === '@' ? name.slice(name.indexOf('/') + 1) : name).startsWith(prefix);
17
- const isDeclared = (manifest, name) => Boolean(manifest.dependencies?.[name] ??
18
- manifest.devDependencies?.[name] ??
19
- manifest.optionalDependencies?.[name] ??
20
- manifest.peerDependencies?.[name]);
21
- const toPackageDependency = (prefix, name, candidates, manifest) => toDependency(candidates.find(candidate => isDeclared(manifest, candidate)) ??
17
+ const toPackageDependency = (prefix, name, candidates, manifest) => toDependency(candidates.find(candidate => manifest.allDependencies.has(candidate)) ??
22
18
  (hasPrefix(prefix, name) ? name : createFullPackageName(prefix, name)));
23
19
  const isPresetRuleKey = (key) => key.startsWith('preset-') ||
24
20
  key.startsWith(PRESET_PREFIX) ||
@@ -1,3 +1,9 @@
1
1
  import type { Plugin } from '../../types/config.ts';
2
+ import type { TsConfigJson } from '../../types/tsconfig-json.ts';
3
+ import { type Input } from '../../util/input.ts';
4
+ export declare const resolveTsNodeConfig: (options: NonNullable<TsConfigJson['ts-node']>) => Input[];
5
+ export declare const docs: {
6
+ note: string;
7
+ };
2
8
  declare const plugin: Plugin;
3
9
  export default plugin;
@@ -1,4 +1,19 @@
1
+ import { toModule } from '../../util/input.js';
2
+ import { hasDependency } from '../../util/plugin.js';
1
3
  const title = 'ts-node';
4
+ const enablers = ['ts-node'];
5
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
6
+ export const resolveTsNodeConfig = (options) => {
7
+ const inputs = [];
8
+ for (const id of options.require ?? [])
9
+ inputs.push(toModule(id));
10
+ if (options.compiler)
11
+ inputs.push(toModule(options.compiler));
12
+ const transpiler = Array.isArray(options.transpiler) ? options.transpiler[0] : options.transpiler;
13
+ if (transpiler)
14
+ inputs.push(toModule(transpiler));
15
+ return inputs;
16
+ };
2
17
  const args = {
3
18
  binaries: ['ts-node', 'ts-node-cwd', 'ts-node-esm', 'ts-node-script', 'ts-node-transpile-only'],
4
19
  positional: (parsed) => (parsed.eval === undefined ? parsed._.slice(0, 1) : []),
@@ -27,8 +42,12 @@ const args = {
27
42
  boolean: true,
28
43
  stopEarly: true,
29
44
  };
45
+ const note = 'The `"ts-node"` section of `tsconfig.json` is read by the TypeScript plugin.';
46
+ export const docs = { note };
30
47
  const plugin = {
31
48
  title,
49
+ enablers,
50
+ isEnabled,
32
51
  args,
33
52
  };
34
53
  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,46 @@
1
+ const title = 'ts-node-dev';
2
+ const args = {
3
+ binaries: ['ts-node-dev', 'tsnd'],
4
+ positional: true,
5
+ nodeImportArgs: true,
6
+ args: (args) => args.filter((arg, index) => arg !== '--watch' && args[index - 1] !== '--watch'),
7
+ boolean: [
8
+ 'all-deps',
9
+ 'clear',
10
+ 'cls',
11
+ 'compiler-host',
12
+ 'debug',
13
+ 'dedupe',
14
+ 'deps',
15
+ 'emit',
16
+ 'error-recompile',
17
+ 'exec-check',
18
+ 'exit-child',
19
+ 'files',
20
+ 'fork',
21
+ 'log-error',
22
+ 'notify',
23
+ 'poll',
24
+ 'prefer-ts-exts',
25
+ 'pretty',
26
+ 'respawn',
27
+ 'rs',
28
+ 'scope',
29
+ 'script-mode',
30
+ 'skip-ignore',
31
+ 'skip-project',
32
+ 'transpile-only',
33
+ 'tree-kill',
34
+ ],
35
+ alias: {
36
+ 'compiler-host': ['H'],
37
+ 'prefer-ts-exts': ['prefer-ts'],
38
+ 'script-mode': ['s'],
39
+ 'transpile-only': ['T'],
40
+ },
41
+ };
42
+ const plugin = {
43
+ title,
44
+ args,
45
+ };
46
+ export default plugin;
@@ -24,6 +24,8 @@ const resolveConfig = async (config) => {
24
24
  const resolveFromAST = program => Array.from(collectPropertyValues(program, 'entry'), id => toEntry(id, { production: true, allowIncludeExports: true }));
25
25
  const args = {
26
26
  config: true,
27
+ boolean: ['clean'],
28
+ resolveInputs: parsed => parsed._.map(id => toEntry(id, { production: true, allowIncludeExports: true })),
27
29
  };
28
30
  const plugin = {
29
31
  title,
@@ -2,6 +2,7 @@ import { compact } from '../../util/array.js';
2
2
  import { toConfig, toModule, toDependency } from '../../util/input.js';
3
3
  import { join, toAbsolute } from '../../util/path.js';
4
4
  import { hasDependency } from '../../util/plugin.js';
5
+ import { resolveTsNodeConfig } from '../ts-node/index.js';
5
6
  import { contentMapperResolvers } from './content-mappers.js';
6
7
  const title = 'TypeScript';
7
8
  const enablers = ['typescript', '@typescript/native', '@typescript/native-preview'];
@@ -24,8 +25,11 @@ export const resolveConfig = (localConfig, options) => {
24
25
  : [];
25
26
  const references = localConfig.references?.map(({ path }) => toConfig(options.pluginName, path.endsWith('.json') ? path : toAbsolute(join(path, 'tsconfig.json'), options.configFileDir))) ?? [];
26
27
  const contentMappers = resolveContentMappers(localConfig, options.configFileDir);
28
+ const tsNode = localConfig['ts-node'] && options.enabledPlugins.includes('ts-node')
29
+ ? resolveTsNodeConfig(localConfig['ts-node'])
30
+ : [];
27
31
  if (!(compilerOptions && localConfig))
28
- return compact([...contentMappers, ...extend, ...references]);
32
+ return compact([...contentMappers, ...tsNode, ...extend, ...references]);
29
33
  const jsx = (compilerOptions?.jsxImportSource ? [compilerOptions.jsxImportSource] : []).map(id => toDependency(id, { production: true, dir: options.cwd, alsoReferenceOwner: true }));
30
34
  const types = compilerOptions.types?.filter(id => id !== '*') ?? [];
31
35
  const plugins = Array.isArray(compilerOptions?.plugins)
@@ -34,6 +38,7 @@ export const resolveConfig = (localConfig, options) => {
34
38
  const importHelpers = compilerOptions?.importHelpers ? ['tslib'] : [];
35
39
  return compact([
36
40
  ...contentMappers,
41
+ ...tsNode,
37
42
  ...extend,
38
43
  ...references,
39
44
  ...types.map(id => toModule(id, { isTypeOnly: true, dir: options.cwd, alsoReferenceOwner: true })),
@@ -1,5 +1,5 @@
1
1
  import { blockCommentMatcher, lineCommentMatcher, scriptExtractor } from '../../compilers/compilers.js';
2
- import { findImportedCalls, findProperty, getStringValues, resolveObjectArg } from '../../typescript/ast-helpers.js';
2
+ import { findImportedCalls, findProperty, getStringValues, resolveObjectArg, unwrapExpression, } from '../../typescript/ast-helpers.js';
3
3
  import { getStringValue } from '../../typescript/ast-nodes.js';
4
4
  import { isFile, loadFile } from '../../util/fs.js';
5
5
  import { toEntryPath } from '../../util/input.js';
@@ -100,9 +100,6 @@ export const getVitePluginDirs = (program, specifiers, key) => {
100
100
  }
101
101
  return dirs;
102
102
  };
103
- const unwrapExpression = (node) => node.type === 'TSSatisfiesExpression' || node.type === 'TSAsExpression' || node.type === 'ParenthesizedExpression'
104
- ? unwrapExpression(node.expression)
105
- : node;
106
103
  export const getViteRoot = (program, cwd) => {
107
104
  for (const node of program.body) {
108
105
  if (node.type !== 'ExportDefaultDeclaration')
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from '../../types/config.ts';
2
+ declare const plugin: Plugin;
3
+ export default plugin;
@@ -0,0 +1,11 @@
1
+ const title = 'vite-node';
2
+ const args = {
3
+ positional: true,
4
+ boolean: ['inspect', 'script'],
5
+ alias: { watch: ['w'] },
6
+ };
7
+ const plugin = {
8
+ title,
9
+ args,
10
+ };
11
+ export default plugin;
@@ -10,11 +10,15 @@ const getNames = (plugins = []) => plugins.flatMap(plugin => {
10
10
  const name = Array.isArray(plugin) ? plugin[0] : plugin;
11
11
  return typeof name === 'string' && !name.startsWith('file://') && !isAbsolute(name) ? [name] : [];
12
12
  });
13
- const toPluginDependency = (name, type, dir) => {
13
+ const toPluginDependency = (name, type, dir, manifest) => {
14
14
  if (name.startsWith('@'))
15
15
  return toDependency(name);
16
16
  const scoped = `@wdio/${name.toLowerCase()}-${type}`;
17
17
  const community = `wdio-${name.toLowerCase()}-${type}`;
18
+ if (manifest.allDependencies.has(scoped))
19
+ return toDependency(scoped);
20
+ if (manifest.allDependencies.has(community))
21
+ return toDependency(community);
18
22
  const isCommunity = !resolvePackageManifestPath(scoped, dir) && resolvePackageManifestPath(community, dir);
19
23
  return toDependency(isCommunity ? community : scoped);
20
24
  };
@@ -22,7 +26,7 @@ const resolveConfig = async (config, options) => {
22
26
  const cfg = config?.config;
23
27
  if (!cfg)
24
28
  return [];
25
- const toInputs = (plugins, type) => getNames(plugins).map(name => toPluginDependency(name, type, options.configFileDir));
29
+ const toInputs = (plugins, type) => getNames(plugins).map(name => toPluginDependency(name, type, options.configFileDir, options.manifest));
26
30
  return [
27
31
  ...toInputs([cfg.framework], 'framework'),
28
32
  ...toInputs([cfg.runner ?? 'local'], 'runner'),
@@ -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' | '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'];
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' | 'env-cmd' | 'esbuild' | 'eslint' | 'evalite' | 'eve' | 'execa' | 'expo' | 'expo-router' | 'expressive-code' | 'fast' | 'filesystem-routing' | 'firebase' | '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' | 'ts-node-dev' | '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-node' | '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', 'env-cmd', 'esbuild', 'eslint', 'evalite', 'eve', 'execa', 'expo', 'expo-router', 'expressive-code', 'fast', 'filesystem-routing', 'firebase', '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', 'ts-node-dev', '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-node', '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'];
@@ -36,6 +36,7 @@ export const pluginNames = [
36
36
  'eleventy',
37
37
  'ember',
38
38
  'ember-template-lint',
39
+ 'env',
39
40
  'env-cmd',
40
41
  'esbuild',
41
42
  'eslint',
@@ -47,6 +48,7 @@ export const pluginNames = [
47
48
  'expressive-code',
48
49
  'fast',
49
50
  'filesystem-routing',
51
+ 'firebase',
50
52
  'flue',
51
53
  'fumadocs',
52
54
  'gatsby',
@@ -174,6 +176,7 @@ export const pluginNames = [
174
176
  'travis',
175
177
  'trigger-dev',
176
178
  'ts-node',
179
+ 'ts-node-dev',
177
180
  'tsd',
178
181
  'tsdown',
179
182
  'tsrs',
@@ -196,6 +199,7 @@ export const pluginNames = [
196
199
  'vercel-og',
197
200
  'vike',
198
201
  'vite',
202
+ 'vite-node',
199
203
  'vite-plugin-pages',
200
204
  'vite-plugin-pwa',
201
205
  'vite-plugin-vue-layouts-next',
@@ -15,4 +15,9 @@ export interface TsConfigJson {
15
15
  references?: Array<{
16
16
  path: string;
17
17
  }>;
18
+ 'ts-node'?: {
19
+ compiler?: string;
20
+ transpiler?: string | [string, object];
21
+ require?: string[];
22
+ };
18
23
  }
@@ -1,10 +1,12 @@
1
- import type { CallExpression, ParseResult, Program } from 'oxc-parser';
1
+ import type { CallExpression, Node, ParseResult, Program } from 'oxc-parser';
2
2
  export declare const getPropertyKey: (prop: any) => string | undefined;
3
3
  export declare const getImportMap: (program: Program) => Map<string, string>;
4
4
  export declare const getPropertyValues: (node: any, propertyName: string) => Set<string>;
5
5
  export declare const collectPropertyValues: (program: Program, propertyName: string) => Set<string>;
6
6
  export declare const getFirstPropertyValue: (node: any, propertyName: string) => string | undefined;
7
7
  export declare const collectFirstPropertyValue: (program: Program, propertyName: string) => string | undefined;
8
+ export declare function unwrapExpression(node: Node): Node;
9
+ export declare function unwrapExpression(node: Node | null | undefined): Node | null | undefined;
8
10
  export declare const resolveObjectArg: (arg: any) => any | undefined;
9
11
  type ModuleMatch = string | string[] | ((path: string) => boolean);
10
12
  export declare const findImportedCalls: (program: Program, module: ModuleMatch) => CallExpression[];
@@ -82,23 +82,33 @@ const firstValue = (values) => {
82
82
  };
83
83
  export const getFirstPropertyValue = (node, propertyName) => firstValue(getPropertyValues(node, propertyName));
84
84
  export const collectFirstPropertyValue = (program, propertyName) => firstValue(collectPropertyValues(program, propertyName));
85
- const unwrapParens = (node) => node?.type === 'ParenthesizedExpression' ? unwrapParens(node.expression) : node;
85
+ export function unwrapExpression(node) {
86
+ while (node &&
87
+ (node.type === 'ParenthesizedExpression' ||
88
+ node.type === 'TSAsExpression' ||
89
+ node.type === 'TSSatisfiesExpression' ||
90
+ node.type === 'TSNonNullExpression' ||
91
+ node.type === 'TSTypeAssertion')) {
92
+ node = node.expression;
93
+ }
94
+ return node;
95
+ }
86
96
  export const resolveObjectArg = (arg) => {
87
- const node = unwrapParens(arg);
97
+ const node = unwrapExpression(arg);
88
98
  if (!node)
89
99
  return;
90
100
  if (node.type === 'ObjectExpression')
91
101
  return node;
92
102
  if (node.type !== 'ArrowFunctionExpression' && node.type !== 'FunctionExpression')
93
103
  return;
94
- const body = unwrapParens(node.body);
104
+ const body = unwrapExpression(node.body);
95
105
  if (body?.type === 'ObjectExpression')
96
106
  return body;
97
107
  if (body?.type !== 'BlockStatement')
98
108
  return;
99
109
  for (const stmt of body.body ?? []) {
100
110
  if (stmt.type === 'ReturnStatement') {
101
- const ret = unwrapParens(stmt.argument);
111
+ const ret = unwrapExpression(stmt.argument);
102
112
  if (ret?.type === 'ObjectExpression')
103
113
  return ret;
104
114
  }
@@ -1,5 +1,6 @@
1
1
  import { ALIAS_TAG, FIX_FLAGS, IMPORT_FLAGS, IMPORT_STAR, SYMBOL_TYPE } from '../../constants.js';
2
2
  import { addNsValue, addValue } from '../../util/module-graph.js';
3
+ import { unwrapExpression } from '../ast-helpers.js';
3
4
  import { extractEnumMembers, extractNamespaceMembers, getStringValue, isStringLiteral } from '../ast-nodes.js';
4
5
  import { EMPTY_TAGS } from './jsdoc.js';
5
6
  const getName = (n) => (n?.type === 'Identifier' ? n.name : undefined);
@@ -325,13 +326,15 @@ export function handleExpressionStatement(node, s) {
325
326
  if (exportName) {
326
327
  const right = expr.right;
327
328
  let isReExport = false;
329
+ const object = right.type === 'MemberExpression' ? unwrapExpression(right.object) : undefined;
328
330
  if (right.type === 'MemberExpression' &&
329
- right.object.type === 'CallExpression' &&
330
- right.object.callee.type === 'Identifier' &&
331
- right.object.callee.name === 'require' &&
332
- right.object.arguments.length === 1 &&
333
- isStringLiteral(right.object.arguments[0])) {
334
- const specifier = getStringValue(right.object.arguments[0]);
331
+ object &&
332
+ object.type === 'CallExpression' &&
333
+ object.callee.type === 'Identifier' &&
334
+ object.callee.name === 'require' &&
335
+ object.arguments.length === 1 &&
336
+ isStringLiteral(object.arguments[0])) {
337
+ const specifier = getStringValue(object.arguments[0]);
335
338
  let memberName;
336
339
  if (!right.computed && right.property.type === 'Identifier')
337
340
  memberName = right.property.name;
@@ -339,8 +342,8 @@ export function handleExpressionStatement(node, s) {
339
342
  memberName = getStringValue(right.property);
340
343
  if (memberName) {
341
344
  const alias = exportName !== memberName ? exportName : undefined;
342
- s.addImport(specifier, memberName, alias, undefined, right.object.arguments[0].start, IMPORT_FLAGS.RE_EXPORT);
343
- s.handledImportExpressions.add(right.object.start);
345
+ s.addImport(specifier, memberName, alias, undefined, object.arguments[0].start, IMPORT_FLAGS.RE_EXPORT);
346
+ s.handledImportExpressions.add(object.start);
344
347
  isReExport = true;
345
348
  }
346
349
  }
@@ -1,6 +1,7 @@
1
1
  import { IMPORT_FLAGS, IMPORT_STAR, OPAQUE } from '../../constants.js';
2
2
  import { addValue } from '../../util/module-graph.js';
3
3
  import { isInNodeModules } from '../../util/path.js';
4
+ import { unwrapExpression } from '../ast-helpers.js';
4
5
  import { getStringValue, isStringLiteral } from '../ast-nodes.js';
5
6
  import { isShadowedIn } from './shadow.js';
6
7
  export function markNamespaceRef(name, pos, s, isStaticIncluded = false) {
@@ -53,12 +54,13 @@ export function handleVariableDeclarator(node, isVar, s) {
53
54
  handleDynamicImportBinding(node.id, importExpr, init.type === 'AwaitExpression', caughtFlag, getBlockScope(s), isVar, s);
54
55
  return;
55
56
  }
56
- if (init.type === 'CallExpression' &&
57
- init.callee.type === 'Identifier' &&
58
- init.callee.name === 'require' &&
59
- init.arguments.length === 1 &&
60
- isStringLiteral(init.arguments[0])) {
61
- const specifier = getStringValue(init.arguments[0]);
57
+ const requireInit = unwrapExpression(init);
58
+ if (requireInit.type === 'CallExpression' &&
59
+ requireInit.callee.type === 'Identifier' &&
60
+ requireInit.callee.name === 'require' &&
61
+ requireInit.arguments.length === 1 &&
62
+ isStringLiteral(requireInit.arguments[0])) {
63
+ const specifier = getStringValue(requireInit.arguments[0]);
62
64
  const reqTags = s.currentVarDeclStart >= 0 ? s.getJSDocTags(s.currentVarDeclStart) : undefined;
63
65
  if (node.id.type === 'ObjectPattern') {
64
66
  for (const prop of node.id.properties) {
@@ -78,10 +80,10 @@ export function handleVariableDeclarator(node, isVar, s) {
78
80
  }
79
81
  }
80
82
  else if (node.id.type === 'Identifier') {
81
- s.addImport(specifier, 'default', node.id.name, undefined, init.arguments[0].start, IMPORT_FLAGS.NONE, undefined, reqTags);
83
+ s.addImport(specifier, 'default', node.id.name, undefined, requireInit.arguments[0].start, IMPORT_FLAGS.NONE, undefined, reqTags);
82
84
  }
83
85
  else {
84
- s.addImport(specifier, undefined, undefined, undefined, init.arguments[0].start, IMPORT_FLAGS.SIDE_EFFECTS, undefined, reqTags);
86
+ s.addImport(specifier, undefined, undefined, undefined, requireInit.arguments[0].start, IMPORT_FLAGS.SIDE_EFFECTS, undefined, reqTags);
85
87
  }
86
88
  return;
87
89
  }
@@ -1,5 +1,6 @@
1
1
  import { IMPORT_FLAGS, OPAQUE } from '../../constants.js';
2
2
  import { addValue } from '../../util/module-graph.js';
3
+ import { unwrapExpression } from '../ast-helpers.js';
3
4
  import { getStringValue, isStringLiteral } from '../ast-nodes.js';
4
5
  import { isShadowedIn } from './shadow.js';
5
6
  const chainNames = [];
@@ -10,21 +11,22 @@ function isNumericKey(value) {
10
11
  return value != null && Number.isFinite(Number(value)) && String(Number(value)) === value;
11
12
  }
12
13
  export function handleMemberExpression(node, s) {
13
- if (node.object.type === 'CallExpression' &&
14
- node.object.callee.type === 'Identifier' &&
15
- node.object.callee.name === 'require' &&
16
- node.object.arguments.length === 1 &&
17
- isStringLiteral(node.object.arguments[0]) &&
18
- !s.handledImportExpressions.has(node.object.start)) {
14
+ const object = unwrapExpression(node.object);
15
+ if (object.type === 'CallExpression' &&
16
+ object.callee.type === 'Identifier' &&
17
+ object.callee.name === 'require' &&
18
+ object.arguments.length === 1 &&
19
+ isStringLiteral(object.arguments[0]) &&
20
+ !s.handledImportExpressions.has(object.start)) {
19
21
  let memberName;
20
22
  if (!node.computed && node.property.type === 'Identifier')
21
23
  memberName = node.property.name;
22
24
  else if (node.computed && isStringLiteral(node.property))
23
25
  memberName = getStringValue(node.property);
24
26
  if (memberName) {
25
- const specifier = getStringValue(node.object.arguments[0]);
27
+ const specifier = getStringValue(object.arguments[0]);
26
28
  const reqTags = s.currentVarDeclStart >= 0 ? s.getJSDocTags(s.currentVarDeclStart) : undefined;
27
- s.addImport(specifier, memberName, undefined, undefined, node.object.arguments[0].start, IMPORT_FLAGS.NONE, undefined, reqTags);
29
+ s.addImport(specifier, memberName, undefined, undefined, object.arguments[0].start, IMPORT_FLAGS.NONE, undefined, reqTags);
28
30
  }
29
31
  return;
30
32
  }
@@ -2,7 +2,7 @@ import { IGNORED_GLOBAL_BINARIES } from '../constants.js';
2
2
  import { debugLog } from './debug.js';
3
3
  import { isFile } from './fs.js';
4
4
  import { fromBinary, isConfig, isDeferResolveEntry, toDebugString } from './input.js';
5
- import { getPackageNameFromFilePath, getPackageNameFromSpecifier } from './modules.js';
5
+ import { getPackageNameFromFilePath, getPackageNameFromSpecifier, isStartsLikePackageName } from './modules.js';
6
6
  import { dirname, isAbsolute, isInNodeModules, isInternal, join } from './path.js';
7
7
  import { _resolveModuleSync, _resolveSync, resolvePackageManifestPath } from './resolve.js';
8
8
  const CHAR_HASH = 35;
@@ -63,7 +63,7 @@ export const createInputHandler = (deputy, chief, isGitIgnored, addIssue, extern
63
63
  const packageName = resolvedFilePath
64
64
  ? getPackageNameFromFilePath(resolvedFilePath)
65
65
  : getPackageNameFromSpecifier(specifier);
66
- if (packageName) {
66
+ if (packageName && isStartsLikePackageName(packageName)) {
67
67
  if (packageName !== recordedPackageName && !chief.findWorkspaceByPackageName(packageName, containingFilePath)) {
68
68
  addExternalRef(containingFilePath, packageName);
69
69
  }
@@ -32,6 +32,7 @@ export declare const save: (filePath: string, content: ExtendedPackageJson) => P
32
32
  export declare const getEntrySpecifiersFromManifest: (manifest: PackageJson, isIncludeSubpathExports?: boolean) => Set<string>;
33
33
  export type Manifest = PackageJson & {
34
34
  scriptNames: Set<string>;
35
+ allDependencies: Set<string>;
35
36
  getMajor: (name: string) => number | undefined;
36
37
  };
37
38
  export declare const createManifest: (raw: PackageJson) => Manifest;
@@ -323,15 +323,27 @@ export const getEntrySpecifiersFromManifest = (manifest, isIncludeSubpathExports
323
323
  }
324
324
  return entryPaths;
325
325
  };
326
- export const createManifest = (raw) => Object.assign(raw, {
327
- ...raw,
328
- scriptNames: new Set(Object.keys(raw.scripts ?? {})),
329
- getMajor(name) {
330
- const range = raw.dependencies?.[name] ?? raw.devDependencies?.[name];
331
- const match = range?.match(/\d+/)?.[0];
332
- return match ? Number.parseInt(match, 10) : undefined;
333
- },
334
- });
326
+ export const createManifest = (raw) => {
327
+ const allDependencies = new Set();
328
+ for (const name in raw.dependencies)
329
+ allDependencies.add(name);
330
+ for (const name in raw.devDependencies)
331
+ allDependencies.add(name);
332
+ for (const name in raw.peerDependencies)
333
+ allDependencies.add(name);
334
+ for (const name in raw.optionalDependencies)
335
+ allDependencies.add(name);
336
+ return Object.assign(raw, {
337
+ ...raw,
338
+ scriptNames: new Set(Object.keys(raw.scripts ?? {})),
339
+ allDependencies,
340
+ getMajor(name) {
341
+ const range = raw.dependencies?.[name] ?? raw.devDependencies?.[name];
342
+ const match = range?.match(/\d+/)?.[0];
343
+ return match ? Number.parseInt(match, 10) : undefined;
344
+ },
345
+ });
346
+ };
335
347
  export const getManifestImportDependencies = (manifest) => {
336
348
  const dependencies = new Set();
337
349
  if (!manifest.imports)
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "6.47.0";
1
+ export declare const version = "6.48.0";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '6.47.0';
1
+ export const version = '6.48.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "6.47.0",
3
+ "version": "6.48.0",
4
4
  "description": "Find and fix unused dependencies, exports and files in your TypeScript and JavaScript projects",
5
5
  "keywords": [
6
6
  "analysis",