knip 2.37.0 → 2.38.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.
package/README.md CHANGED
@@ -277,6 +277,7 @@ Knip contains a growing list of plugins:
277
277
  - [ESLint][plugin-eslint]
278
278
  - [Gatsby][plugin-gatsby]
279
279
  - [GitHub Actions][plugin-github-actions]
280
+ - [Graphql Codegen][plugin-graphql-codegen]
280
281
  - [husky][plugin-husky]
281
282
  - [Jest][plugin-jest]
282
283
  - [Lefthook][plugin-lefthook]
@@ -928,6 +929,7 @@ Special thanks to the wonderful people who have contributed to this project:
928
929
  [plugin-eslint]: ./src/plugins/eslint
929
930
  [plugin-gatsby]: ./src/plugins/gatsby
930
931
  [plugin-github-actions]: ./src/plugins/github-actions
932
+ [plugin-graphql-codegen]: ./src/plugins/graphql-codegen
931
933
  [plugin-husky]: ./src/plugins/husky
932
934
  [plugin-jest]: ./src/plugins/jest
933
935
  [plugin-lefthook]: ./src/plugins/lefthook
@@ -203,6 +203,19 @@ export declare const ConfigurationValidator: z.ZodObject<{
203
203
  entry?: string | string[] | undefined;
204
204
  project?: string | string[] | undefined;
205
205
  }>]>>;
206
+ 'graphql-codegen': z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
207
+ config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
208
+ entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
209
+ project: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
210
+ }, "strip", z.ZodTypeAny, {
211
+ config?: string | string[] | undefined;
212
+ entry?: string | string[] | undefined;
213
+ project?: string | string[] | undefined;
214
+ }, {
215
+ config?: string | string[] | undefined;
216
+ entry?: string | string[] | undefined;
217
+ project?: string | string[] | undefined;
218
+ }>]>>;
206
219
  husky: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
207
220
  config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
208
221
  entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
@@ -652,6 +665,11 @@ export declare const ConfigurationValidator: z.ZodObject<{
652
665
  entry?: string | string[] | undefined;
653
666
  project?: string | string[] | undefined;
654
667
  } | undefined;
668
+ 'graphql-codegen'?: string | boolean | string[] | {
669
+ config?: string | string[] | undefined;
670
+ entry?: string | string[] | undefined;
671
+ project?: string | string[] | undefined;
672
+ } | undefined;
655
673
  husky?: string | boolean | string[] | {
656
674
  config?: string | string[] | undefined;
657
675
  entry?: string | string[] | undefined;
@@ -869,6 +887,11 @@ export declare const ConfigurationValidator: z.ZodObject<{
869
887
  entry?: string | string[] | undefined;
870
888
  project?: string | string[] | undefined;
871
889
  } | undefined;
890
+ 'graphql-codegen'?: string | boolean | string[] | {
891
+ config?: string | string[] | undefined;
892
+ entry?: string | string[] | undefined;
893
+ project?: string | string[] | undefined;
894
+ } | undefined;
872
895
  husky?: string | boolean | string[] | {
873
896
  config?: string | string[] | undefined;
874
897
  entry?: string | string[] | undefined;
@@ -1184,6 +1207,19 @@ export declare const ConfigurationValidator: z.ZodObject<{
1184
1207
  entry?: string | string[] | undefined;
1185
1208
  project?: string | string[] | undefined;
1186
1209
  }>]>>;
1210
+ 'graphql-codegen': z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
1211
+ config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
1212
+ entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
1213
+ project: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
1214
+ }, "strip", z.ZodTypeAny, {
1215
+ config?: string | string[] | undefined;
1216
+ entry?: string | string[] | undefined;
1217
+ project?: string | string[] | undefined;
1218
+ }, {
1219
+ config?: string | string[] | undefined;
1220
+ entry?: string | string[] | undefined;
1221
+ project?: string | string[] | undefined;
1222
+ }>]>>;
1187
1223
  husky: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
1188
1224
  config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
1189
1225
  entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
@@ -1648,6 +1684,11 @@ export declare const ConfigurationValidator: z.ZodObject<{
1648
1684
  entry?: string | string[] | undefined;
1649
1685
  project?: string | string[] | undefined;
1650
1686
  } | undefined;
1687
+ 'graphql-codegen'?: string | boolean | string[] | {
1688
+ config?: string | string[] | undefined;
1689
+ entry?: string | string[] | undefined;
1690
+ project?: string | string[] | undefined;
1691
+ } | undefined;
1651
1692
  husky?: string | boolean | string[] | {
1652
1693
  config?: string | string[] | undefined;
1653
1694
  entry?: string | string[] | undefined;
@@ -1859,6 +1900,11 @@ export declare const ConfigurationValidator: z.ZodObject<{
1859
1900
  entry?: string | string[] | undefined;
1860
1901
  project?: string | string[] | undefined;
1861
1902
  } | undefined;
1903
+ 'graphql-codegen'?: string | boolean | string[] | {
1904
+ config?: string | string[] | undefined;
1905
+ entry?: string | string[] | undefined;
1906
+ project?: string | string[] | undefined;
1907
+ } | undefined;
1862
1908
  husky?: string | boolean | string[] | {
1863
1909
  config?: string | string[] | undefined;
1864
1910
  entry?: string | string[] | undefined;
@@ -2091,6 +2137,11 @@ export declare const ConfigurationValidator: z.ZodObject<{
2091
2137
  entry?: string | string[] | undefined;
2092
2138
  project?: string | string[] | undefined;
2093
2139
  } | undefined;
2140
+ 'graphql-codegen'?: string | boolean | string[] | {
2141
+ config?: string | string[] | undefined;
2142
+ entry?: string | string[] | undefined;
2143
+ project?: string | string[] | undefined;
2144
+ } | undefined;
2094
2145
  husky?: string | boolean | string[] | {
2095
2146
  config?: string | string[] | undefined;
2096
2147
  entry?: string | string[] | undefined;
@@ -2302,6 +2353,11 @@ export declare const ConfigurationValidator: z.ZodObject<{
2302
2353
  entry?: string | string[] | undefined;
2303
2354
  project?: string | string[] | undefined;
2304
2355
  } | undefined;
2356
+ 'graphql-codegen'?: string | boolean | string[] | {
2357
+ config?: string | string[] | undefined;
2358
+ entry?: string | string[] | undefined;
2359
+ project?: string | string[] | undefined;
2360
+ } | undefined;
2305
2361
  husky?: string | boolean | string[] | {
2306
2362
  config?: string | string[] | undefined;
2307
2363
  entry?: string | string[] | undefined;
@@ -73,6 +73,7 @@ const pluginsSchema = z.object({
73
73
  eslint: pluginSchema,
74
74
  gatsby: pluginSchema,
75
75
  'github-actions': pluginSchema,
76
+ 'graphql-codegen': pluginSchema,
76
77
  husky: pluginSchema,
77
78
  jest: pluginSchema,
78
79
  lefthook: pluginSchema,
@@ -52,7 +52,7 @@ export declare class WorkspaceWorker {
52
52
  installedBinaries: InstalledBinaries;
53
53
  referencedDependencies: ReferencedDependencies;
54
54
  hasTypesIncluded: Set<string>;
55
- enabledPlugins: ("astro" | "angular" | "ava" | "babel" | "capacitor" | "changesets" | "commitizen" | "commitlint" | "cspell" | "cypress" | "eslint" | "gatsby" | "husky" | "jest" | "lefthook" | "markdownlint" | "mocha" | "next" | "nx" | "nyc" | "playwright" | "postcss" | "prettier" | "remark" | "remix" | "rollup" | "sentry" | "storybook" | "stryker" | "stylelint" | "tailwind" | "typedoc" | "typescript" | "vite" | "vitest" | "webpack" | "drizzle" | "githubActions" | "lintStaged" | "nodeTestRunner" | "npmPackageJsonLint" | "playwrightCt" | "releaseIt" | "semanticRelease" | "svelte")[];
55
+ enabledPlugins: ("astro" | "angular" | "ava" | "babel" | "capacitor" | "changesets" | "commitizen" | "commitlint" | "cspell" | "cypress" | "eslint" | "gatsby" | "husky" | "jest" | "lefthook" | "markdownlint" | "mocha" | "next" | "nx" | "nyc" | "playwright" | "postcss" | "prettier" | "remark" | "remix" | "rollup" | "sentry" | "storybook" | "stryker" | "stylelint" | "tailwind" | "typedoc" | "typescript" | "vite" | "vitest" | "webpack" | "drizzle" | "githubActions" | "graphqlCodegen" | "lintStaged" | "nodeTestRunner" | "npmPackageJsonLint" | "playwrightCt" | "releaseIt" | "semanticRelease" | "svelte")[];
56
56
  entryFilePatterns: string[];
57
57
  productionEntryFilePatterns: string[];
58
58
  }>;
@@ -0,0 +1,7 @@
1
+ import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
2
+ export declare const NAME = "Graphql Codegen";
3
+ export declare const ENABLERS: RegExp[];
4
+ export declare const PACKAGE_JSON_PATH = "codegen";
5
+ export declare const isEnabled: IsPluginEnabledCallback;
6
+ export declare const CONFIG_FILE_PATTERNS: string[];
7
+ export declare const findDependencies: GenericPluginCallback;
@@ -0,0 +1,35 @@
1
+ import { timerify } from '../../util/Performance.js';
2
+ import { hasDependency, load } from '../../util/plugin.js';
3
+ import { isConfigurationOutput } from './types.js';
4
+ export const NAME = 'Graphql Codegen';
5
+ export const ENABLERS = [/^@graphql-codegen\//];
6
+ export const PACKAGE_JSON_PATH = 'codegen';
7
+ export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
8
+ export const CONFIG_FILE_PATTERNS = ['codegen.{ts,js,json,yml,mjs,cts}', 'package.json'];
9
+ const findPluginDependencies = async (configFilePath, options) => {
10
+ const { manifest, isProduction } = options;
11
+ if (isProduction)
12
+ return [];
13
+ const localConfig = configFilePath.endsWith('package.json')
14
+ ? manifest[PACKAGE_JSON_PATH]
15
+ : await load(configFilePath);
16
+ if (!localConfig)
17
+ return [];
18
+ const generateSet = Object.values(localConfig.generates);
19
+ const configurationOutput = generateSet.filter(isConfigurationOutput);
20
+ const presets = configurationOutput
21
+ .map(configOutput => (configOutput.preset ? configOutput.preset : undefined))
22
+ .filter((preset) => typeof preset === 'string')
23
+ .map(presetName => `@graphql-codegen/${presetName}${presetName.endsWith('-preset') ? '' : '-preset'}`);
24
+ const flatPlugins = generateSet
25
+ .filter((config) => !isConfigurationOutput(config))
26
+ .map(item => Object.keys(item))
27
+ .flat()
28
+ .map(plugin => `@graphql-codegen/${plugin}`);
29
+ const nestedPlugins = configurationOutput
30
+ .map(configOutput => (configOutput.plugins ? configOutput.plugins : []))
31
+ .flat()
32
+ .map(plugin => `@graphql-codegen/${plugin}`);
33
+ return [...presets, ...flatPlugins, ...nestedPlugins];
34
+ };
35
+ export const findDependencies = timerify(findPluginDependencies);
@@ -0,0 +1,25 @@
1
+ type PluginConfig<T = unknown> = {
2
+ [key: string]: T;
3
+ };
4
+ export interface ConfiguredPlugin {
5
+ [name: string]: PluginConfig;
6
+ }
7
+ type NamedPlugin = string;
8
+ type OutputConfig = NamedPlugin | ConfiguredPlugin;
9
+ type PresetNamesBase = 'client' | 'near-operation-file' | 'gql-tag-operations' | 'graphql-modules' | 'import-types';
10
+ export type PresetNames = `${PresetNamesBase}-preset` | PresetNamesBase;
11
+ type OutputPreset = {
12
+ buildGeneratesSection: (options: unknown) => Promise<unknown>;
13
+ prepareDocuments?: (outputFilePath: string, outputSpecificDocuments: unknown) => Promise<unknown>;
14
+ };
15
+ export declare function isConfigurationOutput(config: ConfiguredOutput | ConfiguredPlugin[]): config is ConfiguredOutput;
16
+ interface ConfiguredOutput {
17
+ plugins?: OutputConfig[];
18
+ preset?: PresetNames | OutputPreset;
19
+ }
20
+ export interface GraphqlCodegenTypes {
21
+ generates: {
22
+ [outputPath: string]: ConfiguredOutput | ConfiguredPlugin[];
23
+ };
24
+ }
25
+ export {};
@@ -0,0 +1,3 @@
1
+ export function isConfigurationOutput(config) {
2
+ return 'preset' in config || 'plugins' in config;
3
+ }
@@ -12,6 +12,7 @@ export * as drizzle from './drizzle/index.js';
12
12
  export * as eslint from './eslint/index.js';
13
13
  export * as gatsby from './gatsby/index.js';
14
14
  export * as githubActions from './github-actions/index.js';
15
+ export * as graphqlCodegen from './graphql-codegen/index.js';
15
16
  export * as husky from './husky/index.js';
16
17
  export * as jest from './jest/index.js';
17
18
  export * as lefthook from './lefthook/index.js';
@@ -12,6 +12,7 @@ export * as drizzle from './drizzle/index.js';
12
12
  export * as eslint from './eslint/index.js';
13
13
  export * as gatsby from './gatsby/index.js';
14
14
  export * as githubActions from './github-actions/index.js';
15
+ export * as graphqlCodegen from './graphql-codegen/index.js';
15
16
  export * as husky from './husky/index.js';
16
17
  export * as jest from './jest/index.js';
17
18
  export * as lefthook from './lefthook/index.js';
@@ -6,7 +6,7 @@ export const NAME = 'Storybook';
6
6
  export const ENABLERS = [/^@storybook\//, '@nrwl/storybook'];
7
7
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
8
8
  export const CONFIG_FILE_PATTERNS = ['.storybook/{main,test-runner}.{js,ts}'];
9
- export const STORIES_FILE_PATTERNS = ['**/*.stories.{js,jsx,ts,tsx}'];
9
+ export const STORIES_FILE_PATTERNS = ['**/*.@(mdx|stories.@(mdx|js|jsx|mjs|ts|tsx))'];
10
10
  export const ENTRY_FILE_PATTERNS = ['.storybook/{manager,preview}.{js,jsx,ts,tsx}', ...STORIES_FILE_PATTERNS];
11
11
  export const PROJECT_FILE_PATTERNS = ['.storybook/**/*.{js,jsx,ts,tsx}'];
12
12
  const findStorybookDependencies = async (configFilePath, options) => {
@@ -15,7 +15,11 @@ const findStorybookDependencies = async (configFilePath, options) => {
15
15
  const stories = typeof localConfig?.stories === 'function'
16
16
  ? await localConfig.stories(STORIES_FILE_PATTERNS)
17
17
  : localConfig?.stories;
18
- const relativePatterns = stories?.map(pattern => relative(cwd, join(dirname(configFilePath), pattern)));
18
+ const relativePatterns = stories?.map(pattern => {
19
+ if (typeof pattern === 'string')
20
+ return relative(cwd, join(dirname(configFilePath), pattern));
21
+ return relative(cwd, join(dirname(configFilePath), pattern.directory, pattern.files ?? STORIES_FILE_PATTERNS[0]));
22
+ });
19
23
  const patterns = [...(config?.entry ?? []), ...(relativePatterns ?? [])];
20
24
  const entryPatterns = (patterns.length > 0 ? patterns : ENTRY_FILE_PATTERNS).map(toEntryPattern);
21
25
  if (!localConfig || isProduction)
@@ -1,5 +1,10 @@
1
+ type Stories = (string | {
2
+ directory: string;
3
+ files?: string;
4
+ titlePrefix?: string;
5
+ })[];
1
6
  export type StorybookConfig = {
2
- stories?: string[] | ((patterns: string[]) => Promise<string[]>);
7
+ stories?: Stories | ((patterns: string[]) => Promise<string[]>);
3
8
  addons?: (string | {
4
9
  name: string;
5
10
  })[];
@@ -10,3 +15,4 @@ export type StorybookConfig = {
10
15
  name?: string;
11
16
  };
12
17
  };
18
+ export {};
@@ -87,6 +87,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
87
87
  entry?: string | string[] | undefined;
88
88
  project?: string | string[] | undefined;
89
89
  } | undefined;
90
+ 'graphql-codegen'?: string | boolean | string[] | {
91
+ config?: string | string[] | undefined;
92
+ entry?: string | string[] | undefined;
93
+ project?: string | string[] | undefined;
94
+ } | undefined;
90
95
  husky?: string | boolean | string[] | {
91
96
  config?: string | string[] | undefined;
92
97
  entry?: string | string[] | undefined;
@@ -298,6 +303,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
298
303
  entry?: string | string[] | undefined;
299
304
  project?: string | string[] | undefined;
300
305
  } | undefined;
306
+ 'graphql-codegen'?: string | boolean | string[] | {
307
+ config?: string | string[] | undefined;
308
+ entry?: string | string[] | undefined;
309
+ project?: string | string[] | undefined;
310
+ } | undefined;
301
311
  husky?: string | boolean | string[] | {
302
312
  config?: string | string[] | undefined;
303
313
  entry?: string | string[] | undefined;
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "2.37.0";
1
+ export declare const version = "2.38.1";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '2.37.0';
1
+ export const version = '2.38.1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "2.37.0",
3
+ "version": "2.38.1",
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",
@@ -46,7 +46,7 @@
46
46
  "@npmcli/map-workspaces": "^3.0.4",
47
47
  "@pkgjs/parseargs": "0.11.0",
48
48
  "@pnpm/logger": "5.0.0",
49
- "@pnpm/workspace.pkgs-graph": "2.0.8",
49
+ "@pnpm/workspace.pkgs-graph": "2.0.9",
50
50
  "@snyk/github-codeowners": "^1.1.0",
51
51
  "chalk": "^5.2.0",
52
52
  "easy-table": "^1.2.0",
@@ -68,21 +68,21 @@
68
68
  "@npmcli/package-json": "5.0.0",
69
69
  "@release-it/bumper": "5.1.0",
70
70
  "@swc/cli": "0.1.62",
71
- "@swc/core": "1.3.94",
71
+ "@swc/core": "1.3.95",
72
72
  "@types/eslint": "8.44.6",
73
73
  "@types/js-yaml": "4.0.8",
74
74
  "@types/micromatch": "4.0.4",
75
75
  "@types/minimist": "1.2.4",
76
- "@types/node": "20.8.7",
76
+ "@types/node": "20.8.8",
77
77
  "@types/npmcli__map-workspaces": "3.0.3",
78
78
  "@types/pkgjs__parseargs": "0.10.2",
79
79
  "@types/webpack": "5.28.4",
80
- "@typescript-eslint/eslint-plugin": "6.8.0",
81
- "@typescript-eslint/parser": "6.8.0",
80
+ "@typescript-eslint/eslint-plugin": "6.9.0",
81
+ "@typescript-eslint/parser": "6.9.0",
82
82
  "c8": "8.0.1",
83
83
  "eslint": "8.52.0",
84
84
  "eslint-import-resolver-typescript": "3.6.1",
85
- "eslint-plugin-import": "2.28.1",
85
+ "eslint-plugin-import": "2.29.0",
86
86
  "eslint-plugin-n": "16.2.0",
87
87
  "playwright": "1.39.0",
88
88
  "prettier": "3.0.3",
package/schema.json CHANGED
@@ -276,6 +276,10 @@
276
276
  "title": "github-actions plugin configuration (https://github.com/webpro/knip/blob/main/src/plugins/github-actions/README.md)",
277
277
  "$ref": "#/definitions/plugin"
278
278
  },
279
+ "graphql-codegen": {
280
+ "title": "graphql-codegen plugin configuration (https://github.com/webpro/knip/blob/main/src/plugins/graphql-codegen/README.md)",
281
+ "$ref": "#/definitions/plugin"
282
+ },
279
283
  "husky": {
280
284
  "title": "husky plugin configuration (https://github.com/webpro/knip/blob/main/src/plugins/husky/README.md)",
281
285
  "$ref": "#/definitions/plugin"