knip 5.43.5 → 5.44.0

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.
Files changed (47) hide show
  1. package/README.md +6 -6
  2. package/dist/ConfigurationChief.d.ts +6 -5
  3. package/dist/ConfigurationChief.js +9 -5
  4. package/dist/ConfigurationValidator.d.ts +56 -56
  5. package/dist/DependencyDeputy.d.ts +3 -1
  6. package/dist/DependencyDeputy.js +11 -5
  7. package/dist/PackageJsonPeeker.d.ts +13 -0
  8. package/dist/PackageJsonPeeker.js +43 -0
  9. package/dist/binaries/plugins.js +1 -1
  10. package/dist/compilers/index.d.ts +10 -10
  11. package/dist/index.js +3 -3
  12. package/dist/plugins/expo/helpers.d.ts +19 -3
  13. package/dist/plugins/expo/helpers.js +16 -3
  14. package/dist/plugins/expo/index.js +4 -4
  15. package/dist/plugins/expo/types.d.ts +10 -4
  16. package/dist/plugins/graphql-codegen/index.d.ts +1 -1
  17. package/dist/plugins/index.d.ts +14 -7
  18. package/dist/plugins/index.js +2 -2
  19. package/dist/plugins/node/index.d.ts +8 -0
  20. package/dist/plugins/node/index.js +18 -0
  21. package/dist/plugins/nyc/index.js +1 -1
  22. package/dist/plugins/react-router/index.d.ts +10 -0
  23. package/dist/plugins/react-router/index.js +41 -0
  24. package/dist/plugins/react-router/types.d.ts +7 -0
  25. package/dist/plugins/react-router/types.js +1 -0
  26. package/dist/reporters/json.js +3 -3
  27. package/dist/reporters/symbols.js +2 -2
  28. package/dist/reporters/util.d.ts +1 -0
  29. package/dist/reporters/util.js +2 -1
  30. package/dist/reporters/watch.js +1 -1
  31. package/dist/schema/plugins.d.ts +23 -23
  32. package/dist/schema/plugins.js +1 -1
  33. package/dist/types/PluginNames.d.ts +2 -2
  34. package/dist/types/PluginNames.js +1 -1
  35. package/dist/types/config.d.ts +1 -1
  36. package/dist/types/package-json.d.ts +3 -1
  37. package/dist/types/workspace.d.ts +1 -0
  38. package/dist/util/input.d.ts +0 -1
  39. package/dist/util/map-workspaces.d.ts +2 -2
  40. package/dist/util/map-workspaces.js +7 -6
  41. package/dist/util/to-source-path.js +1 -1
  42. package/dist/version.d.ts +1 -1
  43. package/dist/version.js +1 -1
  44. package/package.json +4 -4
  45. package/schema.json +4 -0
  46. package/dist/plugins/node-test-runner/index.d.ts +0 -8
  47. package/dist/plugins/node-test-runner/index.js +0 -10
package/README.md CHANGED
@@ -9,15 +9,15 @@
9
9
 
10
10
  <div align="center">
11
11
 
