knip 6.46.1 → 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 (101) hide show
  1. package/dist/ConfigurationChief.d.ts +6 -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/binaries/create-script-parser-context.js +2 -1
  6. package/dist/binaries/fallback.js +2 -3
  7. package/dist/binaries/plugins.js +1 -5
  8. package/dist/binaries/resolvers/npx.js +6 -8
  9. package/dist/binaries/resolvers/pnpx.js +3 -7
  10. package/dist/binaries/util.d.ts +4 -0
  11. package/dist/binaries/util.js +12 -2
  12. package/dist/compilers/mdx.js +7 -1
  13. package/dist/plugins/angular/helpers.d.ts +7 -0
  14. package/dist/plugins/angular/helpers.js +58 -0
  15. package/dist/plugins/angular/index.js +5 -50
  16. package/dist/plugins/angular/types.d.ts +2 -2
  17. package/dist/plugins/astro/index.js +6 -1
  18. package/dist/plugins/cucumber/index.js +19 -7
  19. package/dist/plugins/cucumber/types.d.ts +1 -0
  20. package/dist/plugins/cypress/index.js +5 -0
  21. package/dist/plugins/docusaurus/helpers.js +19 -5
  22. package/dist/plugins/drizzle/index.js +5 -0
  23. package/dist/plugins/ember/index.js +4 -8
  24. package/dist/plugins/env/index.d.ts +3 -0
  25. package/dist/plugins/env/index.js +27 -0
  26. package/dist/plugins/esbuild/index.js +5 -0
  27. package/dist/plugins/firebase/index.d.ts +3 -0
  28. package/dist/plugins/firebase/index.js +12 -0
  29. package/dist/plugins/github-action/index.js +13 -3
  30. package/dist/plugins/github-actions/index.d.ts +2 -1
  31. package/dist/plugins/github-actions/index.js +4 -2
  32. package/dist/plugins/github-actions/types.d.ts +5 -0
  33. package/dist/plugins/graphql-codegen/index.js +2 -0
  34. package/dist/plugins/index.d.ts +6 -0
  35. package/dist/plugins/index.js +12 -0
  36. package/dist/plugins/mocha/index.js +6 -0
  37. package/dist/plugins/mocha/types.d.ts +3 -0
  38. package/dist/plugins/netlify/index.js +12 -2
  39. package/dist/plugins/netlify/types.d.ts +3 -0
  40. package/dist/plugins/node/index.d.ts +2 -2
  41. package/dist/plugins/node/index.js +14 -3
  42. package/dist/plugins/nodemon/index.js +19 -0
  43. package/dist/plugins/nx/index.js +14 -1
  44. package/dist/plugins/plop/index.js +4 -0
  45. package/dist/plugins/prisma/index.js +2 -0
  46. package/dist/plugins/remark/helpers.js +1 -8
  47. package/dist/plugins/rollup/index.js +1 -1
  48. package/dist/plugins/serverless-framework/index.js +14 -5
  49. package/dist/plugins/serverless-framework/types.d.ts +4 -1
  50. package/dist/plugins/sst/index.js +13 -0
  51. package/dist/plugins/sst/resolveFromAST.js +35 -16
  52. package/dist/plugins/start-server-and-test/index.d.ts +3 -0
  53. package/dist/plugins/start-server-and-test/index.js +10 -0
  54. package/dist/plugins/storybook/index.js +3 -3
  55. package/dist/plugins/storybook/types.d.ts +5 -3
  56. package/dist/plugins/textlint/helpers.js +1 -5
  57. package/dist/plugins/trigger-dev/index.d.ts +3 -0
  58. package/dist/plugins/trigger-dev/index.js +28 -0
  59. package/dist/plugins/ts-node/index.d.ts +6 -0
  60. package/dist/plugins/ts-node/index.js +19 -0
  61. package/dist/plugins/ts-node-dev/index.d.ts +3 -0
  62. package/dist/plugins/ts-node-dev/index.js +46 -0
  63. package/dist/plugins/tsup/index.js +2 -0
  64. package/dist/plugins/tsx/index.js +1 -1
  65. package/dist/plugins/typedoc/index.js +5 -2
  66. package/dist/plugins/typescript/index.d.ts +12 -1
  67. package/dist/plugins/typescript/index.js +12 -4
  68. package/dist/plugins/vite/helpers.js +1 -4
  69. package/dist/plugins/vite-node/index.d.ts +3 -0
  70. package/dist/plugins/vite-node/index.js +11 -0
  71. package/dist/plugins/vite-plus/index.d.ts +4 -1
  72. package/dist/plugins/vite-plus/index.js +19 -4
  73. package/dist/plugins/vite-plus/types.d.ts +12 -0
  74. package/dist/plugins/vite-plus/types.js +1 -0
  75. package/dist/plugins/vitepress/index.js +14 -0
  76. package/dist/plugins/vitest/index.js +5 -0
  77. package/dist/plugins/vitest/types.d.ts +2 -1
  78. package/dist/plugins/web-test-runner/index.js +8 -2
  79. package/dist/plugins/webdriver-io/index.js +6 -2
  80. package/dist/plugins/wrangler/index.js +4 -0
  81. package/dist/session/index.d.ts +1 -0
  82. package/dist/session/index.js +1 -0
  83. package/dist/types/PluginNames.d.ts +2 -2
  84. package/dist/types/PluginNames.js +6 -0
  85. package/dist/types/tsconfig-json.d.ts +5 -0
  86. package/dist/typescript/ast-helpers.d.ts +3 -1
  87. package/dist/typescript/ast-helpers.js +14 -4
  88. package/dist/typescript/visitors/exports.js +11 -8
  89. package/dist/typescript/visitors/imports.js +10 -8
  90. package/dist/typescript/visitors/members.js +10 -8
  91. package/dist/util/create-input-handler.js +5 -3
  92. package/dist/util/package-json.d.ts +1 -0
  93. package/dist/util/package-json.js +21 -9
  94. package/dist/util/remove-export.d.ts +1 -0
  95. package/dist/util/remove-export.js +2 -0
  96. package/dist/version.d.ts +1 -1
  97. package/dist/version.js +1 -1
  98. package/package.json +1 -1
  99. package/schema.json +24 -0
  100. package/dist/plugins/vite-plus/resolveFromAST.d.ts +0 -2
  101. package/dist/plugins/vite-plus/resolveFromAST.js +0 -37
