knip 2.15.2 → 2.15.5

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
@@ -103,7 +103,7 @@ import type { KnipConfig } from 'knip';
103
103
 
104
104
  const config: KnipConfig = {
105
105
  entry: ['src/index.ts'],
106
- project: ['src/**/*.ts']
106
+ project: ['src/**/*.ts'],
107
107
  };
108
108
 
109
109
  export default config;
@@ -476,8 +476,8 @@ import { compileSync } from 'mdx-js/mdx';
476
476
 
477
477
  export default {
478
478
  compilers: {
479
- mdx: compileSync
480
- }
479
+ mdx: compileSync,
480
+ },
481
481
  };
482
482
  ```
483
483
 
@@ -17,7 +17,7 @@ export declare class DependencyDeputy {
17
17
  ignoreBinaries: string[];
18
18
  ignoreDependencies: string[];
19
19
  constructor({ isStrict }: Options);
20
- addWorkspace({ name, dir, manifestPath, manifest, ignoreDependencies, ignoreBinaries }: {
20
+ addWorkspace({ name, dir, manifestPath, manifest, ignoreDependencies, ignoreBinaries, }: {
21
21
  name: string;
22
22
  dir: string;
23
23
  manifestPath: string;
@@ -1,5 +1,5 @@
1
1
  import { isBuiltin } from 'node:module';
2
- import { IGNORE_DEFINITELY_TYPED, IGNORED_DEPENDENCIES, IGNORED_GLOBAL_BINARIES, ROOT_WORKSPACE_NAME } from './constants.js';
2
+ import { IGNORE_DEFINITELY_TYPED, IGNORED_DEPENDENCIES, IGNORED_GLOBAL_BINARIES, ROOT_WORKSPACE_NAME, } from './constants.js';
3
3
  import { isDefinitelyTyped, getDefinitelyTypedFor, getPackageFromDefinitelyTyped } from './util/modules.js';
4
4
  export class DependencyDeputy {
5
5
  isStrict;
@@ -17,7 +17,7 @@ export class DependencyDeputy {
17
17
  this.peerDependencies = new Map();
18
18
  this.installedBinaries = new Map();
19
19
  }
20
- addWorkspace({ name, dir, manifestPath, manifest, ignoreDependencies, ignoreBinaries }) {
20
+ addWorkspace({ name, dir, manifestPath, manifest, ignoreDependencies, ignoreBinaries, }) {
21
21
  const scripts = Object.values(manifest.scripts ?? {});
22
22
  const dependencies = Object.keys(manifest.dependencies ?? {});
23
23
  const peerDependencies = Object.keys(manifest.peerDependencies ?? {});
@@ -34,7 +34,7 @@ export class DependencyDeputy {
34
34
  peerDependencies,
35
35
  optionalDependencies,
36
36
  devDependencies,
37
- allDependencies
37
+ allDependencies,
38
38
  });
39
39
  }
40
40
  addIgnored(ignoreBinaries, ignoreDependencies) {
@@ -30,7 +30,7 @@ export declare class WorkspaceWorker {
30
30
  referencedDependencies: ReferencedDependencies;
31
31
  peerDependencies: PeerDependencies;
32
32
  installedBinaries: InstalledBinaries;
33
- constructor({ name, dir, cwd, config, manifest, isProduction, isStrict, rootIgnore, negatedWorkspacePatterns, enabledPluginsInAncestors }: WorkspaceManagerOptions);
33
+ constructor({ name, dir, cwd, config, manifest, isProduction, isStrict, rootIgnore, negatedWorkspacePatterns, enabledPluginsInAncestors, }: WorkspaceManagerOptions);
34
34
  init(): Promise<void>;
35
35
  private setEnabledPlugins;
36
36
  private initReferencedDependencies;
@@ -22,7 +22,7 @@ export class WorkspaceWorker {
22
22
  referencedDependencies = new Set();
23
23
  peerDependencies = new Map();
24
24
  installedBinaries = new Map();
25
- constructor({ name, dir, cwd, config, manifest, isProduction, isStrict, rootIgnore, negatedWorkspacePatterns, enabledPluginsInAncestors }) {
25
+ constructor({ name, dir, cwd, config, manifest, isProduction, isStrict, rootIgnore, negatedWorkspacePatterns, enabledPluginsInAncestors, }) {
26
26
  this.name = name;
27
27
  this.dir = dir;
28
28
  this.cwd = cwd;
@@ -63,7 +63,7 @@ export class WorkspaceWorker {
63
63
  isProduction: this.isProduction,
64
64
  isStrict: this.isStrict,
65
65
  dir: this.dir,
66
- cwd: this.cwd
66
+ cwd: this.cwd,
67
67
  });
68
68
  const filePath = join(this.dir, 'package.json');
69
69
  dependencies.forEach(dependency => this.referencedDependencies.add([filePath, dependency]));
@@ -92,7 +92,7 @@ export class WorkspaceWorker {
92
92
  negatedPluginEntryFilePatterns,
93
93
  negatedPluginProjectFilePatterns,
94
94
  TEST_FILE_PATTERNS,
95
- this.negatedWorkspacePatterns
95
+ this.negatedWorkspacePatterns,
96
96
  ].flat();
97
97
  }
98
98
  getPluginEntryFilePatterns(isIncludeProductionEntryFiles = true) {
@@ -167,7 +167,7 @@ export class WorkspaceWorker {
167
167
  negatedPluginEntryFilePatterns,
168
168
  negatedPluginProjectFilePatterns,
169
169
  negatedTestFilePatterns,
170
- this.negatedWorkspacePatterns
170
+ this.negatedWorkspacePatterns,
171
171
  ].flat();
172
172
  }
173
173
  getProductionPluginEntryFilePatterns() {
@@ -218,7 +218,7 @@ export class WorkspaceWorker {
218
218
  cwd,
219
219
  manifest: this.manifest,
220
220
  config: pluginConfig,
221
- isProduction: this.isProduction
221
+ isProduction: this.isProduction,
222
222
  });
223
223
  dependencies.map(toPosix).forEach(specifier => {
224
224
  pluginDependencies.add(specifier);
@@ -237,7 +237,7 @@ export class WorkspaceWorker {
237
237
  peerDependencies: this.peerDependencies,
238
238
  installedBinaries: this.installedBinaries,
239
239
  referencedDependencies: this.referencedDependencies,
240
- enabledPlugins: this.enabledPlugins
240
+ enabledPlugins: this.enabledPlugins,
241
241
  };
242
242
  }
243
243
  }
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',
@@ -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));
@@ -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
  };
@@ -6,6 +6,7 @@ export const NAME = 'husky';
6
6
  export const ENABLERS = ['husky'];
7
7
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
8
8
  export const CONFIG_FILE_PATTERNS = [
9
+ '.husky/prepare-commit-msg',
9
10
  '.husky/commit-msg',
10
11
  '.husky/pre-{applypatch,commit,merge-commit,push,rebase,receive}',
11
12
  '.husky/post-{checkout,commit,merge,rewrite}',
@@ -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,
@@ -3,4 +3,7 @@ export const NAME = 'Next.js';
3
3
  export const ENABLERS = ['next'];
4
4
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
5
5
  export const ENTRY_FILE_PATTERNS = ['next.config.{js,ts,cjs,mjs}'];
6
- export const PRODUCTION_ENTRY_FILE_PATTERNS = ['pages/**/*.{js,jsx,ts,tsx}', 'src/pages/**/*.{js,jsx,ts,tsx}'];
6
+ export const PRODUCTION_ENTRY_FILE_PATTERNS = [
7
+ '{app,pages}/**/*.{js,jsx,ts,tsx}',
8
+ 'src/{app,pages}/**/*.{js,jsx,ts,tsx}',
9
+ ];
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "2.15.2";
1
+ export declare const version = "2.15.5";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '2.15.2';
1
+ export const version = '2.15.5';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "2.15.2",
3
+ "version": "2.15.5",
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",
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",