12
- [![NPM Version](https://img.shields.io/npm/v/knip)][1]
13
- [![NPM Downloads](https://img.shields.io/npm/dm/knip)][1]
14
- [![GitHub Repo stars](https://img.shields.io/github/stars/webpro-nl/knip)][2]
12
+ [![NPM Version](https://img.shields.io/npm/v/knip)][1]
13
+ [![NPM Downloads](https://img.shields.io/npm/dm/knip)][1]
14
+ [![GitHub Repo stars](https://img.shields.io/github/stars/webpro-nl/knip)][2]
15
15
 
16
16
  </div>
17
17
 
18
- Knip finds **unused files, dependencies and exports** in your JavaScript and
19
- TypeScript projects. Less code and dependencies lead to improved performance,
20
- less maintenance and easier refactorings.
18
+ Knip finds and fixes **unused files, dependencies and exports** in your
19
+ JavaScript and TypeScript projects. Less code and dependencies lead to improved
20
+ performance, less maintenance and easier refactorings.
21
21
 
22
22
  - Website: [knip.dev][3]
23
23
  - GitHub repo: [webpro-nl/knip][2]
@@ -1,5 +1,5 @@
1
1
  import type { Configuration, IgnorePatterns, WorkspaceConfiguration } from './types/config.js';
2
- import type { Package, PackageJson } from './types/package-json.js';
2
+ import type { PackageJson, WorkspacePackage } from './types/package-json.js';
3
3
  import { type WorkspaceGraph } from './util/create-workspace-graph.js';
4
4
  import { type CLIArguments } from './util/get-included-issue-types.js';
5
5
  type ConfigurationManagerOptions = {
@@ -16,6 +16,7 @@ export type Workspace = {
16
16
  ancestors: string[];
17
17
  config: WorkspaceConfiguration;
18
18
  manifestPath: string;
19
+ manifestStr: string;
19
20
  ignoreMembers: IgnorePatterns;
20
21
  srcDir?: string;
21
22
  outDir?: string;
@@ -30,7 +31,7 @@ export declare class ConfigurationChief {
30
31
  manifestPath?: string;
31
32
  manifest?: PackageJson;
32
33
  ignoredWorkspacePatterns: string[];
33
- workspacePackages: Map<string, Package>;
34
+ workspacePackages: Map<string, WorkspacePackage>;
34
35
  workspacesByPkgName: Map<string, Workspace>;
35
36
  workspacesByName: Map<string, Workspace>;
36
37
  additionalWorkspaceNames: Set<string>;
@@ -57,9 +58,9 @@ export declare class ConfigurationChief {
57
58
  private getConfiguredWorkspaceKeys;
58
59
  private getAdditionalWorkspaceNames;
59
60
  private getAvailableWorkspaceNames;
60
- private setIncludedWorkspaces;
61
+ private getIncludedWorkspaces;
61
62
  getManifestForWorkspace(name: string): PackageJson | undefined;
62
- getIncludedWorkspaces(): Workspace[];
63
+ getWorkspaces(): Workspace[];
63
64
  private getDescendentWorkspaces;
64
65
  getIgnoredWorkspacesFor(name: string): string[];
65
66
  getNegatedWorkspacePatterns(name: string): string[];
@@ -111,7 +112,6 @@ export declare class ConfigurationChief {
111
112
  nest?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
112
113
  netlify?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
113
114
  next?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
114
- "node-test-runner"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
115
115
  nodemon?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
116
116
  "npm-package-json-lint"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
117
117
  nuxt?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
@@ -126,6 +126,7 @@ export declare class ConfigurationChief {
126
126
  preconstruct?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
127
127
  prettier?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
128
128
  "react-cosmos"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
129
+ "react-router"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
129
130
  "release-it"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
130
131
  remark?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
131
132
  remix?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
@@ -164,7 +164,7 @@ export class ConfigurationChief {
164
164
  .reverse()
165
165
  .map(dir => join(this.cwd, dir));
166
166
  this.workspaceGraph = createWorkspaceGraph(this.cwd, this.availableWorkspaceNames, wsPkgNames, packages);
167
- this.includedWorkspaces = this.setIncludedWorkspaces();
167
+ this.includedWorkspaces = this.getIncludedWorkspaces();
168
168
  for (const workspace of this.includedWorkspaces) {
169
169
  this.workspacesByPkgName.set(workspace.pkgName, workspace);
170
170
  this.workspacesByName.set(workspace.name, workspace);
@@ -203,7 +203,7 @@ export class ConfigurationChief {
203
203
  getAvailableWorkspaceNames(names) {
204
204
  return [...names, ...this.additionalWorkspaceNames].filter(name => !picomatch.isMatch(name, this.ignoredWorkspacePatterns));
205
205
  }
206
- setIncludedWorkspaces() {
206
+ getIncludedWorkspaces() {
207
207
  if (this.workspace) {
208
208
  const dir = resolve(this.workspace);
209
209
  if (!isDirectory(dir))
@@ -255,7 +255,10 @@ export class ConfigurationChief {
255
255
  .sort(byPathDepth)
256
256
  .map((name) => {
257
257
  const dir = join(this.cwd, name);
258
- const pkgName = this.workspacePackages.get(name)?.pkgName ?? `KNIP_ADDED_${name}`;
258
+ const pkg = this.workspacePackages.get(name);
259
+ const pkgName = pkg?.pkgName ?? `KNIP_ADDED_${name}`;
260
+ const manifestPath = pkg?.manifestPath ?? join(dir, 'package.json');
261
+ const manifestStr = pkg?.manifestStr ?? '';
259
262
  const workspaceConfig = this.getWorkspaceConfig(name);
260
263
  const ignoreMembers = arrayify(workspaceConfig.ignoreMembers).map(toRegexOrString);
261
264
  return {
@@ -264,7 +267,8 @@ export class ConfigurationChief {
264
267
  dir,
265
268
  config: this.getConfigForWorkspace(name),
266
269
  ancestors: this.availableWorkspaceNames.reduce(getAncestors(name), []),
267
- manifestPath: join(dir, 'package.json'),
270
+ manifestPath,
271
+ manifestStr,
268
272
  ignoreMembers,
269
273
  };
270
274
  });
@@ -272,7 +276,7 @@ export class ConfigurationChief {
272
276
  getManifestForWorkspace(name) {
273
277
  return this.workspacePackages.get(name)?.manifest;
274
278
  }
275
- getIncludedWorkspaces() {
279
+ getWorkspaces() {
276
280
  return this.includedWorkspaces;
277
281
  }
278
282
  getDescendentWorkspaces(name) {
@@ -550,19 +550,6 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
550
550
  entry?: string | string[] | undefined;
551
551
  project?: string | string[] | undefined;
552
552
  }>]>>;
553
- 'node-test-runner': z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
554
- config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
555
- entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
556
- project: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
557
- }, "strip", z.ZodTypeAny, {
558
- config?: string | string[] | undefined;
559
- entry?: string | string[] | undefined;
560
- project?: string | string[] | undefined;
561
- }, {
562
- config?: string | string[] | undefined;
563
- entry?: string | string[] | undefined;
564
- project?: string | string[] | undefined;
565
- }>]>>;
566
553
  nodemon: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
567
554
  config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
568
555
  entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
@@ -745,6 +732,19 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
745
732
  entry?: string | string[] | undefined;
746
733
  project?: string | string[] | undefined;
747
734
  }>]>>;
735
+ 'react-router': z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
736
+ config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
737
+ entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
738
+ project: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
739
+ }, "strip", z.ZodTypeAny, {
740
+ config?: string | string[] | undefined;
741
+ entry?: string | string[] | undefined;
742
+ project?: string | string[] | undefined;
743
+ }, {
744
+ config?: string | string[] | undefined;
745
+ entry?: string | string[] | undefined;
746
+ project?: string | string[] | undefined;
747
+ }>]>>;
748
748
  'release-it': z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
749
749
  config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
750
750
  entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
@@ -1416,11 +1416,6 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
1416
1416
  entry?: string | string[] | undefined;
1417
1417
  project?: string | string[] | undefined;
1418
1418
  } | undefined;
1419
- 'node-test-runner'?: string | boolean | string[] | {
1420
- config?: string | string[] | undefined;
1421
- entry?: string | string[] | undefined;
1422
- project?: string | string[] | undefined;
1423
- } | undefined;
1424
1419
  nodemon?: string | boolean | string[] | {
1425
1420
  config?: string | string[] | undefined;
1426
1421
  entry?: string | string[] | undefined;
@@ -1491,6 +1486,11 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
1491
1486
  entry?: string | string[] | undefined;
1492
1487
  project?: string | string[] | undefined;
1493
1488
  } | undefined;
1489
+ 'react-router'?: string | boolean | string[] | {
1490
+ config?: string | string[] | undefined;
1491
+ entry?: string | string[] | undefined;
1492
+ project?: string | string[] | undefined;
1493
+ } | undefined;
1494
1494
  'release-it'?: string | boolean | string[] | {
1495
1495
  config?: string | string[] | undefined;
1496
1496
  entry?: string | string[] | undefined;
@@ -1881,11 +1881,6 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
1881
1881
  entry?: string | string[] | undefined;
1882
1882
  project?: string | string[] | undefined;
1883
1883
  } | undefined;
1884
- 'node-test-runner'?: string | boolean | string[] | {
1885
- config?: string | string[] | undefined;
1886
- entry?: string | string[] | undefined;
1887
- project?: string | string[] | undefined;
1888
- } | undefined;
1889
1884
  nodemon?: string | boolean | string[] | {
1890
1885
  config?: string | string[] | undefined;
1891
1886
  entry?: string | string[] | undefined;
@@ -1956,6 +1951,11 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
1956
1951
  entry?: string | string[] | undefined;
1957
1952
  project?: string | string[] | undefined;
1958
1953
  } | undefined;
1954
+ 'react-router'?: string | boolean | string[] | {
1955
+ config?: string | string[] | undefined;
1956
+ entry?: string | string[] | undefined;
1957
+ project?: string | string[] | undefined;
1958
+ } | undefined;
1959
1959
  'release-it'?: string | boolean | string[] | {
1960
1960
  config?: string | string[] | undefined;
1961
1961
  entry?: string | string[] | undefined;
@@ -2665,19 +2665,6 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
2665
2665
  entry?: string | string[] | undefined;
2666
2666
  project?: string | string[] | undefined;
2667
2667
  }>]>>;
2668
- 'node-test-runner': z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
2669
- config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
2670
- entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
2671
- project: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
2672
- }, "strip", z.ZodTypeAny, {
2673
- config?: string | string[] | undefined;
2674
- entry?: string | string[] | undefined;
2675
- project?: string | string[] | undefined;
2676
- }, {
2677
- config?: string | string[] | undefined;
2678
- entry?: string | string[] | undefined;
2679
- project?: string | string[] | undefined;
2680
- }>]>>;
2681
2668
  nodemon: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
2682
2669
  config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
2683
2670
  entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
@@ -2860,6 +2847,19 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
2860
2847
  entry?: string | string[] | undefined;
2861
2848
  project?: string | string[] | undefined;
2862
2849
  }>]>>;
2850
+ 'react-router': z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
2851
+ config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
2852
+ entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
2853
+ project: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
2854
+ }, "strip", z.ZodTypeAny, {
2855
+ config?: string | string[] | undefined;
2856
+ entry?: string | string[] | undefined;
2857
+ project?: string | string[] | undefined;
2858
+ }, {
2859
+ config?: string | string[] | undefined;
2860
+ entry?: string | string[] | undefined;
2861
+ project?: string | string[] | undefined;
2862
+ }>]>>;
2863
2863
  'release-it': z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
2864
2864
  config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
2865
2865
  entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
@@ -3533,11 +3533,6 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
3533
3533
  entry?: string | string[] | undefined;
3534
3534
  project?: string | string[] | undefined;
3535
3535
  } | undefined;
3536
- 'node-test-runner'?: string | boolean | string[] | {
3537
- config?: string | string[] | undefined;
3538
- entry?: string | string[] | undefined;
3539
- project?: string | string[] | undefined;
3540
- } | undefined;
3541
3536
  nodemon?: string | boolean | string[] | {
3542
3537
  config?: string | string[] | undefined;
3543
3538
  entry?: string | string[] | undefined;
@@ -3608,6 +3603,11 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
3608
3603
  entry?: string | string[] | undefined;
3609
3604
  project?: string | string[] | undefined;
3610
3605
  } | undefined;
3606
+ 'react-router'?: string | boolean | string[] | {
3607
+ config?: string | string[] | undefined;
3608
+ entry?: string | string[] | undefined;
3609
+ project?: string | string[] | undefined;
3610
+ } | undefined;
3611
3611
  'release-it'?: string | boolean | string[] | {
3612
3612
  config?: string | string[] | undefined;
3613
3613
  entry?: string | string[] | undefined;
@@ -4004,11 +4004,6 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
4004
4004
  entry?: string | string[] | undefined;
4005
4005
  project?: string | string[] | undefined;
4006
4006
  } | undefined;
4007
- 'node-test-runner'?: string | boolean | string[] | {
4008
- config?: string | string[] | undefined;
4009
- entry?: string | string[] | undefined;
4010
- project?: string | string[] | undefined;
4011
- } | undefined;
4012
4007
  nodemon?: string | boolean | string[] | {
4013
4008
  config?: string | string[] | undefined;
4014
4009
  entry?: string | string[] | undefined;
@@ -4079,6 +4074,11 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
4079
4074
  entry?: string | string[] | undefined;
4080
4075
  project?: string | string[] | undefined;
4081
4076
  } | undefined;
4077
+ 'react-router'?: string | boolean | string[] | {
4078
+ config?: string | string[] | undefined;
4079
+ entry?: string | string[] | undefined;
4080
+ project?: string | string[] | undefined;
4081
+ } | undefined;
4082
4082
  'release-it'?: string | boolean | string[] | {
4083
4083
  config?: string | string[] | undefined;
4084
4084
  entry?: string | string[] | undefined;
@@ -4472,11 +4472,6 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
4472
4472
  entry?: string | string[] | undefined;
4473
4473
  project?: string | string[] | undefined;
4474
4474
  } | undefined;
4475
- 'node-test-runner'?: string | boolean | string[] | {
4476
- config?: string | string[] | undefined;
4477
- entry?: string | string[] | undefined;
4478
- project?: string | string[] | undefined;
4479
- } | undefined;
4480
4475
  nodemon?: string | boolean | string[] | {
4481
4476
  config?: string | string[] | undefined;
4482
4477
  entry?: string | string[] | undefined;
@@ -4547,6 +4542,11 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
4547
4542
  entry?: string | string[] | undefined;
4548
4543
  project?: string | string[] | undefined;
4549
4544
  } | undefined;
4545
+ 'react-router'?: string | boolean | string[] | {
4546
+ config?: string | string[] | undefined;
4547
+ entry?: string | string[] | undefined;
4548
+ project?: string | string[] | undefined;
4549
+ } | undefined;
4550
4550
  'release-it'?: string | boolean | string[] | {
4551
4551
  config?: string | string[] | undefined;
4552
4552
  entry?: string | string[] | undefined;
@@ -4943,11 +4943,6 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
4943
4943
  entry?: string | string[] | undefined;
4944
4944
  project?: string | string[] | undefined;
4945
4945
  } | undefined;
4946
- 'node-test-runner'?: string | boolean | string[] | {
4947
- config?: string | string[] | undefined;
4948
- entry?: string | string[] | undefined;
4949
- project?: string | string[] | undefined;
4950
- } | undefined;
4951
4946
  nodemon?: string | boolean | string[] | {
4952
4947
  config?: string | string[] | undefined;
4953
4948
  entry?: string | string[] | undefined;
@@ -5018,6 +5013,11 @@ export declare const ConfigurationValidator: z.ZodObject<z.objectUtil.extendShap
5018
5013
  entry?: string | string[] | undefined;
5019
5014
  project?: string | string[] | undefined;
5020
5015
  } | undefined;
5016
+ 'react-router'?: string | boolean | string[] | {
5017
+ config?: string | string[] | undefined;
5018
+ entry?: string | string[] | undefined;
5019
+ project?: string | string[] | undefined;
5020
+ } | undefined;
5021
5021
  'release-it'?: string | boolean | string[] | {
5022
5022
  config?: string | string[] | undefined;
5023
5023
  entry?: string | string[] | undefined;
@@ -16,11 +16,12 @@ export declare class DependencyDeputy {
16
16
  installedBinaries: Map<string, InstalledBinaries>;
17
17
  hasTypesIncluded: Map<string, Set<string>>;
18
18
  constructor({ isProduction, isStrict }: Options);
19
- addWorkspace({ name, cwd, dir, manifestPath, manifest, ignoreDependencies, ignoreBinaries, ignoreUnresolved, }: {
19
+ addWorkspace({ name, cwd, dir, manifestPath, manifestStr, manifest, ignoreDependencies, ignoreBinaries, ignoreUnresolved, }: {
20
20
  name: string;
21
21
  cwd: string;
22
22
  dir: string;
23
23
  manifestPath: string;
24
+ manifestStr: string;
24
25
  manifest: PackageJson;
25
26
  ignoreDependencies: (string | RegExp)[];
26
27
  ignoreBinaries: (string | RegExp)[];
@@ -29,6 +30,7 @@ export declare class DependencyDeputy {
29
30
  getWorkspaceManifest(workspaceName: string): {
30
31
  workspaceDir: string;
31
32
  manifestPath: string;
33
+ manifestStr: string;
32
34
  dependencies: DependencyArray;
33
35
  devDependencies: DependencyArray;
34
36
  peerDependencies: DependencySet;
@@ -1,4 +1,5 @@
1
1
  import { isBuiltin } from 'node:module';
2
+ import { PackageJsonPeeker } from './PackageJsonPeeker.js';
2
3
  import { DT_SCOPE, IGNORED_DEPENDENCIES, IGNORED_GLOBAL_BINARIES, IGNORED_RUNTIME_DEPENDENCIES, IGNORE_DEFINITELY_TYPED, ROOT_WORKSPACE_NAME, } from './constants.js';
3
4
  import { getDependencyMetaData } from './manifest/index.js';
4
5
  import { getDefinitelyTypedFor, getPackageFromDefinitelyTyped, getPackageNameFromModuleSpecifier, isDefinitelyTyped, } from './util/modules.js';
@@ -21,7 +22,7 @@ export class DependencyDeputy {
21
22
  this.installedBinaries = new Map();
22
23
  this.hasTypesIncluded = new Map();
23
24
  }
24
- addWorkspace({ name, cwd, dir, manifestPath, manifest, ignoreDependencies, ignoreBinaries, ignoreUnresolved, }) {
25
+ addWorkspace({ name, cwd, dir, manifestPath, manifestStr, manifest, ignoreDependencies, ignoreBinaries, ignoreUnresolved, }) {
25
26
  const dependencies = Object.keys(manifest.dependencies ?? {});
26
27
  const peerDependencies = Object.keys(manifest.peerDependencies ?? {});
27
28
  const optionalDependencies = Object.keys(manifest.optionalDependencies ?? {});
@@ -48,6 +49,7 @@ export class DependencyDeputy {
48
49
  this._manifests.set(name, {
49
50
  workspaceDir: dir,
50
51
  manifestPath,
52
+ manifestStr,
51
53
  ignoreDependencies: ignoreDependencies.map(toRegexOrString),
52
54
  ignoreBinaries: ignoreBinaries.map(toRegexOrString),
53
55
  ignoreUnresolved: ignoreUnresolved.map(toRegexOrString),
@@ -168,9 +170,10 @@ export class DependencyDeputy {
168
170
  const dependencyIssues = [];
169
171
  const devDependencyIssues = [];
170
172
  const optionalPeerDependencyIssues = [];
171
- for (const [workspace, { manifestPath: filePath }] of this._manifests.entries()) {
173
+ for (const [workspace, { manifestPath: filePath, manifestStr }] of this._manifests.entries()) {
172
174
  const referencedDependencies = this.referencedDependencies.get(workspace);
173
175
  const hasTypesIncluded = this.getHasTypesIncluded(workspace);
176
+ const peeker = new PackageJsonPeeker(manifestStr);
174
177
  const peerDepRecs = {};
175
178
  const isReferencedDependency = (dependency, isPeerDep) => {
176
179
  if (referencedDependencies?.has(dependency))
@@ -205,13 +208,16 @@ export class DependencyDeputy {
205
208
  };
206
209
  const isNotReferencedDependency = (dependency) => !isReferencedDependency(dependency, false);
207
210
  for (const symbol of this.getProductionDependencies(workspace).filter(isNotReferencedDependency)) {
208
- dependencyIssues.push({ type: 'dependencies', workspace, filePath, symbol });
211
+ const position = peeker.getLocation('dependencies', symbol);
212
+ dependencyIssues.push({ type: 'dependencies', workspace, filePath, symbol, ...position });
209
213
  }
210
214
  for (const symbol of this.getDevDependencies(workspace).filter(isNotReferencedDependency)) {
211
- devDependencyIssues.push({ type: 'devDependencies', filePath, workspace, symbol });
215
+ const position = peeker.getLocation('devDependencies', symbol);
216
+ devDependencyIssues.push({ type: 'devDependencies', filePath, workspace, symbol, ...position });
212
217
  }
213
218
  for (const symbol of this.getOptionalPeerDependencies(workspace).filter(d => isReferencedDependency(d))) {
214
- optionalPeerDependencyIssues.push({ type: 'optionalPeerDependencies', filePath, workspace, symbol });
219
+ const pos = peeker.getLocation('optionalPeerDependencies', symbol);
220
+ optionalPeerDependencyIssues.push({ type: 'optionalPeerDependencies', filePath, workspace, symbol, ...pos });
215
221
  }
216
222
  }
217
223
  return { dependencyIssues, devDependencyIssues, optionalPeerDependencyIssues };
@@ -0,0 +1,13 @@
1
+ export declare class PackageJsonPeeker {
2
+ private manifestStr;
3
+ private lines;
4
+ private sections;
5
+ private ready;
6
+ constructor(manifestStr: string);
7
+ private init;
8
+ getLocation(type: 'dependencies' | 'devDependencies' | 'optionalPeerDependencies', packageName: string): {
9
+ line: number;
10
+ col: number;
11
+ pos: number;
12
+ } | undefined;
13
+ }
@@ -0,0 +1,43 @@
1
+ export class PackageJsonPeeker {
2
+ manifestStr;
3
+ lines = [];
4
+ sections = {};
5
+ ready = false;
6
+ constructor(manifestStr) {
7
+ this.manifestStr = manifestStr;
8
+ }
9
+ init() {
10
+ this.lines = this.manifestStr.split('\n');
11
+ let pos = 0;
12
+ for (let i = 0; i < this.lines.length; i++) {
13
+ const line = this.lines[i];
14
+ const section = line.indexOf('"dependencies"') !== -1
15
+ ? 'dependencies'
16
+ : line.indexOf('"devDependencies"') !== -1
17
+ ? 'devDependencies'
18
+ : line.indexOf('"optionalPeerDependencies"') !== -1
19
+ ? 'optionalPeerDependencies'
20
+ : undefined;
21
+ if (section)
22
+ this.sections[section] = { startLine: i, startPos: pos };
23
+ pos += line.length + 1;
24
+ }
25
+ }
26
+ getLocation(type, packageName) {
27
+ if (!this.ready)
28
+ this.init();
29
+ const lines = this.lines;
30
+ const section = this.sections[type];
31
+ if (lines.length === 0 || !section)
32
+ return;
33
+ let pos = section.startPos + lines[section.startLine].length + 1;
34
+ for (let i = section.startLine + 1; i < lines.length; i++) {
35
+ const line = lines[i];
36
+ if (line.includes(`"${packageName}"`)) {
37
+ const col = line.indexOf(packageName);
38
+ return { line: i + 1, col: col + 1, pos: pos + col };
39
+ }
40
+ pos += line.length + 1;
41
+ }
42
+ }
43
+ }
@@ -6,7 +6,7 @@ import { extractBinary } from '../util/modules.js';
6
6
  import { resolve as fallbackResolve } from './fallback.js';
7
7
  const isGlobLikeMatch = /(^!|[*+\\(|{^$])/;
8
8
  const isGlobLike = (value) => isGlobLikeMatch.test(value);
9
- const nodeLoadersArgs = { import: ['r', 'experimental-loader', 'require', 'loader', 'test-reporter'] };
9
+ const nodeLoadersArgs = { import: ['r', 'experimental-loader', 'require', 'loader'] };
10
10
  export const resolve = (binary, _args, options) => {
11
11
  const { fromArgs, containingFilePath } = options;
12
12
  const [pluginName, pluginArgs] = pluginArgsMap.get(binary) ?? [];
@@ -208,11 +208,6 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
208
208
  entry?: string | string[] | undefined;
209
209
  project?: string | string[] | undefined;
210
210
  } | undefined;
211
- 'node-test-runner'?: string | boolean | string[] | {
212
- config?: string | string[] | undefined;
213
- entry?: string | string[] | undefined;
214
- project?: string | string[] | undefined;
215
- } | undefined;
216
211
  nodemon?: string | boolean | string[] | {
217
212
  config?: string | string[] | undefined;
218
213
  entry?: string | string[] | undefined;
@@ -283,6 +278,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
283
278
  entry?: string | string[] | undefined;
284
279
  project?: string | string[] | undefined;
285
280
  } | undefined;
281
+ 'react-router'?: string | boolean | string[] | {
282
+ config?: string | string[] | undefined;
283
+ entry?: string | string[] | undefined;
284
+ project?: string | string[] | undefined;
285
+ } | undefined;
286
286
  'release-it'?: string | boolean | string[] | {
287
287
  config?: string | string[] | undefined;
288
288
  entry?: string | string[] | undefined;
@@ -677,11 +677,6 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
677
677
  entry?: string | string[] | undefined;
678
678
  project?: string | string[] | undefined;
679
679
  } | undefined;
680
- 'node-test-runner'?: string | boolean | string[] | {
681
- config?: string | string[] | undefined;
682
- entry?: string | string[] | undefined;
683
- project?: string | string[] | undefined;
684
- } | undefined;
685
680
  nodemon?: string | boolean | string[] | {
686
681
  config?: string | string[] | undefined;
687
682
  entry?: string | string[] | undefined;
@@ -752,6 +747,11 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
752
747
  entry?: string | string[] | undefined;
753
748
  project?: string | string[] | undefined;
754
749
  } | undefined;
750
+ 'react-router'?: string | boolean | string[] | {
751
+ config?: string | string[] | undefined;
752
+ entry?: string | string[] | undefined;
753
+ project?: string | string[] | undefined;
754
+ } | undefined;
755
755
  'release-it'?: string | boolean | string[] | {
756
756
  config?: string | string[] | undefined;
757
757
  entry?: string | string[] | undefined;
package/dist/index.js CHANGED
@@ -34,7 +34,7 @@ export const main = async (unresolvedConfiguration) => {
34
34
  const streamer = new ConsoleStreamer({ isEnabled: isShowProgress });
35
35
  streamer.cast('Reading workspace configuration(s)...');
36
36
  await chief.init();
37
- const workspaces = chief.getIncludedWorkspaces();
37
+ const workspaces = chief.getWorkspaces();
38
38
  const report = chief.getIncludedIssueTypes({
39
39
  includedIssueTypes,
40
40
  excludedIssueTypes,
@@ -64,11 +64,11 @@ export const main = async (unresolvedConfiguration) => {
64
64
  const shouldIgnore = getShouldIgnoreHandler(isProduction);
65
65
  const shouldIgnoreTags = getShouldIgnoreTagHandler(tags);
66
66
  for (const workspace of workspaces) {
67
- const { name, dir, manifestPath } = workspace;
67
+ const { name, dir, manifestPath, manifestStr } = workspace;
68
68
  const manifest = chief.getManifestForWorkspace(name);
69
69
  if (!manifest)
70
70
  continue;
71
- deputy.addWorkspace({ name, cwd, dir, manifestPath, manifest, ...chief.getIgnores(name) });
71
+ deputy.addWorkspace({ name, cwd, dir, manifestPath, manifestStr, manifest, ...chief.getIgnores(name) });
72
72
  }
73
73
  for (const workspace of workspaces) {
74
74
  const { name, dir, ancestors, pkgName } = workspace;
@@ -1,4 +1,20 @@
1
- import type { PluginOptions } from '../../types/config.js';
2
- import { type Input } from '../../util/input.js';
1
+ import type { PluginOptions, ResolveConfig } from '../../types/config.js';
3
2
  import type { ExpoConfig } from './types.js';
4
- export declare const getDependencies: (localConfig: ExpoConfig, { manifest }: PluginOptions) => Promise<Input[]>;
3
+ export declare const getConfig: (localConfig: ExpoConfig, options: PluginOptions) => {
4
+ platforms?: ("ios" | "android" | "web")[];
5
+ notification?: Record<string, unknown>;
6
+ updates?: {
7
+ enabled?: boolean;
8
+ };
9
+ backgroundColor?: string;
10
+ userInterfaceStyle?: "automatic" | "light" | "dark";
11
+ ios?: {
12
+ backgroundColor?: string;
13
+ };
14
+ android?: {
15
+ userInterfaceStyle?: "automatic" | "light" | "dark";
16
+ };
17
+ androidNavigationBar?: Record<string, unknown>;
18
+ plugins?: (string | [string, Record<string, unknown>])[];
19
+ };
20
+ export declare const getDependencies: ResolveConfig<ExpoConfig>;
@@ -1,8 +1,21 @@
1
1
  import { toDependency, toProductionDependency } from '../../util/input.js';
2
2
  import { getPackageNameFromModuleSpecifier } from '../../util/modules.js';
3
- export const getDependencies = async (localConfig, { manifest }) => {
4
- const expoConfig = typeof localConfig === 'function' ? localConfig() : localConfig;
5
- const config = 'expo' in expoConfig ? expoConfig.expo : expoConfig;
3
+ import { join } from '../../util/path.js';
4
+ const getDummyConfigContext = (options) => ({
5
+ projectRoot: options.cwd,
6
+ staticConfigPath: null,
7
+ packageJsonPath: join(options.cwd, 'package.json'),
8
+ config: {
9
+ plugins: [],
10
+ },
11
+ });
12
+ export const getConfig = (localConfig, options) => {
13
+ const expoConfig = typeof localConfig === 'function' ? localConfig(getDummyConfigContext(options)) : localConfig;
14
+ return 'expo' in expoConfig ? expoConfig.expo : expoConfig;
15
+ };
16
+ export const getDependencies = async (localConfig, options) => {
17
+ const { manifest } = options;
18
+ const config = getConfig(localConfig, options);
6
19
  const platforms = config.platforms ?? ['ios', 'android'];
7
20
  const pluginPackages = config.plugins
8
21
  ?.map(plugin => {
@@ -1,16 +1,16 @@
1
1
  import { toProductionEntry } from '../../util/input.js';
2
2
  import { join } from '../../util/path.js';
3
3
  import { hasDependency } from '../../util/plugin.js';
4
- import { getDependencies } from './helpers.js';
4
+ import { getConfig, getDependencies } from './helpers.js';
5
5
  const title = 'Expo';
6
6
  const enablers = ['expo'];
7
7
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
8
8
  const config = ['app.json', 'app.config.{ts,js}'];
9
9
  const production = ['app/**/*.{js,jsx,ts,tsx}', 'src/app/**/*.{js,jsx,ts,tsx}'];
10
10
  export const docs = { production };
11
- const resolveEntryPaths = async (localConfig, { manifest }) => {
12
- const expoConfig = typeof localConfig === 'function' ? localConfig() : localConfig;
13
- const config = 'expo' in expoConfig ? expoConfig.expo : expoConfig;
11
+ const resolveEntryPaths = async (localConfig, options) => {
12
+ const { manifest } = options;
13
+ const config = getConfig(localConfig, options);
14
14
  if (manifest.main === 'expo-router/entry') {
15
15
  let patterns = [...production];
16
16
  const normalizedPlugins = config.plugins?.map(plugin => (Array.isArray(plugin) ? plugin : [plugin])) ?? [];