@@ -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' | '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',
@@ -153,6 +155,7 @@ export const pluginNames = [
153
155
  'solidjs-vite-plugin',
154
156
  'sst',
155
157
  'starlight',
158
+ 'start-server-and-test',
156
159
  'stencil',
157
160
  'storybook',
158
161
  'stryker',
@@ -171,7 +174,9 @@ export const pluginNames = [
171
174
  'temporal',
172
175
  'textlint',
173
176
  'travis',
177
+ 'trigger-dev',
174
178
  'ts-node',
179
+ 'ts-node-dev',
175
180
  'tsd',
176
181
  'tsdown',
177
182
  'tsrs',
@@ -194,6 +199,7 @@ export const pluginNames = [
194
199
  'vercel-og',
195
200
  'vike',
196
201
  'vite',
202
+ 'vite-node',
197
203
  'vite-plugin-pages',
198
204
  'vite-plugin-pwa',
199
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
  }
@@ -1,7 +1,8 @@
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
- import { getPackageNameFromFilePath, getPackageNameFromSpecifier } from './modules.js';
5
+ import { getPackageNameFromFilePath, getPackageNameFromSpecifier, isStartsLikePackageName } from './modules.js';
5
6
  import { dirname, isAbsolute, isInNodeModules, isInternal, join } from './path.js';
6
7
  import { _resolveModuleSync, _resolveSync, resolvePackageManifestPath } from './resolve.js';
7
8
  const CHAR_HASH = 35;
@@ -62,7 +63,7 @@ export const createInputHandler = (deputy, chief, isGitIgnored, addIssue, extern
62
63
  const packageName = resolvedFilePath
63
64
  ? getPackageNameFromFilePath(resolvedFilePath)
64
65
  : getPackageNameFromSpecifier(specifier);
65
- if (packageName) {
66
+ if (packageName && isStartsLikePackageName(packageName)) {
66
67
  if (packageName !== recordedPackageName && !chief.findWorkspaceByPackageName(packageName, containingFilePath)) {
67
68
  addExternalRef(containingFilePath, packageName);
68
69
  }
@@ -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)
@@ -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)
@@ -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.48.0";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '6.46.1';
1
+ export const version = '6.48.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "6.46.1",
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",
package/schema.json CHANGED
@@ -587,6 +587,10 @@
587
587
  "title": "ember-template-lint plugin configuration (https://knip.dev/reference/plugins/ember-template-lint)",
588
588
  "$ref": "#/definitions/plugin"
589
589
  },
590
+ "env": {
591
+ "title": "env plugin configuration (https://knip.dev/reference/plugins/env)",
592
+ "$ref": "#/definitions/plugin"
593
+ },
590
594
  "env-cmd": {
591
595
  "title": "env-cmd plugin configuration (https://knip.dev/reference/plugins/env-cmd)",
592
596
  "$ref": "#/definitions/plugin"
@@ -631,6 +635,10 @@
631
635
  "title": "filesystem-routing plugin configuration (https://knip.dev/reference/plugins/filesystem-routing)",
632
636
  "$ref": "#/definitions/plugin"
633
637
  },
638
+ "firebase": {
639
+ "title": "firebase plugin configuration (https://knip.dev/reference/plugins/firebase)",
640
+ "$ref": "#/definitions/plugin"
641
+ },
634
642
  "flue": {
635
643
  "title": "flue plugin configuration (https://knip.dev/reference/plugins/flue)",
636
644
  "$ref": "#/definitions/plugin"
@@ -1043,6 +1051,10 @@
1043
1051
  "title": "starlight plugin configuration (https://knip.dev/reference/plugins/starlight)",
1044
1052
  "$ref": "#/definitions/plugin"
1045
1053
  },
1054
+ "start-server-and-test": {
1055
+ "title": "start-server-and-test plugin configuration (https://knip.dev/reference/plugins/start-server-and-test)",
1056
+ "$ref": "#/definitions/plugin"
1057
+ },
1046
1058
  "stencil": {
1047
1059
  "title": "stencil plugin configuration (https://knip.dev/reference/plugins/stencil)",
1048
1060
  "$ref": "#/definitions/plugin"
@@ -1115,10 +1127,18 @@
1115
1127
  "title": "travis plugin configuration (https://knip.dev/reference/plugins/travis)",
1116
1128
  "$ref": "#/definitions/plugin"
1117
1129
  },
1130
+ "trigger-dev": {
1131
+ "title": "trigger-dev plugin configuration (https://knip.dev/reference/plugins/trigger-dev)",
1132
+ "$ref": "#/definitions/plugin"
1133
+ },
1118
1134
  "ts-node": {
1119
1135
  "title": "ts-node plugin configuration (https://knip.dev/reference/plugins/ts-node)",
1120
1136
  "$ref": "#/definitions/plugin"
1121
1137
  },
1138
+ "ts-node-dev": {
1139
+ "title": "ts-node-dev plugin configuration (https://knip.dev/reference/plugins/ts-node-dev)",
1140
+ "$ref": "#/definitions/plugin"
1141
+ },
1122
1142
  "tsd": {
1123
1143
  "title": "tsd plugin configuration (https://knip.dev/reference/plugins/tsd)",
1124
1144
  "$ref": "#/definitions/plugin"
@@ -1207,6 +1227,10 @@
1207
1227
  "title": "vite plugin configuration (https://knip.dev/reference/plugins/vite)",
1208
1228
  "$ref": "#/definitions/plugin"
1209
1229
  },
1230
+ "vite-node": {
1231
+ "title": "vite-node plugin configuration (https://knip.dev/reference/plugins/vite-node)",
1232
+ "$ref": "#/definitions/plugin"
1233
+ },
1210
1234
  "vite-plugin-pages": {
1211
1235
  "title": "vite-plugin-pages plugin configuration (https://knip.dev/reference/plugins/vite-plugin-pages)",
1212
1236
  "$ref": "#/definitions/plugin"
@@ -1,2 +0,0 @@
1
- import type { ResolveFromAST } from '../../types/config.ts';
2
- export declare const resolveFromAST: ResolveFromAST;
@@ -1,37 +0,0 @@
1
- import { Visitor } from 'oxc-parser';
2
- import { findProperty, getPropertyValues } from '../../typescript/ast-helpers.js';
3
- import { getStringValue } from '../../typescript/ast-nodes.js';
4
- export const resolveFromAST = (program, options) => {
5
- const commands = [];
6
- const visitor = new Visitor({
7
- ObjectExpression(node) {
8
- const run = findProperty(node, 'run');
9
- const tasks = run?.type === 'ObjectExpression' ? findProperty(run, 'tasks') : undefined;
10
- if (tasks?.type === 'ObjectExpression') {
11
- for (const task of tasks.properties ?? []) {
12
- if (task.type === 'Property' && task.value?.type === 'ObjectExpression') {
13
- for (const command of getPropertyValues(task.value, 'command'))
14
- commands.push(command);
15
- }
16
- }
17
- }
18
- const staged = findProperty(node, 'staged');
19
- if (staged?.type === 'ObjectExpression') {
20
- for (const prop of staged.properties ?? []) {
21
- if (prop.type === 'Property') {
22
- const command = getStringValue(prop.value);
23
- if (command)
24
- commands.push(command);
25
- }
26
- }
27
- }
28
- },
29
- });
30
- visitor.visit(program);
31
- const inputs = [];
32
- for (const command of commands) {
33
- for (const input of options.getInputsFromScripts(command, { optionalBinaries: true }))
34
- inputs.push(input);
35
- }
36
- return inputs;
37
- };