knip 2.2.2 → 2.2.4

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/README.md CHANGED
@@ -211,7 +211,7 @@ There are a few ways to tell Knip to ignore certain packages, binaries, dependen
211
211
  "ignore": ["**/*.d.ts", "**/fixtures"],
212
212
  "ignoreBinaries": ["zip", "docker-compose"],
213
213
  "ignoreDependencies": ["hidden-package"],
214
- "ignoreWorkspaces": ["packages/deno-lib"]
214
+ "ignoreWorkspaces": ["packages/ignore", "packages/examples/**"]
215
215
  }
216
216
  ```
217
217
 
package/dist/index.js CHANGED
@@ -201,6 +201,9 @@ export const main = async (unresolvedConfiguration) => {
201
201
  importedModule.isReExported = importItems.isReExported;
202
202
  importedModule.isReExportedBy.add(filePath);
203
203
  }
204
+ if (importItems.isDynamic) {
205
+ importedModule.isDynamic = importItems.isDynamic;
206
+ }
204
207
  }
205
208
  }
206
209
  duplicate.forEach(symbols => {
@@ -1,4 +1,5 @@
1
1
  import { compact } from '../../util/array.js';
2
+ import { getPackageNameFromModuleSpecifier } from '../../util/modules.js';
2
3
  import { isAbsolute, isInternal, join, dirname } from '../../util/path.js';
3
4
  import { load } from '../../util/plugin.js';
4
5
  import { _resolve } from '../../util/require.js';
@@ -11,7 +12,8 @@ const getDependencies = (config) => {
11
12
  const parser = config.parser;
12
13
  const extraParsers = config.parserOptions?.babelOptions?.presets ?? [];
13
14
  const settings = config.settings ? getDependenciesFromSettings(config.settings) : [];
14
- return compact([...extendsSpecifiers, ...plugins, parser, ...extraParsers, ...settings]);
15
+ const overrides = config.overrides ? [config.overrides].flat().flatMap(getDependencies) : [];
16
+ return compact([...extendsSpecifiers, ...plugins, parser, ...extraParsers, ...settings, ...overrides]);
15
17
  };
16
18
  export const getDependenciesDeep = async (configFilePath, dependencies = new Set(), options) => {
17
19
  const addAll = (deps) => deps.forEach(dependency => dependencies.add(dependency));
@@ -41,9 +43,6 @@ export const getDependenciesDeep = async (configFilePath, dependencies = new Set
41
43
  }
42
44
  }
43
45
  }
44
- if (config.overrides)
45
- for (const override of [config.overrides].flat())
46
- addAll(getDependencies(override));
47
46
  addAll(getDependencies(config));
48
47
  }
49
48
  return dependencies;
@@ -60,9 +59,12 @@ const resolveExtendsSpecifier = (specifier) => {
60
59
  if (isInternal(specifier))
61
60
  return;
62
61
  if (specifier.includes(':')) {
63
- const pluginName = specifier.replace(/^plugin:/, '').replace(/(\/|:).+$/, '');
62
+ const strippedSpecifier = specifier.replace(/(^plugin:|:.+$)/, '').replace(/\/(eslint-)?recommended$/, '');
63
+ const pluginName = getPackageNameFromModuleSpecifier(strippedSpecifier);
64
64
  if (pluginName === 'eslint')
65
65
  return;
66
+ if (pluginName.includes('eslint-'))
67
+ return pluginName;
66
68
  return resolvePackageName('eslint-plugin', pluginName);
67
69
  }
68
70
  return specifier.includes('eslint') ? specifier : resolvePackageName('eslint-config', specifier);
@@ -15,8 +15,9 @@ type BaseConfig = {
15
15
  settings?: Settings;
16
16
  rules?: Rules;
17
17
  };
18
- type OverrideConfig = BaseConfig & {
18
+ export type OverrideConfig = BaseConfig & {
19
19
  files: string[];
20
+ overrides: OverrideConfig;
20
21
  };
21
22
  export type ESLintConfig = BaseConfig & {
22
23
  env?: Record<string, boolean>;
@@ -1,6 +1,6 @@
1
1
  import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
2
2
  export declare const NAME = "Nx";
3
- export declare const ENABLERS: RegExp[];
3
+ export declare const ENABLERS: (string | RegExp)[];
4
4
  export declare const isEnabled: IsPluginEnabledCallback;
5
5
  export declare const CONFIG_FILE_PATTERNS: string[];
6
6
  export declare const findDependencies: GenericPluginCallback;
@@ -3,9 +3,9 @@ import { compact } from '../../util/array.js';
3
3
  import { timerify } from '../../util/Performance.js';
4
4
  import { hasDependency, load } from '../../util/plugin.js';
5
5
  export const NAME = 'Nx';
6
- export const ENABLERS = [/^@nrwl\//];
6
+ export const ENABLERS = ['nx', /^@nrwl\//];
7
7
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
8
- export const CONFIG_FILE_PATTERNS = ['{apps,libs}/**/project.json'];
8
+ export const CONFIG_FILE_PATTERNS = ['project.json', '{apps,libs}/**/project.json'];
9
9
  const findNxDependencies = async (configFilePath, { cwd, manifest }) => {
10
10
  const config = await load(configFilePath);
11
11
  if (!config)
@@ -17,8 +17,8 @@ const findNxDependencies = async (configFilePath, { cwd, manifest }) => {
17
17
  .map(executor => executor?.split(':')[0]));
18
18
  const scripts = compact(targets
19
19
  .filter(target => target.executor === 'nx:run-commands')
20
- .flatMap(target => (target.options?.commands ?? target.options?.command ? [target.options.command] : [])));
21
- const dependencies = _getDependenciesFromScripts(scripts, { cwd, manifest, knownGlobalsOnly: true });
20
+ .flatMap(target => target.options?.commands ?? (target.options?.command ? [target.options.command] : [])));
21
+ const dependencies = _getDependenciesFromScripts(scripts, { cwd, manifest });
22
22
  return [...executors, ...dependencies];
23
23
  };
24
24
  export const findDependencies = timerify(findNxDependencies);
@@ -1,5 +1,5 @@
1
1
  type BuiltinEnvironment = 'node' | 'jsdom' | 'happy-dom' | 'edge-runtime';
2
2
  type VitestEnvironment = BuiltinEnvironment | (string & Record<never, never>);
3
3
  export declare const getEnvPackageName: (env: VitestEnvironment) => any;
4
- export declare const getExternalReporters: (reporters?: string[]) => string[];
4
+ export declare const getExternalReporters: (reporters?: string | string[]) => string[];
5
5
  export {};
@@ -17,4 +17,4 @@ export const getEnvPackageName = (env) => {
17
17
  return `vitest-environment-${env}`;
18
18
  };
19
19
  const builtInReporters = ['default', 'verbose', 'dot', 'json', 'tap', 'tap-flat', 'junit', 'hanging-process'];
20
- export const getExternalReporters = (reporters) => reporters ? reporters.filter(reporter => !builtInReporters.includes(reporter)) : [];
20
+ export const getExternalReporters = (reporters) => reporters ? [reporters].flat().filter(reporter => !builtInReporters.includes(reporter)) : [];
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "2.2.2";
1
+ export declare const version = "2.2.4";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '2.2.2';
1
+ export const version = '2.2.4';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "2.2.2",
3
+ "version": "2.2.4",
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",
@@ -62,7 +62,7 @@
62
62
  "@jest/types": "29.5.0",
63
63
  "@npmcli/package-json": "3.0.0",
64
64
  "@release-it/bumper": "4.0.2",
65
- "@types/eslint": "8.21.3",
65
+ "@types/eslint": "8.37.0",
66
66
  "@types/js-yaml": "4.0.5",
67
67
  "@types/micromatch": "4.0.2",
68
68
  "@types/minimist": "1.2.2",