knip 2.32.1 → 2.32.2

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/dist/cli.js CHANGED
@@ -58,7 +58,7 @@ const run = async () => {
58
58
  }
59
59
  }
60
60
  catch (error) {
61
- if (error instanceof Error && isKnownError(error)) {
61
+ if (!isDebug && error instanceof Error && isKnownError(error)) {
62
62
  const knownError = getKnownError(error);
63
63
  console.error(knownError.message);
64
64
  if (hasCause(knownError))
@@ -3,7 +3,9 @@ import { toEntryPattern } from '../../util/protocols.js';
3
3
  export const NAME = 'Node.js Test Runner';
4
4
  export const ENABLERS = [''];
5
5
  export const isEnabled = ({ manifest }) => {
6
- return Boolean(manifest.scripts?.test && /node.+--test/.test(manifest.scripts?.test));
6
+ return Object.keys(manifest.scripts ?? {})
7
+ .filter(s => /test/.test(s))
8
+ .some(s => manifest.scripts && /node (.*)--test/.test(manifest.scripts[s]));
7
9
  };
8
10
  export const ENTRY_FILE_PATTERNS = [
9
11
  '**/test.{js,cjs,mjs}',
@@ -1,7 +1,9 @@
1
1
  import type { GenericPluginCallback, IsPluginEnabledCallback } from '../../types/plugins.js';
2
+ import type { PlaywrightTestConfig } from 'playwright/test';
2
3
  export declare const NAME = "Playwright";
3
4
  export declare const ENABLERS: string[];
4
5
  export declare const isEnabled: IsPluginEnabledCallback;
5
6
  export declare const ENTRY_FILE_PATTERNS: string[];
6
7
  export declare const CONFIG_FILE_PATTERNS: string[];
8
+ export declare const toEntryPatterns: (testMatch: string | RegExp | Array<string | RegExp> | undefined, cwd: string, configFilePath: string, config: PlaywrightTestConfig) => string[];
7
9
  export declare const findDependencies: GenericPluginCallback;
@@ -7,7 +7,7 @@ export const ENABLERS = ['@playwright/test'];
7
7
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
8
8
  export const ENTRY_FILE_PATTERNS = ['**/*.@(spec|test).?(c|m)[jt]s?(x)'];
9
9
  export const CONFIG_FILE_PATTERNS = ['playwright.config.{js,ts}'];
10
- const toEntryPatterns = (testMatch, cwd, configFilePath, config) => {
10
+ export const toEntryPatterns = (testMatch, cwd, configFilePath, config) => {
11
11
  if (!testMatch)
12
12
  return [];
13
13
  const dir = relative(cwd, config.testDir ? join(dirname(configFilePath), config.testDir) : dirname(configFilePath));
@@ -1,16 +1,16 @@
1
- import { dirname, join } from '../../util/path.js';
2
1
  import { timerify } from '../../util/Performance.js';
3
2
  import { hasDependency, load } from '../../util/plugin.js';
4
- import { toEntryPattern } from '../../util/protocols.js';
3
+ import { toEntryPatterns } from '../playwright/index.js';
5
4
  export const NAME = 'Playwright for components';
6
5
  export const ENABLERS = [/^@playwright\/experimental-ct-/];
7
6
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
8
7
  export const CONFIG_FILE_PATTERNS = ['playwright-ct.config.{js,ts}', 'playwright/index.{js,ts,jsx,tsx}'];
9
8
  export const ENTRY_FILE_PATTERNS = ['**/*.@(spec|test).?(c|m)[jt]s?(x)'];
10
- const findPlaywrightCTDependencies = async (configFilePath) => {
11
- const cfg = await load(configFilePath);
12
- const dir = cfg.testDir ? join(dirname(configFilePath), cfg.testDir) : dirname(configFilePath);
13
- const entryPatterns = (cfg.testMatch ? [cfg.testMatch] : ENTRY_FILE_PATTERNS).map(p => toEntryPattern(join(dir, p)));
14
- return entryPatterns;
9
+ const findPlaywrightCTDependencies = async (configFilePath, { cwd }) => {
10
+ const config = await load(configFilePath);
11
+ const entryPatterns = toEntryPatterns(config.testMatch, cwd, configFilePath, config);
12
+ if (entryPatterns.length > 0)
13
+ return entryPatterns;
14
+ return toEntryPatterns(ENTRY_FILE_PATTERNS, cwd, configFilePath, config);
15
15
  };
16
16
  export const findDependencies = timerify(findPlaywrightCTDependencies);
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "2.32.1";
1
+ export declare const version = "2.32.2";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '2.32.1';
1
+ export const version = '2.32.2';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "2.32.1",
3
+ "version": "2.32.2",
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",
@@ -57,7 +57,7 @@
57
57
  "strip-json-comments": "^5.0.0",
58
58
  "summary": "^2.1.0",
59
59
  "typescript": "^5.0.2",
60
- "zod": "^3.22.2",
60
+ "zod": "3.22.4",
61
61
  "zod-validation-error": "^1.5.0"
62
62
  },
63
63
  "devDependencies": {
@@ -65,18 +65,18 @@
65
65
  "@npmcli/package-json": "5.0.0",
66
66
  "@release-it/bumper": "5.1.0",
67
67
  "@swc/cli": "0.1.62",
68
- "@swc/core": "1.3.91",
68
+ "@swc/core": "1.3.92",
69
69
  "@types/eslint": "8.44.3",
70
70
  "@types/js-yaml": "4.0.6",
71
71
  "@types/micromatch": "4.0.3",
72
72
  "@types/minimist": "1.2.3",
73
- "@types/node": "20.8.2",
73
+ "@types/node": "20.8.3",
74
74
  "@types/npmcli__map-workspaces": "3.0.2",
75
75
  "@types/webpack": "5.28.3",
76
76
  "@typescript-eslint/eslint-plugin": "6.7.4",
77
77
  "@typescript-eslint/parser": "6.7.4",
78
78
  "c8": "8.0.1",
79
- "eslint": "8.50.0",
79
+ "eslint": "8.51.0",
80
80
  "eslint-import-resolver-typescript": "3.6.1",
81
81
  "eslint-plugin-import": "2.28.1",
82
82
  "eslint-plugin-n": "16.1.0",
@@ -86,7 +86,7 @@
86
86
  "remark-cli": "12.0.0",
87
87
  "remark-preset-webpro": "1.0.0",
88
88
  "tsx": "3.13.0",
89
- "type-fest": "4.3.3"
89
+ "type-fest": "4.4.0"
90
90
  },
91
91
  "engines": {
92
92
  "node": ">=16.17.0 <17 || >=18.6.0"
package/schema.json CHANGED
@@ -191,7 +191,7 @@
191
191
  "description": "Knip plugin configuration. See https://github.com/webpro/knip#plugins",
192
192
  "anyOf": [
193
193
  {
194
- "const": false
194
+ "type": "boolean"
195
195
  },
196
196
  {
197
197
  "$ref": "#/definitions/globPatterns"