knip 6.4.1 → 6.6.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.
- package/dist/CacheConsultant.js +3 -3
- package/dist/CatalogCounselor.js +5 -5
- package/dist/ConfigurationChief.d.ts +39 -16
- package/dist/ConfigurationChief.js +15 -15
- package/dist/DependencyDeputy.d.ts +1 -1
- package/dist/DependencyDeputy.js +5 -5
- package/dist/IssueCollector.js +3 -3
- package/dist/IssueFixer.js +5 -5
- package/dist/JsonCatalogPeeker.js +1 -1
- package/dist/ProjectPrincipal.js +13 -13
- package/dist/WorkspaceWorker.d.ts +3 -2
- package/dist/WorkspaceWorker.js +39 -26
- package/dist/YamlCatalogPeeker.js +1 -1
- package/dist/binaries/bash-parser.js +10 -10
- package/dist/binaries/fallback.js +3 -3
- package/dist/binaries/index.js +3 -3
- package/dist/binaries/plugins.js +6 -6
- package/dist/binaries/resolvers/bun.js +4 -4
- package/dist/binaries/resolvers/bunx.js +4 -4
- package/dist/binaries/resolvers/find.js +1 -1
- package/dist/binaries/resolvers/index.js +8 -8
- package/dist/binaries/resolvers/npx.js +4 -4
- package/dist/binaries/resolvers/pnpm.js +3 -3
- package/dist/binaries/resolvers/pnpx.js +2 -2
- package/dist/binaries/resolvers/yarn.js +4 -4
- package/dist/cli.js +10 -10
- package/dist/compilers/index.d.ts +62 -22
- package/dist/compilers/index.js +2 -2
- package/dist/compilers/mdx.js +1 -1
- package/dist/compilers/scss.js +1 -1
- package/dist/constants.d.ts +25 -25
- package/dist/constants.js +1 -1
- package/dist/graph/analyze.js +7 -7
- package/dist/graph/build.d.ts +2 -2
- package/dist/graph/build.js +34 -26
- package/dist/graph-explorer/constants.d.ts +5 -5
- package/dist/graph-explorer/explorer.js +9 -9
- package/dist/graph-explorer/operations/build-exports-tree.js +2 -2
- package/dist/graph-explorer/operations/get-contention.js +3 -3
- package/dist/graph-explorer/operations/get-dependency-usage.js +1 -1
- package/dist/graph-explorer/operations/get-usage.js +5 -5
- package/dist/graph-explorer/operations/has-strictly-ns-references.js +1 -1
- package/dist/graph-explorer/operations/is-referenced.js +2 -2
- package/dist/graph-explorer/operations/resolve-definition.js +3 -3
- package/dist/graph-explorer/utils.d.ts +1 -1
- package/dist/graph-explorer/utils.js +2 -2
- package/dist/graph-explorer/visitors.js +1 -1
- package/dist/graph-explorer/walk-down.js +2 -2
- package/dist/graph-explorer/walk-up.js +2 -2
- package/dist/index.js +2 -2
- package/dist/manifest/helpers.js +2 -2
- package/dist/manifest/index.js +3 -3
- package/dist/plugins/_template/index.js +2 -2
- package/dist/plugins/angular/index.js +4 -4
- package/dist/plugins/astro/compiler-mdx.js +1 -1
- package/dist/plugins/astro/compiler.js +1 -1
- package/dist/plugins/astro/index.js +8 -6
- package/dist/plugins/astro/resolveFromAST.d.ts +1 -0
- package/dist/plugins/astro/resolveFromAST.js +40 -1
- package/dist/plugins/astro-db/index.js +1 -1
- package/dist/plugins/astro-og-canvas/index.js +2 -2
- package/dist/plugins/ava/index.js +2 -2
- package/dist/plugins/babel/helpers.d.ts +44 -6
- package/dist/plugins/babel/helpers.js +1 -1
- package/dist/plugins/babel/index.js +4 -4
- package/dist/plugins/biome/index.js +4 -4
- package/dist/plugins/bumpp/index.js +2 -2
- package/dist/plugins/bun/index.js +1 -1
- package/dist/plugins/c8/index.js +1 -1
- package/dist/plugins/capacitor/index.js +3 -3
- package/dist/plugins/changelogen/index.js +2 -2
- package/dist/plugins/changelogithub/index.js +2 -2
- package/dist/plugins/changesets/index.js +3 -3
- package/dist/plugins/commitizen/index.js +2 -2
- package/dist/plugins/commitlint/index.js +3 -3
- package/dist/plugins/convex/index.js +1 -1
- package/dist/plugins/create-typescript-app/index.js +1 -1
- package/dist/plugins/cspell/index.js +2 -2
- package/dist/plugins/cucumber/index.js +2 -2
- package/dist/plugins/cypress/helpers.js +2 -2
- package/dist/plugins/cypress/index.js +3 -3
- package/dist/plugins/danger/index.js +1 -1
- package/dist/plugins/dependency-cruiser/index.js +1 -1
- package/dist/plugins/docusaurus/helpers.js +2 -2
- package/dist/plugins/docusaurus/index.js +4 -4
- package/dist/plugins/dotenv/index.js +1 -1
- package/dist/plugins/drizzle/index.js +2 -2
- package/dist/plugins/eleventy/index.js +6 -6
- package/dist/plugins/eslint/helpers.js +5 -5
- package/dist/plugins/eslint/index.js +4 -4
- package/dist/plugins/eslint/resolveFromAST.js +3 -3
- package/dist/plugins/execa/index.js +2 -2
- package/dist/plugins/execa/visitors/execa.js +1 -1
- package/dist/plugins/expo/helpers.d.ts +3 -3
- package/dist/plugins/expo/helpers.js +3 -3
- package/dist/plugins/expo/index.js +4 -4
- package/dist/plugins/expressive-code/index.js +1 -1
- package/dist/plugins/gatsby/index.js +2 -2
- package/dist/plugins/github-action/index.js +4 -4
- package/dist/plugins/github-actions/index.js +4 -4
- package/dist/plugins/graphql-codegen/index.js +5 -5
- package/dist/plugins/hardhat/index.js +2 -2
- package/dist/plugins/husky/index.js +3 -3
- package/dist/plugins/i18next-parser/index.js +1 -1
- package/dist/plugins/index.d.ts +4 -0
- package/dist/plugins/index.js +152 -144
- package/dist/plugins/jest/helpers.js +2 -2
- package/dist/plugins/jest/index.js +4 -4
- package/dist/plugins/karma/helpers.d.ts +1 -1
- package/dist/plugins/karma/helpers.js +2 -2
- package/dist/plugins/karma/index.js +4 -4
- package/dist/plugins/knex/index.js +3 -3
- package/dist/plugins/ladle/index.js +4 -4
- package/dist/plugins/lefthook/index.js +5 -5
- package/dist/plugins/lint-staged/index.js +2 -2
- package/dist/plugins/linthtml/index.js +3 -3
- package/dist/plugins/lockfile-lint/index.js +2 -2
- package/dist/plugins/lost-pixel/index.js +1 -1
- package/dist/plugins/markdownlint/index.js +3 -3
- package/dist/plugins/mdx/index.js +2 -2
- package/dist/plugins/mdxlint/index.js +3 -3
- package/dist/plugins/metro/index.js +4 -4
- package/dist/plugins/mocha/index.js +2 -2
- package/dist/plugins/moonrepo/index.js +1 -1
- package/dist/plugins/msw/index.js +3 -3
- package/dist/plugins/nano-staged/index.js +1 -1
- package/dist/plugins/nest/index.js +2 -2
- package/dist/plugins/netlify/index.js +4 -4
- package/dist/plugins/next/index.js +3 -3
- package/dist/plugins/next/resolveFromAST.js +1 -1
- package/dist/plugins/next-intl/index.js +1 -1
- package/dist/plugins/next-mdx/index.js +3 -3
- package/dist/plugins/next-mdx/resolveFromAST.js +1 -1
- package/dist/plugins/nitro/index.js +3 -3
- package/dist/plugins/node/index.js +1 -1
- package/dist/plugins/node-modules-inspector/index.js +2 -2
- package/dist/plugins/npm-package-json-lint/index.js +3 -3
- package/dist/plugins/nuxt/helpers.js +3 -3
- package/dist/plugins/nuxt/index.js +10 -11
- package/dist/plugins/nx/index.js +4 -4
- package/dist/plugins/nyc/index.js +2 -2
- package/dist/plugins/oclif/index.js +2 -2
- package/dist/plugins/openapi-ts/index.js +2 -2
- package/dist/plugins/oxfmt/index.js +1 -1
- package/dist/plugins/oxlint/index.js +3 -3
- package/dist/plugins/panda-css/index.js +2 -2
- package/dist/plugins/parcel/index.js +2 -2
- package/dist/plugins/payload/index.js +2 -2
- package/dist/plugins/pino/index.d.ts +3 -0
- package/dist/plugins/pino/index.js +15 -0
- package/dist/plugins/pino/visitors/transportCall.d.ts +2 -0
- package/dist/plugins/pino/visitors/transportCall.js +87 -0
- package/dist/plugins/playwright/index.js +4 -4
- package/dist/plugins/playwright-ct/index.js +3 -3
- package/dist/plugins/playwright-test/index.js +1 -1
- package/dist/plugins/plop/index.js +1 -1
- package/dist/plugins/pm2/index.js +3 -3
- package/dist/plugins/pnpm/index.js +1 -1
- package/dist/plugins/postcss/index.js +3 -3
- package/dist/plugins/preconstruct/index.js +3 -3
- package/dist/plugins/prettier/index.js +6 -2
- package/dist/plugins/prisma/index.js +5 -5
- package/dist/plugins/qwik/index.js +5 -5
- package/dist/plugins/qwik/resolveFromAST.js +1 -1
- package/dist/plugins/raycast/index.js +3 -3
- package/dist/plugins/react-cosmos/index.js +3 -3
- package/dist/plugins/react-email/index.d.ts +3 -0
- package/dist/plugins/react-email/index.js +26 -0
- package/dist/plugins/react-native/index.js +2 -2
- package/dist/plugins/react-router/index.js +6 -10
- package/dist/plugins/relay/index.js +3 -3
- package/dist/plugins/release-it/index.js +2 -2
- package/dist/plugins/remark/index.js +3 -3
- package/dist/plugins/remix/index.js +1 -1
- package/dist/plugins/rolldown/index.js +3 -3
- package/dist/plugins/rolldown/resolveFromAST.js +1 -1
- package/dist/plugins/rollup/index.js +3 -3
- package/dist/plugins/rollup/resolveFromAST.js +1 -1
- package/dist/plugins/rsbuild/index.js +2 -2
- package/dist/plugins/rslib/index.js +1 -1
- package/dist/plugins/rspack/index.js +2 -2
- package/dist/plugins/rstest/index.js +2 -2
- package/dist/plugins/sanity/index.js +1 -1
- package/dist/plugins/semantic-release/index.js +3 -3
- package/dist/plugins/sentry/index.js +1 -1
- package/dist/plugins/serverless-framework/index.d.ts +3 -0
- package/dist/plugins/serverless-framework/index.js +23 -0
- package/dist/plugins/serverless-framework/types.d.ts +7 -0
- package/dist/plugins/serverless-framework/types.js +1 -0
- package/dist/plugins/simple-git-hooks/index.js +2 -2
- package/dist/plugins/size-limit/index.js +3 -3
- package/dist/plugins/sst/index.js +2 -2
- package/dist/plugins/sst/resolveFromAST.js +5 -5
- package/dist/plugins/starlight/index.js +4 -4
- package/dist/plugins/starlight/resolveFromAST.js +1 -1
- package/dist/plugins/stencil/index.js +3 -3
- package/dist/plugins/storybook/index.js +3 -3
- package/dist/plugins/stryker/index.js +2 -2
- package/dist/plugins/stylelint/index.js +3 -3
- package/dist/plugins/svelte/compiler.js +1 -1
- package/dist/plugins/svelte/index.js +3 -3
- package/dist/plugins/sveltejs-package/helpers.d.ts +8 -0
- package/dist/plugins/sveltejs-package/helpers.js +65 -0
- package/dist/plugins/sveltejs-package/index.d.ts +3 -0
- package/dist/plugins/sveltejs-package/index.js +27 -0
- package/dist/plugins/sveltekit/index.js +3 -3
- package/dist/plugins/svgo/index.js +1 -1
- package/dist/plugins/svgr/index.js +2 -2
- package/dist/plugins/swc/index.js +3 -3
- package/dist/plugins/syncpack/index.js +2 -2
- package/dist/plugins/tailwind/index.js +2 -2
- package/dist/plugins/tanstack-router/index.js +3 -3
- package/dist/plugins/taskfile/index.js +3 -3
- package/dist/plugins/travis/index.js +1 -1
- package/dist/plugins/tsdown/index.js +3 -3
- package/dist/plugins/tsdown/resolveFromAST.js +1 -1
- package/dist/plugins/tsup/index.js +3 -3
- package/dist/plugins/tsup/resolveFromAST.js +1 -1
- package/dist/plugins/tsx/index.js +2 -2
- package/dist/plugins/typedoc/index.js +2 -2
- package/dist/plugins/typescript/index.js +4 -4
- package/dist/plugins/unbuild/index.js +2 -2
- package/dist/plugins/unocss/index.js +2 -2
- package/dist/plugins/vercel-og/index.js +1 -1
- package/dist/plugins/vike/index.js +1 -1
- package/dist/plugins/vite/helpers.js +4 -4
- package/dist/plugins/vite/index.js +5 -5
- package/dist/plugins/vite/visitors/importMetaGlob.js +4 -4
- package/dist/plugins/vitepress/index.js +1 -1
- package/dist/plugins/vitest/helpers.d.ts +4 -2
- package/dist/plugins/vitest/helpers.js +18 -0
- package/dist/plugins/vitest/index.js +9 -23
- package/dist/plugins/vue/compiler.js +1 -1
- package/dist/plugins/vue/index.js +4 -4
- package/dist/plugins/webdriver-io/index.js +2 -2
- package/dist/plugins/webpack/index.js +5 -5
- package/dist/plugins/webpack/visitors/requireContext.js +6 -7
- package/dist/plugins/wireit/index.js +1 -1
- package/dist/plugins/wrangler/index.js +2 -2
- package/dist/plugins/xo/index.js +2 -2
- package/dist/plugins/yarn/index.js +2 -2
- package/dist/plugins/yorkie/index.js +2 -2
- package/dist/plugins/zx/index.js +2 -2
- package/dist/plugins.js +2 -2
- package/dist/reporters/codeclimate.js +2 -2
- package/dist/reporters/codeowners.js +3 -3
- package/dist/reporters/compact.js +1 -1
- package/dist/reporters/disclosure.js +1 -1
- package/dist/reporters/github-actions.js +4 -4
- package/dist/reporters/index.js +8 -8
- package/dist/reporters/json.js +4 -4
- package/dist/reporters/markdown.js +2 -2
- package/dist/reporters/symbols.js +2 -2
- package/dist/reporters/trace.js +7 -7
- package/dist/reporters/util/configuration-hints.d.ts +2 -2
- package/dist/reporters/util/configuration-hints.js +7 -10
- package/dist/reporters/util/util.d.ts +3 -3
- package/dist/reporters/util/util.js +16 -15
- package/dist/reporters/watch.js +7 -7
- package/dist/run.js +14 -14
- package/dist/schema/configuration.d.ts +89 -31
- package/dist/schema/configuration.js +2 -2
- package/dist/schema/plugins.d.ts +20 -0
- package/dist/schema/plugins.js +4 -0
- package/dist/session/build-maps.js +3 -3
- package/dist/session/file-descriptor.js +3 -3
- package/dist/session/index.js +7 -7
- package/dist/session/package-json-descriptor.js +1 -1
- package/dist/session/session.js +3 -3
- package/dist/types/PluginNames.d.ts +2 -2
- package/dist/types/PluginNames.js +4 -0
- package/dist/types/config.d.ts +13 -0
- package/dist/types/issues.d.ts +1 -1
- package/dist/typescript/SourceFileManager.js +3 -3
- package/dist/typescript/ast-helpers.d.ts +2 -0
- package/dist/typescript/ast-helpers.js +5 -5
- package/dist/typescript/comments.js +1 -1
- package/dist/typescript/follow-imports.js +2 -2
- package/dist/typescript/get-imports-and-exports.js +10 -10
- package/dist/typescript/resolve-module-names.js +5 -5
- package/dist/typescript/visitors/calls.js +3 -3
- package/dist/typescript/visitors/exports.js +4 -4
- package/dist/typescript/visitors/helpers.js +3 -3
- package/dist/typescript/visitors/imports.js +4 -4
- package/dist/typescript/visitors/members.js +4 -4
- package/dist/typescript/visitors/walk.js +9 -9
- package/dist/util/Performance.d.ts +1 -1
- package/dist/util/Performance.js +2 -2
- package/dist/util/catalog.js +3 -3
- package/dist/util/codeowners.js +4 -4
- package/dist/util/colors.d.ts +18 -0
- package/dist/util/colors.js +24 -0
- package/dist/util/create-input-handler.js +6 -6
- package/dist/util/create-options.d.ts +72 -33
- package/dist/util/create-options.js +14 -15
- package/dist/util/create-workspace-graph.js +1 -1
- package/dist/util/debug.js +2 -4
- package/dist/util/file-entry-cache.js +4 -4
- package/dist/util/fs.js +2 -2
- package/dist/util/get-included-issue-types.js +2 -2
- package/dist/util/git.js +1 -1
- package/dist/util/glob-cache.js +4 -4
- package/dist/util/glob-core.d.ts +3 -3
- package/dist/util/glob-core.js +80 -64
- package/dist/util/glob.d.ts +1 -1
- package/dist/util/glob.js +14 -7
- package/dist/util/input.js +1 -1
- package/dist/util/issue-initializers.js +1 -1
- package/dist/util/jiti.js +1 -1
- package/dist/util/load-config.js +3 -3
- package/dist/util/load-tsconfig.js +62 -50
- package/dist/util/loader.js +5 -5
- package/dist/util/log.js +3 -3
- package/dist/util/map-workspaces.js +6 -6
- package/dist/util/modules.js +2 -2
- package/dist/util/package-name.js +1 -1
- package/dist/util/parse-and-convert-gitignores.d.ts +4 -2
- package/dist/util/parse-and-convert-gitignores.js +19 -7
- package/dist/util/plugin.js +5 -5
- package/dist/util/remove-export.js +1 -1
- package/dist/util/reporter.js +3 -3
- package/dist/util/require.js +1 -1
- package/dist/util/resolve.js +3 -3
- package/dist/util/string.d.ts +1 -1
- package/dist/util/table.js +1 -1
- package/dist/util/tag.js +1 -1
- package/dist/util/to-source-path.d.ts +4 -2
- package/dist/util/to-source-path.js +46 -22
- package/dist/util/trace.js +8 -8
- package/dist/util/watch.js +8 -8
- package/dist/util/workspace-file-filter.js +2 -2
- package/dist/util/workspace-selectors.js +4 -4
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +12 -19
- package/schema.json +13 -1
package/dist/util/table.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { stripVTControlCharacters } from 'node:util';
|
|
2
|
-
import { pad, truncate, truncateStart } from
|
|
2
|
+
import { pad, truncate, truncateStart } from './string.js';
|
|
3
3
|
const DEFAULT_MAX_WIDTH = process.stdout.columns || 120;
|
|
4
4
|
const MIN_TRUNCATED_WIDTH = 4;
|
|
5
5
|
const COLUMN_SEPARATOR = ' ';
|
package/dist/util/tag.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ALIAS_TAG, BETA_TAG, INTERNAL_TAG, PUBLIC_TAG } from
|
|
1
|
+
import { ALIAS_TAG, BETA_TAG, INTERNAL_TAG, PUBLIC_TAG } from '../constants.js';
|
|
2
2
|
export const splitTags = (rawTags) => {
|
|
3
3
|
const tags = rawTags.flatMap(tag => tag.split(','));
|
|
4
4
|
return tags.reduce(([incl, excl], tag) => {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import type { SourceMap } from '../types/config.ts';
|
|
1
2
|
import type { CompilerOptions } from '../types/project.ts';
|
|
2
3
|
import type { ConfigurationChief, Workspace } from '../ConfigurationChief.ts';
|
|
3
|
-
export declare const augmentWorkspace: (workspace: Workspace, dir: string, compilerOptions: CompilerOptions) => void;
|
|
4
|
+
export declare const augmentWorkspace: (workspace: Workspace, dir: string, compilerOptions: CompilerOptions | undefined, pluginSourceMaps?: SourceMap[]) => void;
|
|
4
5
|
export declare const getModuleSourcePathHandler: (chief: ConfigurationChief) => (filePath: string) => string | undefined;
|
|
5
|
-
export declare const getToSourcePathsHandler: (chief: ConfigurationChief) => (specifiers: Set<string>, dir: string, extensions: string | undefined, label: string) => Promise<string[]>;
|
|
6
|
+
export declare const getToSourcePathsHandler: (chief: ConfigurationChief) => (specifiers: Set<string>, dir: string, extensions: (string | undefined) | undefined, label: string) => Promise<string[]>;
|
|
7
|
+
export declare const toSourceMappedSpecifiers: (ws: Workspace | undefined, absSpecifier: string, extensions?: string) => string[];
|
|
6
8
|
export type ToSourceFilePath = ReturnType<typeof getModuleSourcePathHandler>;
|
|
@@ -1,17 +1,32 @@
|
|
|
1
|
-
import { DEFAULT_EXTENSIONS } from
|
|
2
|
-
import { debugLog, debugLogArray } from
|
|
3
|
-
import { findFileWithExtensions, isDirectory } from
|
|
4
|
-
import { _glob, prependDirToPattern } from
|
|
5
|
-
import { isAbsolute, isInternal, join, toRelative } from
|
|
1
|
+
import { DEFAULT_EXTENSIONS } from '../constants.js';
|
|
2
|
+
import { debugLog, debugLogArray } from './debug.js';
|
|
3
|
+
import { findFileWithExtensions, isDirectory } from './fs.js';
|
|
4
|
+
import { _glob, prependDirToPattern } from './glob.js';
|
|
5
|
+
import { isAbsolute, isInternal, join, toRelative } from './path.js';
|
|
6
6
|
const defaultExtensions = `.{${[...DEFAULT_EXTENSIONS].map(ext => ext.slice(1)).join(',')}}`;
|
|
7
7
|
const hasTSExt = /(?<!\.d)\.(m|c)?tsx?$/;
|
|
8
8
|
const matchExt = /(\.d)?\.(m|c)?(j|t)s$/;
|
|
9
9
|
const sourceExtensions = [...DEFAULT_EXTENSIONS];
|
|
10
|
-
|
|
10
|
+
const tsconfigSourceMap = (dir, compilerOptions) => {
|
|
11
11
|
const srcDir = join(dir, 'src');
|
|
12
12
|
const outDirHasSrc = compilerOptions.outDir && isDirectory(compilerOptions.outDir, 'src');
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
const resolvedSrc = compilerOptions.rootDir ?? (outDirHasSrc ? dir : isDirectory(srcDir) ? srcDir : dir);
|
|
14
|
+
return { srcDir: resolvedSrc, outDir: compilerOptions.outDir || resolvedSrc };
|
|
15
|
+
};
|
|
16
|
+
export const augmentWorkspace = (workspace, dir, compilerOptions, pluginSourceMaps = []) => {
|
|
17
|
+
const all = compilerOptions ? [...pluginSourceMaps, tsconfigSourceMap(dir, compilerOptions)] : pluginSourceMaps;
|
|
18
|
+
if (all.length === 0)
|
|
19
|
+
return;
|
|
20
|
+
workspace.sourceMaps = all.sort((a, b) => b.outDir.length - a.outDir.length);
|
|
21
|
+
};
|
|
22
|
+
const isUnderOutDir = (absPath, outDir) => absPath === outDir || absPath.startsWith(`${outDir}/`);
|
|
23
|
+
const isUnderSrcDir = (absPath, srcDir) => absPath === srcDir || absPath.startsWith(`${srcDir}/`);
|
|
24
|
+
const rewritePattern = (sourceMaps, absSpecifier, extensions) => {
|
|
25
|
+
for (const { srcDir, outDir } of sourceMaps) {
|
|
26
|
+
if (!isUnderSrcDir(absSpecifier, srcDir) && isUnderOutDir(absSpecifier, outDir)) {
|
|
27
|
+
return srcDir + absSpecifier.slice(outDir.length).replace(matchExt, extensions);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
15
30
|
};
|
|
16
31
|
export const getModuleSourcePathHandler = (chief) => {
|
|
17
32
|
const toSourceMapCache = new Map();
|
|
@@ -21,13 +36,16 @@ export const getModuleSourcePathHandler = (chief) => {
|
|
|
21
36
|
if (toSourceMapCache.has(filePath))
|
|
22
37
|
return toSourceMapCache.get(filePath);
|
|
23
38
|
const workspace = chief.findWorkspaceByFilePath(filePath);
|
|
24
|
-
if (workspace?.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
39
|
+
if (!workspace?.sourceMaps)
|
|
40
|
+
return;
|
|
41
|
+
for (const { srcDir, outDir } of workspace.sourceMaps) {
|
|
42
|
+
if (!(isUnderOutDir(filePath, outDir) || srcDir === outDir))
|
|
43
|
+
continue;
|
|
44
|
+
const basePath = (srcDir + filePath.slice(outDir.length)).replace(matchExt, '');
|
|
45
|
+
const srcFilePath = findFileWithExtensions(basePath, sourceExtensions);
|
|
46
|
+
if (srcFilePath) {
|
|
47
|
+
toSourceMapCache.set(filePath, srcFilePath);
|
|
48
|
+
if (srcFilePath !== filePath) {
|
|
31
49
|
debugLog('*', `Source mapping ${toRelative(filePath, chief.cwd)} → ${toRelative(srcFilePath, chief.cwd)}`);
|
|
32
50
|
return srcFilePath;
|
|
33
51
|
}
|
|
@@ -41,16 +59,22 @@ export const getToSourcePathsHandler = (chief) => {
|
|
|
41
59
|
for (const specifier of specifiers) {
|
|
42
60
|
const absSpecifier = isAbsolute(specifier) ? specifier : prependDirToPattern(dir, specifier);
|
|
43
61
|
const ws = chief.findWorkspaceByFilePath(absSpecifier);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
patterns.add(pattern);
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
patterns.add(absSpecifier);
|
|
50
|
-
}
|
|
62
|
+
const mapped = ws?.sourceMaps && rewritePattern(ws.sourceMaps, absSpecifier, extensions);
|
|
63
|
+
patterns.add(mapped ?? absSpecifier);
|
|
51
64
|
}
|
|
52
65
|
const filePaths = await _glob({ patterns: Array.from(patterns), cwd: dir, label });
|
|
53
66
|
debugLogArray(toRelative(dir, chief.cwd), 'Source mapping (package.json)', filePaths);
|
|
54
67
|
return filePaths;
|
|
55
68
|
};
|
|
56
69
|
};
|
|
70
|
+
export const toSourceMappedSpecifiers = (ws, absSpecifier, extensions = defaultExtensions) => {
|
|
71
|
+
const out = [];
|
|
72
|
+
if (!ws?.sourceMaps)
|
|
73
|
+
return out;
|
|
74
|
+
for (const { srcDir, outDir } of ws.sourceMaps) {
|
|
75
|
+
if (!isUnderSrcDir(absSpecifier, srcDir) && isUnderOutDir(absSpecifier, outDir)) {
|
|
76
|
+
out.push(srcDir + absSpecifier.slice(outDir.length).replace(matchExt, extensions));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return out;
|
|
80
|
+
};
|
package/dist/util/trace.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import st from './colors.js';
|
|
2
2
|
export const formatTrace = (node, toRelative, isReferenced, memberStatuses) => {
|
|
3
3
|
const lines = [];
|
|
4
|
-
const file =
|
|
5
|
-
const id =
|
|
6
|
-
const ref =
|
|
7
|
-
const via =
|
|
8
|
-
const ok =
|
|
9
|
-
const fail =
|
|
10
|
-
const dim =
|
|
4
|
+
const file = st.white;
|
|
5
|
+
const id = st.cyanBright;
|
|
6
|
+
const ref = st.cyanBright;
|
|
7
|
+
const via = st.dim;
|
|
8
|
+
const ok = st.green;
|
|
9
|
+
const fail = st.red;
|
|
10
|
+
const dim = st.dim;
|
|
11
11
|
const entryMarker = node.isEntry ? dim(' ⎆') : '';
|
|
12
12
|
lines.push(`${file(toRelative(node.filePath))}${dim(':')}${id(node.identifier)}${entryMarker}`);
|
|
13
13
|
const formatVia = (child) => {
|
package/dist/util/watch.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
|
-
import { invalidateCache } from
|
|
3
|
-
import { debugLog } from
|
|
4
|
-
import { isFile } from
|
|
5
|
-
import { updateImportMap } from
|
|
6
|
-
import { toAbsolute, toPosix, toRelative } from
|
|
7
|
-
import { clearModuleResolutionCaches } from
|
|
8
|
-
import { clearGlobCache } from
|
|
9
|
-
import { clearResolverCache } from
|
|
2
|
+
import { invalidateCache } from '../graph-explorer/cache.js';
|
|
3
|
+
import { debugLog } from './debug.js';
|
|
4
|
+
import { isFile } from './fs.js';
|
|
5
|
+
import { updateImportMap } from './module-graph.js';
|
|
6
|
+
import { toAbsolute, toPosix, toRelative } from './path.js';
|
|
7
|
+
import { clearModuleResolutionCaches } from '../typescript/resolve-module-names.js';
|
|
8
|
+
import { clearGlobCache } from './glob-cache.js';
|
|
9
|
+
import { clearResolverCache } from './resolve.js';
|
|
10
10
|
const createUpdate = (options) => {
|
|
11
11
|
const duration = performance.now() - options.startTime;
|
|
12
12
|
const mem = process.memoryUsage().heapUsed;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ROOT_WORKSPACE_NAME } from
|
|
2
|
-
import { join } from
|
|
1
|
+
import { ROOT_WORKSPACE_NAME } from '../constants.js';
|
|
2
|
+
import { join } from './path.js';
|
|
3
3
|
export const createWorkspaceFilePathFilter = (cwd, selectedWorkspaces, availableWorkspaceNames) => {
|
|
4
4
|
if (!selectedWorkspaces || !availableWorkspaceNames)
|
|
5
5
|
return () => true;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import picomatch from 'picomatch';
|
|
2
|
-
import { partition } from
|
|
3
|
-
import { ConfigurationError } from
|
|
4
|
-
import { isDirectory, isFile } from
|
|
5
|
-
import { join } from
|
|
2
|
+
import { partition } from './array.js';
|
|
3
|
+
import { ConfigurationError } from './errors.js';
|
|
4
|
+
import { isDirectory, isFile } from './fs.js';
|
|
5
|
+
import { join } from './path.js';
|
|
6
6
|
export function parseWorkspaceSelector(token, cwd) {
|
|
7
7
|
const trimmed = token.trim();
|
|
8
8
|
let isNegated = false;
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "6.
|
|
1
|
+
export declare const version = "6.6.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '6.
|
|
1
|
+
export const version = '6.6.0';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "knip",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.6.0",
|
|
4
4
|
"description": "Find and fix unused dependencies, exports and files in your TypeScript and JavaScript projects",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"analysis",
|
|
@@ -77,18 +77,17 @@
|
|
|
77
77
|
}
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
80
|
-
"
|
|
81
|
-
"fast-glob": "^3.3.3",
|
|
80
|
+
"fdir": "^6.5.0",
|
|
82
81
|
"formatly": "^0.3.0",
|
|
83
|
-
"get-tsconfig": "4.
|
|
82
|
+
"get-tsconfig": "4.14.0",
|
|
84
83
|
"jiti": "^2.6.0",
|
|
85
84
|
"minimist": "^1.2.8",
|
|
86
|
-
"oxc-parser": "^0.
|
|
85
|
+
"oxc-parser": "^0.126.0",
|
|
87
86
|
"oxc-resolver": "^11.19.1",
|
|
88
|
-
"
|
|
89
|
-
"picomatch": "^4.0.1",
|
|
87
|
+
"picomatch": "^4.0.4",
|
|
90
88
|
"smol-toml": "^1.6.1",
|
|
91
89
|
"strip-json-comments": "5.0.3",
|
|
90
|
+
"tinyglobby": "^0.2.16",
|
|
92
91
|
"unbash": "^2.2.0",
|
|
93
92
|
"yaml": "^2.8.2",
|
|
94
93
|
"zod": "^4.1.11"
|
|
@@ -99,12 +98,11 @@
|
|
|
99
98
|
"@types/minimist": "^1.2.5",
|
|
100
99
|
"@types/picomatch": "^4.0.1",
|
|
101
100
|
"@types/webpack": "^5.28.5",
|
|
101
|
+
"@typescript/native-preview": "7.0.0-dev.20260415.1",
|
|
102
102
|
"@wdio/types": "^9.20.0",
|
|
103
103
|
"codeclimate-types": "^0.3.1",
|
|
104
|
-
"glob-bin": "^1.0.0",
|
|
105
104
|
"prettier": "^3.8.1",
|
|
106
|
-
"tsx": "^4.21.0"
|
|
107
|
-
"typescript": "^5.8.3"
|
|
105
|
+
"tsx": "^4.21.0"
|
|
108
106
|
},
|
|
109
107
|
"engines": {
|
|
110
108
|
"node": "^20.19.0 || >=22.12.0"
|
|
@@ -114,16 +112,11 @@
|
|
|
114
112
|
"knip": "node ./src/cli.ts --directory ../..",
|
|
115
113
|
"knip:production": "node ./src/cli.ts --directory ../.. --production --strict",
|
|
116
114
|
"lint": "oxlint",
|
|
117
|
-
"
|
|
118
|
-
"test": "node scripts/run-test.
|
|
119
|
-
"test:node": "tsx --test test/*.test.ts test/**/*.test.ts",
|
|
120
|
-
"test:bun": "bun test test/*.test.ts test/**/*.test.ts",
|
|
121
|
-
"test:smoke": "glob-bin -c \"tsx --test\" \"test/*.test.ts\" && glob-bin -c \"tsx --test\" \"test/plugins/*.test.ts\" && glob-bin -c \"tsx --test\" \"test/util/*.test.ts\"",
|
|
122
|
-
"test:bun:smoke": "bun test test/*.test.ts test/{plugins,util}/*.test.ts",
|
|
123
|
-
"watch": "npm link && tsc --watch",
|
|
115
|
+
"fmt": "oxfmt -c ../../.oxfmtrc.json --ignore-path ../../.prettierignore",
|
|
116
|
+
"test": "node scripts/run-test.js",
|
|
124
117
|
"prebuild": "pnpm run generate-plugin-defs && node rmdir.js dist",
|
|
125
|
-
"build": "
|
|
126
|
-
"qa": "pnpm lint && pnpm build && pnpm knip && pnpm knip:production && pnpm
|
|
118
|
+
"build": "tsgo",
|
|
119
|
+
"qa": "pnpm lint && pnpm build && pnpm knip && pnpm knip:production && pnpm test",
|
|
127
120
|
"release": "NODE_OPTIONS=--no-deprecation release-it",
|
|
128
121
|
"create-plugin": "node ./scripts/create-new-plugin.ts",
|
|
129
122
|
"postcreate-plugin": "pnpm run build && (oxfmt schema.json schema-jsonc.json src/schema/plugins.ts || true)",
|
package/schema.json
CHANGED
|
@@ -249,7 +249,7 @@
|
|
|
249
249
|
}
|
|
250
250
|
},
|
|
251
251
|
"globPatterns": {
|
|
252
|
-
"description": "Use file paths and glob patterns to match files. Knip uses
|
|
252
|
+
"description": "Use file paths and glob patterns to match files. Knip uses tinyglobby and picomatch (https://github.com/micromatch/picomatch)",
|
|
253
253
|
"anyOf": [
|
|
254
254
|
{
|
|
255
255
|
"type": "string"
|
|
@@ -640,6 +640,10 @@
|
|
|
640
640
|
"title": "payload plugin configuration (https://knip.dev/reference/plugins/payload)",
|
|
641
641
|
"$ref": "#/definitions/plugin"
|
|
642
642
|
},
|
|
643
|
+
"pino": {
|
|
644
|
+
"title": "pino plugin configuration (https://knip.dev/reference/plugins/pino)",
|
|
645
|
+
"$ref": "#/definitions/plugin"
|
|
646
|
+
},
|
|
643
647
|
"playwright": {
|
|
644
648
|
"title": "Playwright plugin configuration (https://knip.dev/reference/plugins/playwright)",
|
|
645
649
|
"$ref": "#/definitions/plugin"
|
|
@@ -684,6 +688,10 @@
|
|
|
684
688
|
"title": "react-cosmos plugin configuration (https://knip.dev/reference/plugins/react-cosmos)",
|
|
685
689
|
"$ref": "#/definitions/plugin"
|
|
686
690
|
},
|
|
691
|
+
"react-email": {
|
|
692
|
+
"title": "react-email plugin configuration (https://knip.dev/reference/plugins/react-email)",
|
|
693
|
+
"$ref": "#/definitions/plugin"
|
|
694
|
+
},
|
|
687
695
|
"react-native": {
|
|
688
696
|
"title": "react-native plugin configuration (https://knip.dev/reference/plugins/react-native)",
|
|
689
697
|
"$ref": "#/definitions/plugin"
|
|
@@ -744,6 +752,10 @@
|
|
|
744
752
|
"title": "Sentry plugin configuration (https://knip.dev/reference/plugins/sentry)",
|
|
745
753
|
"$ref": "#/definitions/plugin"
|
|
746
754
|
},
|
|
755
|
+
"serverless-framework": {
|
|
756
|
+
"title": "serverless-framework plugin configuration (https://knip.dev/reference/plugins/serverless-framework)",
|
|
757
|
+
"$ref": "#/definitions/plugin"
|
|
758
|
+
},
|
|
747
759
|
"simple-git-hooks": {
|
|
748
760
|
"title": "simple-git-hooks plugin configuration (https://knip.dev/reference/plugins/simple-git-hooks)",
|
|
749
761
|
"$ref": "#/definitions/plugin"
|