knip 2.15.1 → 2.15.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.
@@ -1,8 +1,9 @@
1
+ /// <reference types="npmcli__package-json" />
1
2
  import { Workspace } from './ConfigurationChief.js';
2
3
  import type { ConfigurationHints, Issue } from './types/issues.js';
3
4
  import type { WorkspaceManifests } from './types/workspace.js';
4
5
  import type { PeerDependencies, InstalledBinaries } from './types/workspace.js';
5
- import type { PackageJson } from 'type-fest';
6
+ import type { PackageJson } from '@npmcli/package-json';
6
7
  type Options = {
7
8
  isStrict: boolean;
8
9
  };
@@ -1,12 +1,12 @@
1
+ import { PackageJsonWithPlugins } from './types/plugins.js';
1
2
  import { InstalledBinaries, PeerDependencies } from './types/workspace.js';
2
3
  import type { Configuration, PluginName, WorkspaceConfiguration } from './types/config.js';
3
- import type { PackageJson } from 'type-fest';
4
4
  type WorkspaceManagerOptions = {
5
5
  name: string;
6
6
  dir: string;
7
7
  cwd: string;
8
8
  config: WorkspaceConfiguration;
9
- manifest: PackageJson;
9
+ manifest: PackageJsonWithPlugins;
10
10
  rootIgnore: Configuration['ignore'];
11
11
  negatedWorkspacePatterns: string[];
12
12
  enabledPluginsInAncestors: string[];
@@ -19,7 +19,7 @@ export declare class WorkspaceWorker {
19
19
  dir: string;
20
20
  cwd: string;
21
21
  config: WorkspaceConfiguration;
22
- manifest: PackageJson;
22
+ manifest: PackageJsonWithPlugins;
23
23
  isProduction: boolean;
24
24
  isStrict: boolean;
25
25
  rootIgnore: Configuration['ignore'];
@@ -1,4 +1,4 @@
1
- import type { PackageJson } from 'type-fest';
1
+ import type { PackageJson } from '@npmcli/package-json';
2
2
  export declare const getBinariesFromScript: (script: string, { cwd, manifest, knownGlobalsOnly }: {
3
3
  cwd: string;
4
4
  manifest: PackageJson;
@@ -1,4 +1,5 @@
1
- import type { PackageJson } from 'type-fest';
1
+ /// <reference types="npmcli__package-json" />
2
+ import type { PackageJson } from '@npmcli/package-json';
2
3
  type Options = {
3
4
  cwd?: string;
4
5
  manifest?: PackageJson;
package/dist/constants.js CHANGED
@@ -15,6 +15,7 @@ export const IGNORED_GLOBAL_BINARIES = [
15
15
  'npx',
16
16
  'pnpm',
17
17
  'pnpx',
18
+ 'true',
18
19
  'yarn',
19
20
  'cat',
20
21
  'cd',
@@ -1,5 +1,6 @@
1
+ /// <reference types="npmcli__package-json" />
1
2
  import type { InstalledBinaries, PeerDependencies } from '../types/workspace.js';
2
- import type { PackageJson } from 'type-fest';
3
+ import type { PackageJson } from '@npmcli/package-json';
3
4
  type Options = {
4
5
  manifest: PackageJson;
5
6
  isProduction: boolean;
@@ -1,5 +1,6 @@
1
+ /// <reference types="npmcli__package-json" />
1
2
  import type { ESLintConfig } from './types.js';
2
- import type { PackageJson } from 'type-fest';
3
+ import type { PackageJson } from '@npmcli/package-json';
3
4
  type Manifest = PackageJson & {
4
5
  eslintConfig?: ESLintConfig;
5
6
  };
@@ -6,14 +6,23 @@ import { _resolve } from '../../util/require.js';
6
6
  import { fallback } from './fallback.js';
7
7
  const getDependencies = (config) => {
8
8
  const extendsSpecifiers = config.extends ? [config.extends].flat().map(resolveExtendsSpecifier) : [];
9
- const plugins = config.plugins ? config.plugins.map(resolvePluginPackageName) : [];
10
9
  if (extendsSpecifiers.includes('eslint-plugin-prettier'))
11
10
  extendsSpecifiers.push('eslint-config-prettier');
11
+ const plugins = config.plugins ? config.plugins.map(resolvePluginPackageName) : [];
12
12
  const parser = config.parser;
13
+ const extraPlugins = config.parserOptions?.babelOptions?.plugins ?? [];
13
14
  const extraParsers = config.parserOptions?.babelOptions?.presets ?? [];
14
15
  const settings = config.settings ? getDependenciesFromSettings(config.settings) : [];
15
16
  const overrides = config.overrides ? [config.overrides].flat().flatMap(getDependencies) : [];
16
- return compact([...extendsSpecifiers, ...plugins, parser, ...extraParsers, ...settings, ...overrides]);
17
+ return compact([
18
+ ...extendsSpecifiers,
19
+ ...plugins,
20
+ ...extraPlugins,
21
+ parser,
22
+ ...extraParsers,
23
+ ...settings,
24
+ ...overrides,
25
+ ]);
17
26
  };
18
27
  export const getDependenciesDeep = async (configFilePath, dependencies = new Set(), options) => {
19
28
  const addAll = (deps) => deps.forEach(dependency => dependencies.add(dependency));
@@ -54,7 +63,7 @@ const resolveExtendsSpecifier = (specifier) => {
54
63
  return specifier;
55
64
  const strippedSpecifier = specifier
56
65
  .replace(/(^plugin:|:.+$)/, '')
57
- .replace(/\/(eslint-)?(recommended.*|strict|all)$/, '');
66
+ .replace(/\/(eslint-)?(recommended.*|stylistic.*|strict.*|all)$/, '');
58
67
  if (/eslint-(config|plugin)-/.test(strippedSpecifier))
59
68
  return strippedSpecifier;
60
69
  const packageName = getPackageNameFromModuleSpecifier(strippedSpecifier);
@@ -1,6 +1,7 @@
1
1
  type ParserOptions = {
2
2
  project?: string;
3
3
  babelOptions?: {
4
+ plugins: string[];
4
5
  presets: string[];
5
6
  };
6
7
  };
@@ -40,9 +40,9 @@ const findJestDependencies = async (configFilePath, { cwd, manifest }) => {
40
40
  const transform = config.transform
41
41
  ? Object.values(config.transform).map(transform => (typeof transform === 'string' ? transform : transform[0]))
42
42
  : [];
43
- const moduleNameMapper = config.moduleNameMapper
43
+ const moduleNameMapper = (config.moduleNameMapper
44
44
  ? Object.values(config.moduleNameMapper).map(mapper => (typeof mapper === 'string' ? mapper : mapper[0]))
45
- : [];
45
+ : []).filter(value => !/\$[0-9]/.test(value));
46
46
  return [
47
47
  ...presets,
48
48
  ...environments,
@@ -1,5 +1,7 @@
1
+ /// <reference types="npmcli__package-json" />
1
2
  import type { PluginConfiguration } from './config.js';
2
- import type { PackageJson } from 'type-fest';
3
+ import type { PackageJson } from '@npmcli/package-json';
4
+ export type PackageJsonWithPlugins = PackageJson & Record<string, unknown>;
3
5
  type IsPluginEnabledCallbackOptions = {
4
6
  cwd: string;
5
7
  manifest: PackageJson;
@@ -8,7 +10,7 @@ type IsPluginEnabledCallbackOptions = {
8
10
  export type IsPluginEnabledCallback = (options: IsPluginEnabledCallbackOptions) => boolean | Promise<boolean>;
9
11
  type GenericPluginCallbackOptions = {
10
12
  cwd: string;
11
- manifest: PackageJson;
13
+ manifest: PackageJsonWithPlugins;
12
14
  config: PluginConfiguration;
13
15
  isProduction: boolean;
14
16
  };
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "2.15.1";
1
+ export declare const version = "2.15.4";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '2.15.1';
1
+ export const version = '2.15.4';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "2.15.1",
3
+ "version": "2.15.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",
@@ -70,8 +70,8 @@
70
70
  "@types/node": "20.4.1",
71
71
  "@types/npmcli__map-workspaces": "3.0.1",
72
72
  "@types/webpack": "5.28.1",
73
- "@typescript-eslint/eslint-plugin": "5.61.0",
74
- "@typescript-eslint/parser": "5.61.0",
73
+ "@typescript-eslint/eslint-plugin": "6.0.0",
74
+ "@typescript-eslint/parser": "6.0.0",
75
75
  "c8": "8.0.0",
76
76
  "eslint": "8.44.0",
77
77
  "eslint-import-resolver-typescript": "3.5.5",
package/schema.json CHANGED
@@ -46,6 +46,34 @@
46
46
  "examples": ["classMembers", "enumMembers"],
47
47
  "$ref": "#/definitions/issueTypes"
48
48
  },
49
+ "ignoreExportsUsedInFile": {
50
+ "title": "Ignore exports used in file",
51
+ "examples": [
52
+ { "ignoreExportsUsedInFile": true },
53
+ {
54
+ "ignoreExportsUsedInFile": {
55
+ "interface": true,
56
+ "type": true
57
+ }
58
+ }
59
+ ],
60
+ "anyOf": [
61
+ {
62
+ "type": "boolean"
63
+ },
64
+ {
65
+ "type": "object",
66
+ "properties": {
67
+ "class": { "type": "boolean" },
68
+ "enum": { "type": "boolean" },
69
+ "function": { "type": "boolean" },
70
+ "interface": { "type": "boolean" },
71
+ "member": { "type": "boolean" },
72
+ "type": { "type": "boolean" }
73
+ }
74
+ }
75
+ ]
76
+ },
49
77
  "workspaces": {
50
78
  "title": "Configuration for workspaces",
51
79
  "type": "object",