knip 2.38.6 → 2.40.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/constants.js CHANGED
@@ -5,6 +5,7 @@ export const GLOBAL_IGNORE_PATTERNS = ['**/node_modules/**', '.yarn'];
5
5
  export const IGNORED_GLOBAL_BINARIES = [
6
6
  'bash',
7
7
  'bun',
8
+ 'bunx',
8
9
  'cat',
9
10
  'cd',
10
11
  'chmod',
@@ -12,6 +13,7 @@ export const IGNORED_GLOBAL_BINARIES = [
12
13
  'curl',
13
14
  'deno',
14
15
  'dirname',
16
+ 'docker',
15
17
  'echo',
16
18
  'exec',
17
19
  'exit',
package/dist/index.js CHANGED
@@ -6,7 +6,6 @@ import { DependencyDeputy } from './DependencyDeputy.js';
6
6
  import { IssueCollector } from './IssueCollector.js';
7
7
  import { PrincipalFactory } from './PrincipalFactory.js';
8
8
  import { ProjectPrincipal } from './ProjectPrincipal.js';
9
- import { compact } from './util/array.js';
10
9
  import { debugLogObject, debugLogArray, debugLog } from './util/debug.js';
11
10
  import { _glob, negate } from './util/glob.js';
12
11
  import { getEntryPathFromManifest, getPackageNameFromFilePath, getPackageNameFromModuleSpecifier, normalizeSpecifierFromFilePath, } from './util/modules.js';
@@ -161,7 +160,7 @@ export const main = async (unresolvedConfiguration) => {
161
160
  pluginWorkspaceProjectPaths.forEach(projectPath => principal.addProjectPath(projectPath));
162
161
  }
163
162
  {
164
- const patterns = compact(worker.getPluginConfigPatterns());
163
+ const patterns = worker.getPluginConfigPatterns();
165
164
  const configurationEntryPaths = await _glob({ ...sharedGlobOptions, patterns });
166
165
  debugLogArray(name, `Plugin configuration paths`, configurationEntryPaths);
167
166
  principal.addEntryPaths(configurationEntryPaths, { skipExportsAnalysis: true });
@@ -6,8 +6,12 @@ export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABL
6
6
  export const ENTRY_FILE_PATTERNS = ['astro.config.{js,cjs,mjs,ts}', 'src/content/config.ts'];
7
7
  export const PRODUCTION_ENTRY_FILE_PATTERNS = ['src/pages/**/*.{astro,mdx,js,ts}', 'src/content/**/*.mdx'];
8
8
  export const findDependencies = async (configFilePath, options) => {
9
- const { config } = options;
10
- return config.entry
9
+ const { config, manifest } = options;
10
+ const dependencies = config.entry
11
11
  ? config.entry.map(toProductionEntryPattern)
12
12
  : [...ENTRY_FILE_PATTERNS.map(toEntryPattern), ...PRODUCTION_ENTRY_FILE_PATTERNS.map(toProductionEntryPattern)];
13
+ if (manifest.scripts && Object.values(manifest.scripts).some(script => /astro (--.+ )?check/.test(script))) {
14
+ dependencies.push('@astrojs/check');
15
+ }
16
+ return dependencies;
13
17
  };
@@ -71,7 +71,7 @@ export const resolveExtendSpecifier = (specifier) => {
71
71
  return resolveSpecifier(namespace, specifier);
72
72
  };
73
73
  const getDependenciesFromSettings = (settings = {}) => {
74
- return compact(Object.entries(settings).flatMap(([settingKey, settings]) => {
74
+ return Object.entries(settings).flatMap(([settingKey, settings]) => {
75
75
  if (settingKey === 'import/resolver') {
76
76
  return (typeof settings === 'string' ? [settings] : Object.keys(settings))
77
77
  .filter(key => key !== 'node')
@@ -80,5 +80,5 @@ const getDependenciesFromSettings = (settings = {}) => {
80
80
  if (settingKey === 'import/parsers') {
81
81
  return typeof settings === 'string' ? [settings] : Object.keys(settings);
82
82
  }
83
- }));
83
+ });
84
84
  };
@@ -14,14 +14,14 @@ const findNxDependencies = async (configFilePath, options) => {
14
14
  if (!localConfig)
15
15
  return [];
16
16
  const targets = localConfig.targets ? Object.values(localConfig.targets) : [];
17
- const executors = compact(targets
17
+ const executors = targets
18
18
  .map(target => target?.executor)
19
19
  .filter(executor => executor && !executor.startsWith('.'))
20
- .map(executor => executor?.split(':')[0]));
21
- const scripts = compact(targets
20
+ .map(executor => executor?.split(':')[0]);
21
+ const scripts = targets
22
22
  .filter(target => target.executor === 'nx:run-commands')
23
- .flatMap(target => target.options?.commands ?? (target.options?.command ? [target.options.command] : [])));
23
+ .flatMap(target => target.options?.commands ?? (target.options?.command ? [target.options.command] : []));
24
24
  const dependencies = _getDependenciesFromScripts(scripts, { cwd, manifest });
25
- return [...executors, ...dependencies];
25
+ return compact([...executors, ...dependencies]);
26
26
  };
27
27
  export const findDependencies = timerify(findNxDependencies);
@@ -1,3 +1,4 @@
1
+ import { compact } from '../../util/array.js';
1
2
  import { timerify } from '../../util/Performance.js';
2
3
  import { hasDependency, load } from '../../util/plugin.js';
3
4
  import { toEntryPattern } from '../../util/protocols.js';
@@ -45,6 +46,6 @@ const findVitestWorkspaceDependencies = async (configFilePath, options) => {
45
46
  (await findVitestDependencies(config, options)).forEach(dependency => dependencies.add(dependency));
46
47
  }
47
48
  }
48
- return Array.from(dependencies);
49
+ return compact(dependencies);
49
50
  };
50
51
  export const findDependencies = timerify(findVitestWorkspaceDependencies);
@@ -1,2 +1,4 @@
1
- export declare const compact: <T>(collection: (T | undefined)[]) => T[];
1
+ type Collection<T> = Array<T> | Set<T>;
2
+ export declare const compact: <T>(collection: Collection<T | undefined>) => T[];
2
3
  export declare const arrayify: (value?: string[] | string) => string[];
4
+ export {};
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "2.38.6";
1
+ export declare const version = "2.40.0";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '2.38.6';
1
+ export const version = '2.40.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "2.38.6",
3
+ "version": "2.40.0",
4
4
  "description": "Find unused files, dependencies and exports in your TypeScript and JavaScript projects",
5
5
  "homepage": "https://github.com/webpro/knip",
6
6
  "repository": "github:webpro/knip",