knip 5.24.0 → 5.24.1

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.
@@ -13,7 +13,7 @@ export declare const pluginSchema: z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodSt
13
13
  project?: string | string[] | undefined;
14
14
  }>]>;
15
15
  export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShape<z.objectUtil.extendShape<z.objectUtil.extendShape<{
16
- rules: z.ZodOptional<z.ZodRecord<z.ZodUnion<[z.ZodLiteral<"files">, z.ZodLiteral<"dependencies">, z.ZodLiteral<"devDependencies">, z.ZodLiteral<"unlisted">, z.ZodLiteral<"binaries">, z.ZodLiteral<"unresolved">, z.ZodLiteral<"exports">, z.ZodLiteral<"types">, z.ZodLiteral<"nsExports">, z.ZodLiteral<"nsTypes">, z.ZodLiteral<"duplicates">, z.ZodLiteral<"enumMembers">, z.ZodLiteral<"classMembers">]>, z.ZodEnum<["error", "warn", "off"]>>>;
16
+ rules: z.ZodOptional<z.ZodRecord<z.ZodUnion<[z.ZodLiteral<"files">, z.ZodLiteral<"dependencies">, z.ZodLiteral<"devDependencies">, z.ZodLiteral<"optionalPeerDependencies">, z.ZodLiteral<"unlisted">, z.ZodLiteral<"binaries">, z.ZodLiteral<"unresolved">, z.ZodLiteral<"exports">, z.ZodLiteral<"types">, z.ZodLiteral<"nsExports">, z.ZodLiteral<"nsTypes">, z.ZodLiteral<"duplicates">, z.ZodLiteral<"enumMembers">, z.ZodLiteral<"classMembers">]>, z.ZodEnum<["error", "warn", "off"]>>>;
17
17
  entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
18
18
  project: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
19
19
  paths: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
@@ -28,8 +28,8 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
28
28
  syncCompilers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodFunction<z.ZodTuple<[z.ZodString, z.ZodString], z.ZodUnknown>, z.ZodString>>>;
29
29
  asyncCompilers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodFunction<z.ZodTuple<[z.ZodString, z.ZodString], z.ZodUnknown>, z.ZodPromise<z.ZodString>>>>;
30
30
  }, {
31
- include: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodLiteral<"files">, z.ZodLiteral<"dependencies">, z.ZodLiteral<"devDependencies">, z.ZodLiteral<"unlisted">, z.ZodLiteral<"binaries">, z.ZodLiteral<"unresolved">, z.ZodLiteral<"exports">, z.ZodLiteral<"types">, z.ZodLiteral<"nsExports">, z.ZodLiteral<"nsTypes">, z.ZodLiteral<"duplicates">, z.ZodLiteral<"enumMembers">, z.ZodLiteral<"classMembers">]>, "many">>;
32
- exclude: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodLiteral<"files">, z.ZodLiteral<"dependencies">, z.ZodLiteral<"devDependencies">, z.ZodLiteral<"unlisted">, z.ZodLiteral<"binaries">, z.ZodLiteral<"unresolved">, z.ZodLiteral<"exports">, z.ZodLiteral<"types">, z.ZodLiteral<"nsExports">, z.ZodLiteral<"nsTypes">, z.ZodLiteral<"duplicates">, z.ZodLiteral<"enumMembers">, z.ZodLiteral<"classMembers">]>, "many">>;
31
+ include: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodLiteral<"files">, z.ZodLiteral<"dependencies">, z.ZodLiteral<"devDependencies">, z.ZodLiteral<"optionalPeerDependencies">, z.ZodLiteral<"unlisted">, z.ZodLiteral<"binaries">, z.ZodLiteral<"unresolved">, z.ZodLiteral<"exports">, z.ZodLiteral<"types">, z.ZodLiteral<"nsExports">, z.ZodLiteral<"nsTypes">, z.ZodLiteral<"duplicates">, z.ZodLiteral<"enumMembers">, z.ZodLiteral<"classMembers">]>, "many">>;
32
+ exclude: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodLiteral<"files">, z.ZodLiteral<"dependencies">, z.ZodLiteral<"devDependencies">, z.ZodLiteral<"optionalPeerDependencies">, z.ZodLiteral<"unlisted">, z.ZodLiteral<"binaries">, z.ZodLiteral<"unresolved">, z.ZodLiteral<"exports">, z.ZodLiteral<"types">, z.ZodLiteral<"nsExports">, z.ZodLiteral<"nsTypes">, z.ZodLiteral<"duplicates">, z.ZodLiteral<"enumMembers">, z.ZodLiteral<"classMembers">]>, "many">>;
33
33
  }>, {
34
34
  workspaces: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<z.objectUtil.extendShape<{
35
35
  entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
@@ -2474,9 +2474,9 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
2474
2474
  project?: string | string[] | undefined;
2475
2475
  }>]>>;
