Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

knip

Package Overview
Dependencies
Maintainers
0
Versions
430
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

knip - npm Package Compare versions

Comparing version 5.36.3 to 5.36.4

dist/plugins/glob/index.d.ts

2

dist/binaries/plugins.js

@@ -30,3 +30,3 @@ import parseArgs from 'minimist';

const positionals = [];
if (opts.positional) {
if (opts.positional && parsed._[0]) {
const id = parsed._[0];

@@ -33,0 +33,0 @@ if (isGlobLike(id))

@@ -1,2 +0,1 @@

import picocolors from 'picocolors';
import prettyMilliseconds from 'pretty-ms';

@@ -7,2 +6,3 @@ import { main } from './index.js';

import { getKnownError, hasCause, isConfigurationError, isKnownError } from './util/errors.js';
import { logError, logWarning } from './util/log.js';
import { cwd, join, toPosix } from './util/path.js';

@@ -82,5 +82,7 @@ import { runPreprocessors, runReporters } from './util/reporter.js';

if (experimentalTags.length > 0) {
const prefix = `${picocolors.yellow('DEPRECATION WARNING:')}`;
console.warn(`\n${prefix} --experimental-tags is deprecated, please start using --tags instead`);
logWarning('DEPRECATION WARNING', '--experimental-tags is deprecated, please start using --tags instead');
}
if (isIsolateWorkspaces && report.classMembers) {
logWarning('WARNING', 'Class members are not tracked when using the --isolate-workspaces flag');
}
if (!noExitCode && totalErrorCount > Number(maxIssues)) {

@@ -94,4 +96,3 @@ process.exit(1);

const knownError = getKnownError(error);
const prefix = `${picocolors.red('ERROR:')}`;
console.error(`${prefix} ${knownError.message}`);
logError('ERROR', knownError.message);
if (hasCause(knownError))

@@ -98,0 +99,0 @@ console.error('Reason:', knownError.cause.message);

@@ -157,2 +157,3 @@ import type { Configuration, IgnorePatterns, WorkspaceConfiguration } from './types/config.js';

drizzle?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
glob?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
entry: string[];

@@ -159,0 +160,0 @@ project: string[];

@@ -109,5 +109,7 @@ import { watch } from 'node:fs';

const deps = new Set();
debugLogArray(name, 'Definition paths', definitionPaths);
for (const id of definitionPaths)
deps.add(toProductionEntry(id, { containingFilePath: tsConfigFilePath }));
if (definitionPaths.length > 0) {
debugLogArray(name, 'Definition paths', definitionPaths);
for (const id of definitionPaths)
deps.add(toProductionEntry(id, { containingFilePath: tsConfigFilePath }));
}
const ignore = worker.getIgnorePatterns();

@@ -117,3 +119,2 @@ const sharedGlobOptions = { cwd, dir, gitignore };

const entryPathsFromManifest = await getEntryPathsFromManifest(manifest, { ...sharedGlobOptions, ignore });
debugLogArray(name, 'Entry paths in package.json', entryPathsFromManifest);
for (const id of entryPathsFromManifest.map(id => toProductionEntry(id)))

@@ -159,17 +160,17 @@ deps.add(id);

{
const label = 'entry';
const patterns = worker.getProductionEntryFilePatterns(negatedEntryPatterns);
const workspaceEntryPaths = await _glob({ ...sharedGlobOptions, patterns, gitignore: false });
debugLogArray(name, 'Entry paths', workspaceEntryPaths);
const workspaceEntryPaths = await _glob({ ...sharedGlobOptions, patterns, gitignore: false, label });
principal.addEntryPaths(workspaceEntryPaths);
}
{
const label = 'production plugin entry';
const patterns = Array.from(productionEntryFilePatterns);
const pluginWorkspaceEntryPaths = await _glob({ ...sharedGlobOptions, patterns });
debugLogArray(name, 'Production plugin entry paths', pluginWorkspaceEntryPaths);
const pluginWorkspaceEntryPaths = await _glob({ ...sharedGlobOptions, patterns, label });
principal.addEntryPaths(pluginWorkspaceEntryPaths, { skipExportsAnalysis: true });
}
{
const label = 'project';
const patterns = worker.getProductionProjectFilePatterns(negatedEntryPatterns);
const workspaceProjectPaths = await _glob({ ...sharedGlobOptions, patterns });
debugLogArray(name, 'Project paths', workspaceProjectPaths);
const workspaceProjectPaths = await _glob({ ...sharedGlobOptions, patterns, label });
for (const projectPath of workspaceProjectPaths)

@@ -181,11 +182,11 @@ principal.addProjectPath(projectPath);

{
const label = 'entry';
const patterns = worker.getEntryFilePatterns();
const workspaceEntryPaths = await _glob({ ...sharedGlobOptions, patterns, gitignore: false });
debugLogArray(name, 'Entry paths', workspaceEntryPaths);
const workspaceEntryPaths = await _glob({ ...sharedGlobOptions, patterns, gitignore: false, label });
principal.addEntryPaths(workspaceEntryPaths);
}
{
const label = 'project';
const patterns = worker.getProjectFilePatterns([...productionEntryFilePatterns]);
const workspaceProjectPaths = await _glob({ ...sharedGlobOptions, patterns });
debugLogArray(name, 'Project paths', workspaceProjectPaths);
const workspaceProjectPaths = await _glob({ ...sharedGlobOptions, patterns, label });
for (const projectPath of workspaceProjectPaths)

@@ -195,11 +196,11 @@ principal.addProjectPath(projectPath);

{
const label = 'plugin entry';
const patterns = worker.getPluginEntryFilePatterns([...entryFilePatterns, ...productionEntryFilePatterns]);
const pluginWorkspaceEntryPaths = await _glob({ ...sharedGlobOptions, patterns });
debugLogArray(name, 'Plugin entry paths', pluginWorkspaceEntryPaths);
const pluginWorkspaceEntryPaths = await _glob({ ...sharedGlobOptions, patterns, label });
principal.addEntryPaths(pluginWorkspaceEntryPaths, { skipExportsAnalysis: true });
}
{
const label = 'plugin project';
const patterns = worker.getPluginProjectFilePatterns();
const pluginWorkspaceProjectPaths = await _glob({ ...sharedGlobOptions, patterns });
debugLogArray(name, 'Plugin project paths', pluginWorkspaceProjectPaths);
const pluginWorkspaceProjectPaths = await _glob({ ...sharedGlobOptions, patterns, label });
for (const projectPath of pluginWorkspaceProjectPaths)

@@ -209,5 +210,5 @@ principal.addProjectPath(projectPath);

{
const label = 'plugin configuration';
const patterns = worker.getPluginConfigPatterns();
const configurationEntryPaths = await _glob({ ...sharedGlobOptions, patterns });
debugLogArray(name, 'Plugin configuration paths', configurationEntryPaths);
const configurationEntryPaths = await _glob({ ...sharedGlobOptions, patterns, label });
principal.addEntryPaths(configurationEntryPaths, { skipExportsAnalysis: true });

@@ -214,0 +215,0 @@ }

@@ -7,2 +7,3 @@ import type { IsPluginEnabled, ResolveConfig } from '../../types/config.js';

isEnabled: IsPluginEnabled;
isRootOnly: true;
config: string[];

@@ -9,0 +10,0 @@ resolveConfig: ResolveConfig<ChangesetsConfig>;

@@ -6,2 +6,3 @@ import { toDependency } from '../../util/input.js';

const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
const isRootOnly = true;
const config = ['.changeset/config.json'];

@@ -19,4 +20,5 @@ const resolveConfig = config => {

isEnabled,
isRootOnly,
config,
resolveConfig,
};

@@ -7,2 +7,3 @@ import type { IsPluginEnabled, ResolveConfig } from '../../types/config.js';

isEnabled: IsPluginEnabled;
isRootOnly: true;
packageJsonPath: string;

@@ -9,0 +10,0 @@ config: string[];

@@ -6,2 +6,3 @@ import { toDependency } from '../../util/input.js';

const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
const isRootOnly = true;
const packageJsonPath = 'config.commitizen';

@@ -16,2 +17,3 @@ const config = ['.czrc', '.cz.json', 'package.json'];

isEnabled,
isRootOnly,
packageJsonPath,

@@ -18,0 +20,0 @@ config,

@@ -6,2 +6,3 @@ import type { IsPluginEnabled, ResolveConfig } from '../../types/config.js';

isEnabled: IsPluginEnabled;
isRootOnly: true;
config: string[];

@@ -8,0 +9,0 @@ resolveConfig: ResolveConfig;

@@ -8,2 +8,3 @@ import { _firstGlob } from '../../util/glob.js';

const isEnabled = async ({ cwd }) => Boolean(await _firstGlob({ cwd, patterns: ['.github/workflows/*.{yml,yaml}'] }));
const isRootOnly = true;
const config = ['.github/workflows/*.{yml,yaml}', '.github/**/action.{yml,yaml}'];

@@ -45,4 +46,5 @@ const isString = (value) => typeof value === 'string';

isEnabled,
isRootOnly,
config,
resolveConfig,
};

@@ -6,2 +6,3 @@ import type { IsPluginEnabled, ResolveConfig } from '../../types/config.js';

isEnabled: IsPluginEnabled;
isRootOnly: true;
config: string[];

@@ -8,0 +9,0 @@ resolveConfig: ResolveConfig;

@@ -7,2 +7,3 @@ import { getGitHookPaths } from '../../util/git.js';

const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
const isRootOnly = true;
const gitHookPaths = getGitHookPaths('.husky', false);

@@ -26,4 +27,5 @@ const config = [...gitHookPaths, 'package.json'];

isEnabled,
isRootOnly,
config,
resolveConfig,
};

@@ -53,2 +53,3 @@ export declare const Plugins: {

isEnabled: import("../types/config.js").IsPluginEnabled;
isRootOnly: true;
config: string[];

@@ -61,2 +62,3 @@ resolveConfig: import("../types/config.js").ResolveConfig<import("./changesets/types.js").ChangesetsConfig>;

isEnabled: import("../types/config.js").IsPluginEnabled;
isRootOnly: true;
packageJsonPath: string;

@@ -141,5 +143,17 @@ config: string[];

isEnabled: import("../types/config.js").IsPluginEnabled;
isRootOnly: true;
config: string[];
resolveConfig: import("../types/config.js").ResolveConfig;
};
glob: {
title: string;
args: {
binaries: string[];
positional: boolean;
alias: {
cmd: string[];
};
fromArgs: string[];
};
};
'graphql-codegen': {

@@ -157,2 +171,3 @@ title: string;

isEnabled: import("../types/config.js").IsPluginEnabled;
isRootOnly: true;
config: string[];

@@ -454,2 +469,3 @@ resolveConfig: import("../types/config.js").ResolveConfig;

isEnabled: import("../types/config.js").IsPluginEnabled;
isRootOnly: true;
packageJsonPath: string;

@@ -526,2 +542,3 @@ config: string[];

isEnabled: import("../types/config.js").IsPluginEnabled;
isRootOnly: true;
config: string[];

@@ -528,0 +545,0 @@ resolveConfig: import("../types/config.js").ResolveConfig;

@@ -19,2 +19,3 @@ import { default as angular } from './angular/index.js';

import { default as githubActions } from './github-actions/index.js';
import { default as glob } from './glob/index.js';
import { default as graphqlCodegen } from './graphql-codegen/index.js';

@@ -105,2 +106,3 @@ import { default as husky } from './husky/index.js';

'github-actions': githubActions,
glob,
'graphql-codegen': graphqlCodegen,

@@ -107,0 +109,0 @@ husky,

@@ -7,2 +7,3 @@ import type { IsPluginEnabled, ResolveConfig } from '../../types/config.js';

isEnabled: IsPluginEnabled;
isRootOnly: true;
packageJsonPath: string;

@@ -9,0 +10,0 @@ config: string[];

@@ -7,2 +7,3 @@ import { toDeferResolve } from '../../util/input.js';

const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
const isRootOnly = true;
const packageJsonPath = 'release';

@@ -18,2 +19,3 @@ const config = ['package.json', ...toCosmiconfig('release')];

isEnabled,
isRootOnly,
packageJsonPath,

@@ -20,0 +22,0 @@ config,

@@ -6,2 +6,3 @@ import type { IsPluginEnabled, ResolveConfig } from '../../types/config.js';

isEnabled: IsPluginEnabled;
isRootOnly: true;
config: string[];

@@ -8,0 +9,0 @@ resolveConfig: ResolveConfig;

@@ -5,2 +5,3 @@ import { _glob } from '../../util/glob.js';

const isEnabled = async ({ cwd }) => (await _glob({ cwd, patterns: ['.travis.yml'] })).length > 0;
const isRootOnly = true;
const config = ['.travis.yml'];

@@ -20,4 +21,5 @@ const resolveConfig = async (config, options) => {

isEnabled,
isRootOnly,
config,
resolveConfig,
};

@@ -237,3 +237,12 @@ import ts from 'typescript';

.flatMap(refs => refs.references)
.filter(ref => !ref.isDefinition && ref.fileName !== filePath);
.filter(ref => !ref.isDefinition && ref.fileName !== filePath)
.filter(ref => {
const sourceFile = this.backend.program?.getSourceFile(ref.fileName);
if (!sourceFile)
return true;
const node = ts.getTokenAtPosition(sourceFile, ref.textSpan.start);
if (!node?.parent?.parent?.parent)
return true;
return !(ts.isExportSpecifier(node.parent) && node.parent.parent.parent.moduleSpecifier);
});
return externalRefs.length > 0;

@@ -240,0 +249,0 @@ }

@@ -99,2 +99,3 @@ import type { z } from 'zod';

isEnabled?: IsPluginEnabled;
isRootOnly?: boolean;
config?: string[];

@@ -101,0 +102,0 @@ entry?: string[];

@@ -1,2 +0,2 @@

export type PluginName = 'angular' | 'astro' | 'ava' | 'babel' | 'c8' | 'capacitor' | 'changesets' | 'commitizen' | 'commitlint' | 'cspell' | 'cucumber' | 'cypress' | 'dotenv' | 'drizzle' | 'eleventy' | 'eslint' | 'gatsby' | 'github-actions' | 'graphql-codegen' | 'husky' | 'jest' | 'ladle' | 'lefthook' | 'lint-staged' | 'linthtml' | 'lockfile-lint' | 'lost-pixel' | 'markdownlint' | 'mocha' | 'moonrepo' | 'msw' | 'nest' | 'netlify' | 'next' | 'node' | 'node-test-runner' | 'nodemon' | 'npm-package-json-lint' | 'nuxt' | 'nx' | 'nyc' | 'oclif' | 'playwright' | 'playwright-ct' | 'playwright-test' | 'postcss' | 'preconstruct' | 'prettier' | 'react-cosmos' | 'release-it' | 'remark' | 'remix' | 'rollup' | 'rsbuild' | 'rspack' | 'semantic-release' | 'sentry' | 'simple-git-hooks' | 'size-limit' | 'storybook' | 'stryker' | 'stylelint' | 'svelte' | 'syncpack' | 'tailwind' | 'travis' | 'ts-node' | 'tsup' | 'tsx' | 'typedoc' | 'typescript' | 'unbuild' | 'unocss' | 'vercel-og' | 'vike' | 'vite' | 'vitest' | 'vue' | 'webdriver-io' | 'webpack' | 'wireit' | 'wrangler' | 'xo' | 'yorkie';
export declare const pluginNames: readonly ["angular", "astro", "ava", "babel", "c8", "capacitor", "changesets", "commitizen", "commitlint", "cspell", "cucumber", "cypress", "dotenv", "drizzle", "eleventy", "eslint", "gatsby", "github-actions", "graphql-codegen", "husky", "jest", "ladle", "lefthook", "lint-staged", "linthtml", "lockfile-lint", "lost-pixel", "markdownlint", "mocha", "moonrepo", "msw", "nest", "netlify", "next", "node", "node-test-runner", "nodemon", "npm-package-json-lint", "nuxt", "nx", "nyc", "oclif", "playwright", "playwright-ct", "playwright-test", "postcss", "preconstruct", "prettier", "react-cosmos", "release-it", "remark", "remix", "rollup", "rsbuild", "rspack", "semantic-release", "sentry", "simple-git-hooks", "size-limit", "storybook", "stryker", "stylelint", "svelte", "syncpack", "tailwind", "travis", "ts-node", "tsup", "tsx", "typedoc", "typescript", "unbuild", "unocss", "vercel-og", "vike", "vite", "vitest", "vue", "webdriver-io", "webpack", "wireit", "wrangler", "xo", "yorkie"];
export type PluginName = 'angular' | 'astro' | 'ava' | 'babel' | 'c8' | 'capacitor' | 'changesets' | 'commitizen' | 'commitlint' | 'cspell' | 'cucumber' | 'cypress' | 'dotenv' | 'drizzle' | 'eleventy' | 'eslint' | 'gatsby' | 'github-actions' | 'glob' | 'graphql-codegen' | 'husky' | 'jest' | 'ladle' | 'lefthook' | 'lint-staged' | 'linthtml' | 'lockfile-lint' | 'lost-pixel' | 'markdownlint' | 'mocha' | 'moonrepo' | 'msw' | 'nest' | 'netlify' | 'next' | 'node' | 'node-test-runner' | 'nodemon' | 'npm-package-json-lint' | 'nuxt' | 'nx' | 'nyc' | 'oclif' | 'playwright' | 'playwright-ct' | 'playwright-test' | 'postcss' | 'preconstruct' | 'prettier' | 'react-cosmos' | 'release-it' | 'remark' | 'remix' | 'rollup' | 'rsbuild' | 'rspack' | 'semantic-release' | 'sentry' | 'simple-git-hooks' | 'size-limit' | 'storybook' | 'stryker' | 'stylelint' | 'svelte' | 'syncpack' | 'tailwind' | 'travis' | 'ts-node' | 'tsup' | 'tsx' | 'typedoc' | 'typescript' | 'unbuild' | 'unocss' | 'vercel-og' | 'vike' | 'vite' | 'vitest' | 'vue' | 'webdriver-io' | 'webpack' | 'wireit' | 'wrangler' | 'xo' | 'yorkie';
export declare const pluginNames: readonly ["angular", "astro", "ava", "babel", "c8", "capacitor", "changesets", "commitizen", "commitlint", "cspell", "cucumber", "cypress", "dotenv", "drizzle", "eleventy", "eslint", "gatsby", "github-actions", "glob", "graphql-codegen", "husky", "jest", "ladle", "lefthook", "lint-staged", "linthtml", "lockfile-lint", "lost-pixel", "markdownlint", "mocha", "moonrepo", "msw", "nest", "netlify", "next", "node", "node-test-runner", "nodemon", "npm-package-json-lint", "nuxt", "nx", "nyc", "oclif", "playwright", "playwright-ct", "playwright-test", "postcss", "preconstruct", "prettier", "react-cosmos", "release-it", "remark", "remix", "rollup", "rsbuild", "rspack", "semantic-release", "sentry", "simple-git-hooks", "size-limit", "storybook", "stryker", "stylelint", "svelte", "syncpack", "tailwind", "travis", "ts-node", "tsup", "tsx", "typedoc", "typescript", "unbuild", "unocss", "vercel-og", "vike", "vite", "vitest", "vue", "webdriver-io", "webpack", "wireit", "wrangler", "xo", "yorkie"];

@@ -20,2 +20,3 @@ export const pluginNames = [

'github-actions',
'glob',
'graphql-codegen',

@@ -22,0 +23,0 @@ 'husky',

@@ -10,2 +10,1 @@ export declare const isDirectory: (filePath: string) => boolean;

export declare const parseYAML: (contents: string) => unknown;
export declare const _loadJSON: (filePath: string) => Promise<any>;

@@ -6,3 +6,2 @@ import { statSync } from 'node:fs';

import stripJsonComments from 'strip-json-comments';
import { timerify } from './Performance.js';
import { LoaderError } from './errors.js';

@@ -62,2 +61,1 @@ import { join } from './path.js';

};
export const _loadJSON = timerify(loadJSON);

@@ -10,2 +10,3 @@ import { type Options as FastGlobOptions } from 'fast-glob';

readonly dir: string;
label?: string;
} & FastGlobOptionsWithoutCwd;

@@ -26,4 +27,4 @@ type FastGlobOptionsWithoutCwd = Pick<FastGlobOptions, 'onlyDirectories' | 'ignore' | 'absolute' | 'dot'>;

}>;
export declare function globby(patterns: string | string[], options: GlobOptions): Promise<string[]>;
export declare function glob(patterns: string | string[], options: GlobOptions): Promise<string[]>;
export declare function getGitIgnoredHandler(options: Options): Promise<(path: string) => boolean>;
export {};

@@ -8,2 +8,3 @@ import { readFileSync } from 'node:fs';

import { timerify } from './Performance.js';
import { compact } from './array.js';
import { debugLogObject } from './debug.js';

@@ -14,3 +15,4 @@ import { isFile } from './fs.js';

const _picomatch = timerify(picomatch);
const cachedIgnores = new Map();
const cachedGitIgnores = new Map();
const cachedGlobIgnores = new Map();
export const convertGitignoreToPicomatchIgnorePatterns = (pattern) => {

@@ -131,3 +133,3 @@ const negated = pattern[0] === '!';

const cacheDir = ancestor ? cwd : dir;
const cacheForDir = cachedIgnores.get(cwd);
const cacheForDir = cachedGitIgnores.get(cwd);
if (ancestor && cacheForDir) {

@@ -139,3 +141,3 @@ for (const pattern of dirIgnores)

else {
cachedIgnores.set(cacheDir, { ignores: dirIgnores, unignores: Array.from(dirUnignores) });
cachedGitIgnores.set(cacheDir, { ignores: dirIgnores, unignores: Array.from(dirUnignores) });
}

@@ -160,32 +162,41 @@ for (const pattern of dirIgnores)

});
debugLogObject('*', 'Parsed gitignore files', { gitignoreFiles, ignores, unignores });
debugLogObject('*', 'Parsed gitignore files', { gitignoreFiles });
return { gitignoreFiles, ignores, unignores };
};
const _parseFindGitignores = timerify(findAndParseGitignores);
export async function globby(patterns, options) {
export async function glob(patterns, options) {
if (Array.isArray(patterns) && patterns.length === 0)
return [];
const ignore = options.gitignore && Array.isArray(options.ignore) ? [...options.ignore] : [];
const canCache = options.label && options.gitignore;
const willCache = canCache && !cachedGlobIgnores.has(options.dir);
const cachedIgnores = canCache && cachedGlobIgnores.get(options.dir);
const _ignore = options.gitignore && Array.isArray(options.ignore) ? [...options.ignore] : [];
if (options.gitignore) {
let dir = options.dir;
let prev;
while (dir) {
const cacheForDir = cachedIgnores.get(dir);
if (cacheForDir) {
ignore.push(...cacheForDir.ignores);
if (willCache) {
let dir = options.dir;
let prev;
while (dir) {
const cacheForDir = cachedGitIgnores.get(dir);
if (cacheForDir) {
_ignore.push(...cacheForDir.ignores);
}
dir = dirname((prev = dir));
if (prev === dir || dir === '.')
break;
}
dir = dirname((prev = dir));
if (prev === dir || dir === '.')
break;
}
}
else {
ignore.push(...GLOBAL_IGNORE_PATTERNS);
_ignore.push(...GLOBAL_IGNORE_PATTERNS);
}
const fgOptions = Object.assign(options, { ignore });
debugLogObject(relative(options.cwd, options.dir) || ROOT_WORKSPACE_NAME, 'Glob options', { patterns, ...fgOptions });
return fg.glob(patterns, fgOptions);
const ignore = cachedIgnores || compact(_ignore);
const { dir, label, ...fgOptions } = { ...options, ignore };
const paths = await fg.glob(patterns, fgOptions);
debugLogObject(relative(options.cwd, options.dir) || ROOT_WORKSPACE_NAME, label ? `Finding ${label} paths` : 'Finding paths', () => ({ patterns, ...fgOptions, ignore: cachedIgnores ? `identical to ${dir} ↑` : ignore, paths }));
if (willCache)
cachedGlobIgnores.set(options.dir, ignore);
return paths;
}
export async function getGitIgnoredHandler(options) {
cachedIgnores.clear();
cachedGitIgnores.clear();
if (options.gitignore === false)

@@ -192,0 +203,0 @@ return () => false;

@@ -6,2 +6,4 @@ interface GlobOptions {

gitignore?: boolean;
name?: boolean;
label?: string;
}

@@ -12,5 +14,5 @@ export declare const prependDirToPattern: (dir: string, pattern: string) => string;

export declare const hasNoProductionSuffix: (pattern: string) => boolean;
export declare const _glob: ({ cwd, dir, patterns, gitignore }: GlobOptions) => Promise<string[]>;
export declare const _glob: ({ cwd, dir, patterns, gitignore, label }: GlobOptions) => Promise<string[]>;
export declare const _firstGlob: ({ cwd, patterns }: GlobOptions) => Promise<string | Buffer | undefined>;
export declare const _dirGlob: ({ cwd, patterns, gitignore }: GlobOptions) => Promise<string[]>;
export {};

@@ -5,8 +5,8 @@ import fg from 'fast-glob';

import { compact } from './array.js';
import { globby } from './glob-core.js';
import { glob } from './glob-core.js';
import { isAbsolute, join, relative } from './path.js';
const prepend = (pattern, relativePath) => isAbsolute(pattern.replace(/^!/, '')) ? pattern : prependDirToPattern(relativePath, pattern);
const prependDirToPatterns = (cwd, dir, patterns) => {
const relativePath = relative(cwd, dir);
const prepend = (pattern) => isAbsolute(pattern.replace(/^!/, '')) ? pattern : prependDirToPattern(relativePath, pattern);
return compact([patterns].flat().map(prepend).map(removeProductionSuffix)).sort(negatedLast);
return compact([patterns].flat().map(p => removeProductionSuffix(prepend(p, relativePath)))).sort(negatedLast);
};

@@ -23,3 +23,3 @@ const removeProductionSuffix = (pattern) => pattern.replace(/!$/, '');

export const hasNoProductionSuffix = (pattern) => !pattern.endsWith('!');
const glob = async ({ cwd, dir = cwd, patterns, gitignore = true }) => {
const defaultGlob = async ({ cwd, dir = cwd, patterns, gitignore = true, label }) => {
if (patterns.length === 0)

@@ -30,3 +30,3 @@ return [];

return [];
return globby(globPatterns, {
return glob(globPatterns, {
cwd,

@@ -37,2 +37,3 @@ dir,

dot: true,
label,
});

@@ -46,3 +47,3 @@ };

};
const dirGlob = async ({ cwd, patterns, gitignore = true }) => globby(patterns, {
const dirGlob = async ({ cwd, patterns, gitignore = true }) => glob(patterns, {
cwd,

@@ -53,4 +54,4 @@ dir: cwd,

});
export const _glob = timerify(glob);
export const _glob = timerify(defaultGlob);
export const _firstGlob = timerify(firstGlob);
export const _dirGlob = timerify(dirGlob);

@@ -57,3 +57,3 @@ import { readFile, writeFile } from 'node:fs/promises';

entryPaths.add(typings);
return _glob({ ...sharedGlobOptions, patterns: Array.from(entryPaths) });
return _glob({ ...sharedGlobOptions, patterns: Array.from(entryPaths), label: 'package.json entry' });
};

@@ -1,2 +0,1 @@

export { _loadJSON as loadJSON } from './fs.js';
export { _load as load } from './loader.js';

@@ -3,0 +2,0 @@ import type { Plugin, PluginOptions, RawPluginConfiguration } from '../types/config.js';

@@ -1,2 +0,1 @@

export { _loadJSON as loadJSON } from './fs.js';
export { _load as load } from './loader.js';

@@ -3,0 +2,0 @@ import { arrayify } from './array.js';

@@ -1,1 +0,1 @@

export declare const version = "5.36.3";
export declare const version = "5.36.4";

@@ -1,1 +0,1 @@

export const version = '5.36.3';
export const version = '5.36.4';

@@ -57,2 +57,4 @@ import { CacheConsultant } from './CacheConsultant.js';

continue;
if (this.cwd !== this.dir && plugin.isRootOnly)
continue;
if (this.config[pluginName]) {

@@ -69,6 +71,3 @@ this.enabledPluginsMap[pluginName] = true;

}
const enabledPlugins = getKeysByValue(this.enabledPluginsMap, true);
const enabledPluginTitles = enabledPlugins.map(name => Plugins[name].title);
debugLogObject(this.name, 'Enabled plugins', enabledPluginTitles);
return enabledPlugins;
return getKeysByValue(this.enabledPluginsMap, true);
}

@@ -212,3 +211,4 @@ getConfigForPlugin(pluginName) {

return;
const configFilePaths = await _glob({ patterns, cwd: baseScriptOptions.rootCwd, dir: cwd, gitignore: false });
const label = 'config file';
const configFilePaths = await _glob({ patterns, cwd: rootCwd, dir: cwd, gitignore: false, label });
const remainingConfigFilePaths = configFilePaths.filter(filePath => !this.allConfigFilePaths.has(filePath));

@@ -218,4 +218,2 @@ for (const f of remainingConfigFilePaths)

this.allConfigFilePaths.add(f);
if (configFilePaths.length > 0)
debugLogArray([name, plugin.title], 'config file paths', configFilePaths);
const options = {

@@ -282,2 +280,4 @@ ...baseScriptOptions,

};
const enabledPluginTitles = this.enabledPlugins.map(name => Plugins[name].title);
debugLogObject(this.name, 'Enabled plugins', enabledPluginTitles);
for (const pluginName of this.enabledPlugins) {

@@ -284,0 +284,0 @@ const patterns = [...this.getConfigurationFilePatterns(pluginName), ...(configFiles.get(pluginName) ?? [])];

{
"name": "knip",
"version": "5.36.3",
"version": "5.36.4",
"description": "Find unused files, dependencies and exports in your TypeScript and JavaScript projects",

@@ -5,0 +5,0 @@ "homepage": "https://knip.dev",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc