knip 5.0.0 → 5.0.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.
@@ -57,7 +57,7 @@ export declare class ConfigurationChief {
57
57
  private getAvailableWorkspaceManifests;
58
58
  private getAvailableWorkspacePkgNames;
59
59
  private determineIncludedWorkspaces;
60
- getManifestForWorkspace(dir: string): PackageJson;
60
+ getManifestForWorkspace(dir: string): PackageJson | undefined;
61
61
  getIncludedWorkspaces(): Workspace[];
62
62
  private getDescendentWorkspaces;
63
63
  private getIgnoredWorkspacesFor;
@@ -280,7 +280,7 @@ export class ConfigurationChief {
280
280
  });
281
281
  }
282
282
  getManifestForWorkspace(dir) {
283
- return this.availableWorkspaceManifests?.find(item => item.dir === dir)?.manifest ?? {};
283
+ return this.availableWorkspaceManifests?.find(item => item.dir === dir)?.manifest;
284
284
  }
285
285
  getIncludedWorkspaces() {
286
286
  return this.includedWorkspaces;
package/dist/index.js CHANGED
@@ -93,6 +93,8 @@ export const main = async (unresolvedConfiguration) => {
93
93
  streamer.cast(`Analyzing workspace ${name}...`);
94
94
  const manifest = chief.getManifestForWorkspace(dir);
95
95
  const { ignoreBinaries, ignoreDependencies } = chief.getIgnores(name);
96
+ if (!manifest)
97
+ continue;
96
98
  deputy.addWorkspace({ name, cwd, dir, manifestPath, manifest, ignoreBinaries, ignoreDependencies });
97
99
  const dependencies = deputy.getDependencies(name);
98
100
  const compilers = getIncludedCompilers(chief.config.syncCompilers, chief.config.asyncCompilers, dependencies);
@@ -7,6 +7,7 @@ const CONFIG_FILE_PATTERNS = ['cypress.config.{js,ts,mjs,cjs}'];
7
7
  const TEST_FILE_PATTERNS = ['cypress/e2e/**/*.cy.{js,jsx,ts,tsx}'];
8
8
  const SUPPORT_FILE_PATTERNS = [
9
9
  'cypress/support/e2e.{js,jsx,ts,tsx}',
10
+ 'cypress/support/commands.{js,ts}',
10
11
  'cypress/plugins/index.js',
11
12
  ];
12
13
  const ENTRY_FILE_PATTERNS = [...TEST_FILE_PATTERNS, ...SUPPORT_FILE_PATTERNS];
@@ -8,7 +8,8 @@ const productionEntryFilePatternsWithoutSrc = [
8
8
  '{instrumentation,middleware}.{js,ts}',
9
9
  'app/global-error.{js,jsx,ts,tsx}',
10
10
  'app/**/{error,layout,loading,not-found,page,template}.{js,jsx,ts,tsx}',
11
- 'app/**/{route,default}.{js,ts}',
11
+ 'app/**/route.{js,ts}',
12
+ 'app/**/default.{js,jsx,ts,tsx}',
12
13
  'app/{manifest,sitemap,robots}.{js,ts}',
13
14
  'app/**/{icon,apple-icon}.{js,jsx,ts,tsx}',
14
15
  'app/**/{opengraph,twitter}-image.{js,jsx,ts,tsx}',
@@ -16,7 +16,10 @@ const findNxDependenciesInNxJson = async (configFilePath) => {
16
16
  .map(it => it.split(':')[0])
17
17
  : [];
18
18
  const plugins = localConfig.plugins && Array.isArray(localConfig.plugins)
19
- ? localConfig.plugins.map(it => getPackageNameFromModuleSpecifier(it.plugin)).filter(value => value !== undefined)
19
+ ? localConfig.plugins
20
+ .map(item => (typeof item === 'string' ? item : item.plugin))
21
+ .map(it => getPackageNameFromModuleSpecifier(it))
22
+ .filter(value => value !== undefined)
20
23
  : [];
21
24
  const generators = localConfig.generators
22
25
  ? Object.keys(localConfig.generators)
@@ -10,7 +10,7 @@ export interface NxProjectConfiguration {
10
10
  };
11
11
  }
12
12
  export interface NxConfigRoot {
13
- plugins?: Array<{
13
+ plugins?: Array<string | {
14
14
  plugin: string;
15
15
  }>;
16
16
  generators?: Record<string, unknown>;
@@ -1,8 +1,9 @@
1
- import type { IsPluginEnabledCallback } from '../../types/plugins.js';
1
+ import type { GenericPluginCallback, IsPluginEnabledCallback } from '../../types/plugins.js';
2
2
  declare const _default: {
3
3
  NAME: string;
4
4
  ENABLERS: string[];
5
5
  isEnabled: IsPluginEnabledCallback;
6
- CONFIG_FILE_PATTERNS: string[];
6
+ ENTRY_FILE_PATTERNS: string[];
7
+ findDependencies: GenericPluginCallback;
7
8
  };
8
9
  export default _default;
@@ -1,11 +1,17 @@
1
1
  import { hasDependency } from '../../util/plugin.js';
2
+ import { toEntryPattern } from '../../util/protocols.js';
2
3
  const NAME = 'Tailwind';
3
4
  const ENABLERS = ['tailwindcss'];
4
5
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
5
- const CONFIG_FILE_PATTERNS = ['tailwind.config.{js,cjs,mjs,ts}'];
6
+ const ENTRY_FILE_PATTERNS = ['tailwind.config.{js,cjs,mjs,ts}'];
7
+ const findDependencies = async (configFilePath, options) => {
8
+ const { config } = options;
9
+ return config.entry ? config.entry.map(toEntryPattern) : ENTRY_FILE_PATTERNS.map(toEntryPattern);
10
+ };
6
11
  export default {
7
12
  NAME,
8
13
  ENABLERS,
9
14
  isEnabled,
10
- CONFIG_FILE_PATTERNS,
15
+ ENTRY_FILE_PATTERNS,
16
+ findDependencies,
11
17
  };
@@ -65,8 +65,10 @@ export default async ({ report, issues, options }) => {
65
65
  }
66
66
  }
67
67
  }
68
- console.log(JSON.stringify({
68
+ const output = JSON.stringify({
69
69
  files: Array.from(issues.files).map(filePath => relative(filePath)),
70
70
  issues: Object.values(json),
71
- }));
71
+ });
72
+ process.stdout._handle?.setBlocking?.(true);
73
+ process.stdout.write(output + '\n');
72
74
  };
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "4.4.0";
1
+ export declare const version = "5.0.2";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '4.4.0';
1
+ export const version = '5.0.2';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "5.0.0",
3
+ "version": "5.0.2",
4
4
  "description": "Find unused files, dependencies and exports in your TypeScript and JavaScript projects",
5
5
  "homepage": "https://knip.dev",
6
6
  "repository": {
@@ -75,7 +75,7 @@
75
75
  "strip-json-comments": "5.0.1",
76
76
  "summary": "2.1.0",
77
77
  "zod": "3.22.4",
78
- "zod-validation-error": "3.0.0"
78
+ "zod-validation-error": "3.0.2"
79
79
  },
80
80
  "peerDependencies": {
81
81
  "@types/node": ">=18",
@@ -86,21 +86,21 @@
86
86
  "@knip/eslint-config": "0.0.0",
87
87
  "@release-it/bumper": "^6.0.1",
88
88
  "@swc/cli": "^0.3.9",
89
- "@swc/core": "^1.4.0",
89
+ "@swc/core": "^1.4.2",
90
90
  "@types/js-yaml": "^4.0.9",
91
91
  "@types/micromatch": "^4.0.6",
92
92
  "@types/minimist": "^1.2.5",
93
93
  "@types/npmcli__map-workspaces": "^3.0.4",
94
- "@types/npmcli__package-json": "^4.0.3",
95
- "@types/semver": "7.5.6",
94
+ "@types/npmcli__package-json": "^4.0.4",
95
+ "@types/semver": "7.5.7",
96
96
  "@types/webpack": "^5.28.5",
97
97
  "c8": "9.1.0",
98
98
  "eslint": "^8.56.0",
99
99
  "playwright": "^1.41.2",
100
100
  "prettier": "^3.2.5",
101
- "release-it": "^17.0.3",
101
+ "release-it": "^17.1.1",
102
102
  "tsx": "^4.7.1",
103
- "type-fest": "^4.10.2",
103
+ "type-fest": "^4.10.3",
104
104
  "typescript": "5.3.3"
105
105
  },
106
106
  "engines": {
package/schema-jsonc.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "description": "See https://github.com/webpro/knip",
5
5
  "allOf": [
6
6
  {
7
- "$ref": "https://unpkg.com/knip@4/schema.json"
7
+ "$ref": "https://unpkg.com/knip@5/schema.json"
8
8
  }
9
9
  ],
10
10
  "allowTrailingCommas": true