knip 5.66.1 → 5.66.3

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.
@@ -163,7 +163,7 @@ export const analyze = async ({ analyzedFiles, chief, collector, deputy, entryPa
163
163
  for (const [filePath, file] of graph.entries()) {
164
164
  const ws = chief.findWorkspaceByFilePath(filePath);
165
165
  if (ws) {
166
- if (file.duplicates) {
166
+ if (file.duplicates && options.includedIssueTypes.duplicates) {
167
167
  for (const symbols of file.duplicates) {
168
168
  if (symbols.length > 1) {
169
169
  const symbol = symbols.map(s => s.symbol).join('|');
@@ -78,7 +78,8 @@ export async function build({ chief, collector, deputy, factory, isGitIgnored, s
78
78
  collector.addIgnorePatterns(config.ignore.map(p => join(options.cwd, prependDirToPattern(name, p))));
79
79
  collector.addIgnoreFilesPatterns(config.ignoreFiles.map(p => join(options.cwd, prependDirToPattern(name, p))));
80
80
  const entrySpecifiersFromManifest = getEntrySpecifiersFromManifest(manifest);
81
- for (const filePath of await toSourceFilePaths(entrySpecifiersFromManifest, dir, extensionGlobStr)) {
81
+ const label = 'entry paths from package.json';
82
+ for (const filePath of await toSourceFilePaths(entrySpecifiersFromManifest, dir, extensionGlobStr, label)) {
82
83
  inputs.add(toProductionEntry(filePath));
83
84
  }
84
85
  for (const identifier of entrySpecifiersFromManifest) {
package/dist/index.d.ts CHANGED
@@ -1,6 +1,4 @@
1
1
  import type { MainOptions } from './util/create-options.js';
2
- export type { RawConfiguration as KnipConfig } from './types/config.js';
3
- export type { Preprocessor, Reporter, ReporterOptions } from './types/issues.js';
4
2
  export declare const main: (options: MainOptions) => Promise<{
5
3
  issues: import("./types/issues.js").Issues;
6
4
  counters: import("./types/issues.js").Counters;
@@ -7,7 +7,7 @@ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
7
7
  const config = ['next.config.{js,ts,cjs,mjs}'];
8
8
  const defaultPageExtensions = ['{js,jsx,ts,tsx}'];
9
9
  const productionEntryFilePatterns = [
10
- '{instrumentation,instrumentation-client,middleware}.{js,ts}',
10
+ '{instrumentation,instrumentation-client,middleware,proxy}.{js,ts}',
11
11
  'app/global-error.{js,jsx,ts,tsx}',
12
12
  'app/**/{error,layout,loading,not-found,page,template,default}.{js,jsx,ts,tsx}',
13
13
  'app/**/route.{js,jsx,ts,tsx}',
@@ -1,25 +1,25 @@
1
- import { toEntry } from '../../util/input.js';
1
+ import { toProductionEntry } from '../../util/input.js';
2
2
  import { hasDependency } from '../../util/plugin.js';
3
3
  const title = 'Rsbuild';
4
4
  const enablers = ['@rsbuild/core'];
5
5
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
6
6
  const config = ['rsbuild*.config.{mjs,ts,js,cjs,mts,cts}'];
7
7
  const resolveConfig = async (config) => {
8
- const inputs = new Set();
8
+ const entries = new Set();
9
9
  const checkSource = (source) => {
10
10
  if (source?.entry) {
11
11
  for (const entry of Object.values(source.entry)) {
12
12
  if (typeof entry === 'string')
13
- inputs.add(toEntry(entry));
13
+ entries.add(entry);
14
14
  else if (Array.isArray(entry))
15
15
  for (const e of entry)
16
- inputs.add(toEntry(e));
16
+ entries.add(e);
17
17
  else {
18
18
  if (typeof entry.import === 'string')
19
- inputs.add(toEntry(entry.import));
19
+ entries.add(entry.import);
20
20
  else if (Array.isArray(entry.import))
21
21
  for (const e of entry.import)
22
- inputs.add(toEntry(e));
22
+ entries.add(e);
23
23
  }
24
24
  }
25
25
  }
@@ -30,7 +30,7 @@ const resolveConfig = async (config) => {
30
30
  checkSource(environment.source);
31
31
  }
32
32
  }
33
- return Array.from(inputs);
33
+ return Array.from(entries).map(input => toProductionEntry(input));
34
34
  };
35
35
  export default {
36
36
  title,
@@ -16,6 +16,7 @@ export const getEnvPackageName = (env) => {
16
16
  };
17
17
  const builtInReporters = [
18
18
  'basic',
19
+ 'blob',
19
20
  'default',
20
21
  'dot',
21
22
  'github-actions',
@@ -25,6 +26,7 @@ const builtInReporters = [
25
26
  'junit',
26
27
  'tap',
27
28
  'tap-flat',
29
+ 'tree',
28
30
  'verbose',
29
31
  ];
30
32
  export const getExternalReporters = (reporters) => reporters
@@ -1,11 +1,11 @@
1
1
  declare const _default: {
2
- symbols: (options: import("../index.js").ReporterOptions) => void;
3
- compact: ({ report, issues, isShowProgress, cwd }: import("../index.js").ReporterOptions) => void;
4
- codeowners: ({ report, issues, isShowProgress, options, cwd }: import("../index.js").ReporterOptions) => void;
5
- disclosure: ({ report, issues, cwd }: import("../index.js").ReporterOptions) => void;
6
- codeclimate: ({ report, issues, cwd }: import("../index.js").ReporterOptions) => Promise<void>;
7
- json: ({ report, issues, options, cwd }: import("../index.js").ReporterOptions) => Promise<void>;
8
- markdown: ({ report, issues, cwd }: import("../index.js").ReporterOptions) => void;
9
- 'github-actions': ({ report, issues, cwd, configurationHints, isDisableConfigHints, isTreatConfigHintsAsErrors, configFilePath, }: import("../index.js").ReporterOptions) => void;
2
+ symbols: (options: import("../types.js").ReporterOptions) => void;
3
+ compact: ({ report, issues, isShowProgress, cwd }: import("../types.js").ReporterOptions) => void;
4
+ codeowners: ({ report, issues, isShowProgress, options, cwd }: import("../types.js").ReporterOptions) => void;
5
+ disclosure: ({ report, issues, cwd }: import("../types.js").ReporterOptions) => void;
6
+ codeclimate: ({ report, issues, cwd }: import("../types.js").ReporterOptions) => Promise<void>;
7
+ json: ({ report, issues, options, cwd }: import("../types.js").ReporterOptions) => Promise<void>;
8
+ markdown: ({ report, issues, cwd }: import("../types.js").ReporterOptions) => void;
9
+ 'github-actions': ({ report, issues, cwd, configurationHints, isDisableConfigHints, isTreatConfigHintsAsErrors, configFilePath, }: import("../types.js").ReporterOptions) => void;
10
10
  };
11
11
  export default _default;
@@ -0,0 +1,2 @@
1
+ export type { RawConfiguration as KnipConfig } from './types/config.js';
2
+ export type { Preprocessor, Reporter, ReporterOptions } from './types/issues.js';
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -33,7 +33,7 @@ export default visit(isModule, (node, { isFixExports, isFixTypes, isReportClassM
33
33
  return {
34
34
  node: element,
35
35
  symbol: element.symbol,
36
- identifier: element.getText(),
36
+ identifier: element.name.getText(),
37
37
  type: SYMBOL_TYPE.UNKNOWN,
38
38
  pos: element.getStart(),
39
39
  fix,
@@ -37,7 +37,7 @@ export default visit(() => true, node => {
37
37
  specifier,
38
38
  symbol: element.symbol,
39
39
  isTypeOnly: node.importClause?.isTypeOnly,
40
- pos: element.pos,
40
+ pos: element.getStart(),
41
41
  });
42
42
  }
43
43
  }
@@ -58,6 +58,10 @@ export const createOptions = async (options) => {
58
58
  ...(parsedCLIArgs.files ? shorthandFiles : []),
59
59
  ],
60
60
  });
61
+ for (const [key, value] of Object.entries(includedIssueTypes)) {
62
+ if (!value)
63
+ rules[key] = 'off';
64
+ }
61
65
  const fixTypes = rest.fixTypes ?? parsedCLIArgs['fix-type'] ?? [];
62
66
  const isFixFiles = parsedCLIArgs['allow-remove-files'] && (fixTypes.length === 0 || fixTypes.includes('files'));
63
67
  const isIncludeLibs = parsedCLIArgs['include-libs'] ?? rest.isIncludeLibs ?? false;
@@ -24,9 +24,8 @@ export const updateImportMap = (file, importMap, graph) => {
24
24
  updateImportDetails(importedFileImports, importDetails);
25
25
  const importedFile = getOrCreateFileNode(graph, importedFilePath);
26
26
  if (!importedFile.imported)
27
- importedFile.imported = importDetails;
28
- else
29
- updateImportDetails(importedFile.imported, importDetails);
27
+ importedFile.imported = createImports();
28
+ updateImportDetails(importedFile.imported, importDetails);
30
29
  graph.set(importedFilePath, importedFile);
31
30
  }
32
31
  };
@@ -2,5 +2,5 @@ import type { CompilerOptions } from 'typescript';
2
2
  import type { ConfigurationChief, Workspace } from '../ConfigurationChief.js';
3
3
  export declare const augmentWorkspace: (workspace: Workspace, dir: string, compilerOptions: CompilerOptions) => void;
4
4
  export declare const getToSourcePathHandler: (chief: ConfigurationChief) => (filePath: string) => string | undefined;
5
- export declare const getToSourcePathsHandler: (chief: ConfigurationChief) => (specifiers: Set<string>, dir: string, extensions?: string) => Promise<string[]>;
5
+ export declare const getToSourcePathsHandler: (chief: ConfigurationChief) => (specifiers: Set<string>, dir: string, extensions: string | undefined, label: string) => Promise<string[]>;
6
6
  export type ToSourceFilePath = ReturnType<typeof getToSourcePathHandler>;
@@ -1,7 +1,7 @@
1
1
  import { DEFAULT_EXTENSIONS } from '../constants.js';
2
2
  import { debugLog, debugLogArray } from './debug.js';
3
3
  import { isDirectory } from './fs.js';
4
- import { _glob, _syncGlob } from './glob.js';
4
+ import { _glob, _syncGlob, prependDirToPattern } from './glob.js';
5
5
  import { isAbsolute, isInternal, join, toRelative } from './path.js';
6
6
  const defaultExtensions = `.{${DEFAULT_EXTENSIONS.map(ext => ext.slice(1)).join(',')}}`;
7
7
  const hasTSExt = /(?<!\.d)\.(m|c)?tsx?$/;
@@ -35,10 +35,10 @@ export const getToSourcePathHandler = (chief) => {
35
35
  };
36
36
  };
37
37
  export const getToSourcePathsHandler = (chief) => {
38
- return async (specifiers, dir, extensions = defaultExtensions) => {
38
+ return async (specifiers, dir, extensions = defaultExtensions, label) => {
39
39
  const patterns = new Set();
40
40
  for (const specifier of specifiers) {
41
- const absSpecifier = isAbsolute(specifier) ? specifier : join(dir, specifier);
41
+ const absSpecifier = isAbsolute(specifier) ? specifier : prependDirToPattern(dir, specifier);
42
42
  const ws = chief.findWorkspaceByFilePath(absSpecifier);
43
43
  if (ws?.srcDir && ws.outDir && !absSpecifier.startsWith(ws.srcDir) && absSpecifier.startsWith(ws.outDir)) {
44
44
  const pattern = absSpecifier.replace(ws.outDir, ws.srcDir).replace(matchExt, extensions);
@@ -48,7 +48,7 @@ export const getToSourcePathsHandler = (chief) => {
48
48
  patterns.add(absSpecifier);
49
49
  }
50
50
  }
51
- const filePaths = await _glob({ patterns: Array.from(patterns), cwd: dir });
51
+ const filePaths = await _glob({ patterns: Array.from(patterns), cwd: dir, label });
52
52
  debugLogArray(toRelative(dir, chief.cwd), 'Source mapping (package.json)', filePaths);
53
53
  return filePaths;
54
54
  };
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "5.66.1";
1
+ export declare const version = "5.66.3";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '5.66.1';
1
+ export const version = '5.66.3';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "5.66.1",
3
+ "version": "5.66.3",
4
4
  "description": "Find and fix unused dependencies, exports and files in your TypeScript and JavaScript projects",
5
5
  "homepage": "https://knip.dev",
6
6
  "repository": {
@@ -30,7 +30,7 @@
30
30
  "knip-bun": "bin/knip-bun.js"
31
31
  },
32
32
  "type": "module",
33
- "types": "./dist/index.d.ts",
33
+ "types": "./dist/types.d.ts",
34
34
  "scripts": {
35
35
  "knip": "node ./dist/cli.js --directory ../..",
36
36
  "knip:production": "node ./dist/cli.js --directory ../.. --production --strict",