2476
2476
  }>, "strip", z.ZodTypeAny, {
2477
- exclude?: ("dependencies" | "exports" | "files" | "devDependencies" | "unlisted" | "binaries" | "unresolved" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers")[] | undefined;
2478
- include?: ("dependencies" | "exports" | "files" | "devDependencies" | "unlisted" | "binaries" | "unresolved" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers")[] | undefined;
2479
- rules?: Partial<Record<"dependencies" | "exports" | "files" | "devDependencies" | "unlisted" | "binaries" | "unresolved" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers", "error" | "warn" | "off">> | undefined;
2477
+ exclude?: ("dependencies" | "exports" | "files" | "devDependencies" | "optionalPeerDependencies" | "unlisted" | "binaries" | "unresolved" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers")[] | undefined;
2478
+ include?: ("dependencies" | "exports" | "files" | "devDependencies" | "optionalPeerDependencies" | "unlisted" | "binaries" | "unresolved" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers")[] | undefined;
2479
+ rules?: Partial<Record<"dependencies" | "exports" | "files" | "devDependencies" | "optionalPeerDependencies" | "unlisted" | "binaries" | "unresolved" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers", "error" | "warn" | "off">> | undefined;
2480
2480
  entry?: string | string[] | undefined;
2481
2481
  project?: string | string[] | undefined;
2482
2482
  paths?: Record<string, string[]> | undefined;
@@ -3171,9 +3171,9 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
3171
3171
  } | undefined;
3172
3172
  }> | undefined;
3173
3173
  }, {
3174
- exclude?: ("dependencies" | "exports" | "files" | "devDependencies" | "unlisted" | "binaries" | "unresolved" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers")[] | undefined;
3175
- include?: ("dependencies" | "exports" | "files" | "devDependencies" | "unlisted" | "binaries" | "unresolved" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers")[] | undefined;
3176
- rules?: Partial<Record<"dependencies" | "exports" | "files" | "devDependencies" | "unlisted" | "binaries" | "unresolved" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers", "error" | "warn" | "off">> | undefined;
3174
+ exclude?: ("dependencies" | "exports" | "files" | "devDependencies" | "optionalPeerDependencies" | "unlisted" | "binaries" | "unresolved" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers")[] | undefined;
3175
+ include?: ("dependencies" | "exports" | "files" | "devDependencies" | "optionalPeerDependencies" | "unlisted" | "binaries" | "unresolved" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers")[] | undefined;
3176
+ rules?: Partial<Record<"dependencies" | "exports" | "files" | "devDependencies" | "optionalPeerDependencies" | "unlisted" | "binaries" | "unresolved" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers", "error" | "warn" | "off">> | undefined;
3177
3177
  entry?: string | string[] | undefined;
3178
3178
  project?: string | string[] | undefined;
3179
3179
  paths?: Record<string, string[]> | undefined;
@@ -10,6 +10,7 @@ const issueTypeSchema = z.union([
10
10
  z.literal('files'),
11
11
  z.literal('dependencies'),
12
12
  z.literal('devDependencies'),
13
+ z.literal('optionalPeerDependencies'),
13
14
  z.literal('unlisted'),
14
15
  z.literal('binaries'),
15
16
  z.literal('unresolved'),
@@ -40,7 +40,7 @@ export class IssueCollector {
40
40
  if (this.isMatch(filePath))
41
41
  continue;
42
42
  this.issues.files.add(filePath);
43
- this.issues._files.add({ type: 'files', filePath, symbol: relative(filePath) });
43
+ this.issues._files.add({ type: 'files', filePath, symbol: relative(filePath), severity: this.rules.files });
44
44
  this.counters.files++;
45
45
  this.counters.processed++;
46
46
  }
@@ -4,9 +4,9 @@ import type { AsyncCompilerFn, AsyncCompilers, SyncCompilerFn, SyncCompilers } f
4
4
  export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
5
5
  syncCompilers: Record<string, SyncCompilerFn>;
6
6
  asyncCompilers: Record<string, AsyncCompilerFn>;
7
- exclude?: ("dependencies" | "exports" | "files" | "devDependencies" | "unlisted" | "binaries" | "unresolved" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers")[] | undefined;
8
- include?: ("dependencies" | "exports" | "files" | "devDependencies" | "unlisted" | "binaries" | "unresolved" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers")[] | undefined;
9
- rules?: Partial<Record<"dependencies" | "exports" | "files" | "devDependencies" | "unlisted" | "binaries" | "unresolved" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers", "error" | "warn" | "off">> | undefined;
7
+ exclude?: ("dependencies" | "exports" | "files" | "devDependencies" | "optionalPeerDependencies" | "unlisted" | "binaries" | "unresolved" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers")[] | undefined;
8
+ include?: ("dependencies" | "exports" | "files" | "devDependencies" | "optionalPeerDependencies" | "unlisted" | "binaries" | "unresolved" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers")[] | undefined;
9
+ rules?: Partial<Record<"dependencies" | "exports" | "files" | "devDependencies" | "optionalPeerDependencies" | "unlisted" | "binaries" | "unresolved" | "types" | "nsExports" | "nsTypes" | "duplicates" | "enumMembers" | "classMembers", "error" | "warn" | "off">> | undefined;
10
10
  entry?: string | string[] | undefined;
11
11
  project?: string | string[] | undefined;
12
12
  paths?: Record<string, string[]> | undefined;
@@ -36,6 +36,8 @@ export default ({ report, issues, tagHints, configurationHints, noConfigHints, i
36
36
  const relPath = toRelative(issue.filePath);
37
37
  if (issue.isFixed)
38
38
  console.log(picocolors.gray(`${relPath} (deleted)`));
39
+ else if (issue.severity === 'warn')
40
+ console.log(picocolors.gray(relPath));
39
41
  else
40
42
  console.log(relPath);
41
43
  }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -7,7 +7,6 @@ import { _load as load } from './loader.js';
7
7
  import { get } from './object.js';
8
8
  import { basename } from './path.js';
9
9
  import { toEntryPattern, toProductionEntryPattern } from './protocols.js';
10
- import { _loadESLintConfig as loadESLintConfig } from './require.js';
11
10
  export const toCamelCase = (name) => name.toLowerCase().replace(/(-[a-z])/g, group => group.toUpperCase().replace('-', ''));
12
11
  export const hasDependency = (dependencies, values) => values.some(value => {
13
12
  if (typeof value === 'string') {
@@ -44,10 +43,7 @@ export const loadConfigForPlugin = async (configFilePath, plugin, options, plugi
44
43
  ? typeof packageJsonPath === 'function'
45
44
  ? packageJsonPath(manifest)
46
45
  : get(manifest, packageJsonPath ?? pluginName)
47
- :
48
- plugin.title === 'ESLint' && !/(\.(jsonc?|ya?ml)|rc)$/.test(configFilePath)
49
- ? await loadESLintConfig(configFilePath)
50
- : await load(configFilePath);
46
+ : await load(configFilePath);
51
47
  return localConfig;
52
48
  };
53
49
  export const getFinalEntryPaths = (plugin, options, configEntryPaths) => {
@@ -1,9 +1,16 @@
1
+ import { fileURLToPath } from 'node:url';
1
2
  import createJITI, {} from 'jiti';
2
3
  import { DEFAULT_EXTENSIONS } from '../constants.js';
4
+ import { join } from './path.js';
5
+ const empty = join(fileURLToPath(import.meta.url), '../empty.js');
3
6
  const options = {
4
7
  interopDefault: true,
5
8
  extensions: DEFAULT_EXTENSIONS,
6
9
  esmResolve: false,
10
+ alias: {
11
+ '@rushstack/eslint-config/patch/modern-module-resolution': empty,
12
+ '@rushstack/eslint-patch/modern-module-resolution': empty,
13
+ },
7
14
  };
8
15
  const createLoader = (options) => createJITI(process.cwd(), options);
9
16
  export const jitiCJS = createLoader(options);
@@ -1,5 +1,4 @@
1
1
  export declare const _require: NodeRequire;
2
- export declare const _loadESLintConfig: (configFilePath: string) => any;
3
2
  export declare const _resolve: (specifier: string) => string;
4
3
  export declare const _tryResolve: (specifier: string, from: string) => string | undefined;
5
4
  export declare const _resolveSpecifier: (dir: string, specifier: string) => string | undefined;
@@ -1,7 +1,6 @@
1
1
  import { createRequire as nodeCreateRequire } from 'node:module';
2
2
  import { pathToFileURL } from 'node:url';
3
3
  import createJITI from 'jiti';
4
- import transform from 'jiti/dist/babel.js';
5
4
  import { timerify } from './Performance.js';
6
5
  import { debugLog } from './debug.js';
7
6
  import { getPackageNameFromModuleSpecifier } from './modules.js';
@@ -32,18 +31,6 @@ const resolveSpecifier = (dir, specifier) => {
32
31
  }
33
32
  }
34
33
  };
35
- const rushstackMatch = /require\(("|')@rushstack\/(eslint-config\/patch|eslint-patch)\/modern-module-resolution("|')\)/;
36
- const jiti = createJITI(process.cwd(), {
37
- cache: false,
38
- transform: (opts) => {
39
- opts.source = opts.source.replace(rushstackMatch, '');
40
- return transform(opts);
41
- },
42
- });
43
- const loadESLintConfig = (configFilePath) => {
44
- return jiti(configFilePath);
45
- };
46
- export const _loadESLintConfig = timerify(loadESLintConfig);
47
34
  export const _resolve = timerify(resolve);
48
35
  export const _tryResolve = timerify(tryResolve);
49
36
  export const _resolveSpecifier = timerify(resolveSpecifier);
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "5.24.0";
1
+ export declare const version = "5.24.1";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '5.24.0';
1
+ export const version = '5.24.1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "5.24.0",
3
+ "version": "5.24.1",
4
4
  "description": "Find unused files, dependencies and exports in your TypeScript and JavaScript projects",
5
5
  "homepage": "https://knip.dev",
6
6
  "repository": {