@monorepolint/rules 0.6.0-alpha.1 → 0.6.0-alpha.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.
Files changed (87) hide show
  1. package/.turbo/turbo-clean.log +1 -1
  2. package/.turbo/turbo-compile-typescript.log +1 -1
  3. package/.turbo/turbo-lint.log +1 -1
  4. package/.turbo/turbo-test.log +272 -667
  5. package/.turbo/turbo-transpile-typescript.log +5 -5
  6. package/CHANGELOG.md +42 -0
  7. package/build/js/index.js +411 -263
  8. package/build/js/index.js.map +1 -1
  9. package/build/tsconfig.tsbuildinfo +1 -1
  10. package/build/types/__tests__/utils.d.ts +4 -10
  11. package/build/types/__tests__/utils.d.ts.map +1 -1
  12. package/build/types/bannedDependencies.d.ts.map +1 -1
  13. package/build/types/fileContents.d.ts +1 -1
  14. package/build/types/fileContents.d.ts.map +1 -1
  15. package/build/types/index.d.ts +3 -3
  16. package/build/types/index.d.ts.map +1 -1
  17. package/build/types/mustSatisfyPeerDependencies.d.ts.map +1 -1
  18. package/build/types/nestedWorkspaces.d.ts.map +1 -1
  19. package/build/types/packageEntry.d.ts.map +1 -1
  20. package/build/types/packageOrder.d.ts.map +1 -1
  21. package/build/types/packageScript.d.ts.map +1 -1
  22. package/build/types/requireDependency.d.ts +12 -12
  23. package/build/types/requireDependency.d.ts.map +1 -1
  24. package/build/types/standardTsconfig.d.ts.map +1 -1
  25. package/build/types/util/checkAlpha.d.ts.map +1 -1
  26. package/build/types/util/createRuleFactory.d.ts.map +1 -1
  27. package/build/types/util/packageDependencyGraphService.d.ts.map +1 -1
  28. package/coverage/base.css +224 -0
  29. package/coverage/block-navigation.js +87 -0
  30. package/coverage/clover.xml +1887 -0
  31. package/coverage/coverage-final.json +19 -0
  32. package/coverage/favicon.png +0 -0
  33. package/coverage/index.html +131 -0
  34. package/coverage/prettify.css +1 -0
  35. package/coverage/prettify.js +2 -0
  36. package/coverage/sort-arrow-sprite.png +0 -0
  37. package/coverage/sorter.js +196 -0
  38. package/coverage/src/alphabeticalDependencies.ts.html +142 -0
  39. package/coverage/src/alphabeticalScripts.ts.html +136 -0
  40. package/coverage/src/bannedDependencies.ts.html +610 -0
  41. package/coverage/src/consistentDependencies.ts.html +394 -0
  42. package/coverage/src/consistentVersions.ts.html +619 -0
  43. package/coverage/src/fileContents.ts.html +409 -0
  44. package/coverage/src/index.html +311 -0
  45. package/coverage/src/index.ts.html +169 -0
  46. package/coverage/src/mustSatisfyPeerDependencies.ts.html +2605 -0
  47. package/coverage/src/nestedWorkspaces.ts.html +304 -0
  48. package/coverage/src/packageEntry.ts.html +376 -0
  49. package/coverage/src/packageOrder.ts.html +472 -0
  50. package/coverage/src/packageScript.ts.html +436 -0
  51. package/coverage/src/requireDependency.ts.html +349 -0
  52. package/coverage/src/standardTsconfig.ts.html +553 -0
  53. package/coverage/src/util/checkAlpha.ts.html +271 -0
  54. package/coverage/src/util/createRuleFactory.ts.html +196 -0
  55. package/coverage/src/util/index.html +161 -0
  56. package/coverage/src/util/makeDirectory.ts.html +157 -0
  57. package/coverage/src/util/packageDependencyGraphService.ts.html +508 -0
  58. package/package.json +15 -20
  59. package/src/__tests__/alphabeticalScripts.spec.ts +13 -5
  60. package/src/__tests__/bannedDependencies.spec.ts +47 -18
  61. package/src/__tests__/consistentDependencies.spec.ts +12 -6
  62. package/src/__tests__/consistentVersions.spec.ts +74 -20
  63. package/src/__tests__/fileContents.spec.ts +11 -7
  64. package/src/__tests__/mustSatisfyPeerDependencies.spec.ts +193 -78
  65. package/src/__tests__/nestedWorkspaces.spec.ts +12 -8
  66. package/src/__tests__/packageEntry.spec.ts +55 -49
  67. package/src/__tests__/packageOrder.spec.ts +78 -72
  68. package/src/__tests__/packageScript.spec.ts +27 -13
  69. package/src/__tests__/requireDependency.spec.ts +13 -7
  70. package/src/__tests__/utils.ts +18 -9
  71. package/src/bannedDependencies.ts +32 -15
  72. package/src/consistentDependencies.ts +22 -9
  73. package/src/consistentVersions.ts +84 -47
  74. package/src/fileContents.ts +24 -10
  75. package/src/index.ts +3 -3
  76. package/src/mustSatisfyPeerDependencies.ts +162 -66
  77. package/src/nestedWorkspaces.ts +23 -10
  78. package/src/packageEntry.ts +18 -11
  79. package/src/packageOrder.ts +9 -3
  80. package/src/packageScript.ts +37 -19
  81. package/src/requireDependency.ts +28 -11
  82. package/src/standardTsconfig.ts +32 -10
  83. package/src/util/checkAlpha.ts +5 -2
  84. package/src/util/createRuleFactory.ts +6 -2
  85. package/src/util/packageDependencyGraphService.ts +41 -14
  86. package/vitest.config.mjs +17 -0
  87. package/jest.config.cjs +0 -4
@@ -8,50 +8,56 @@
8
8
  // tslint:disable:no-console
9
9
 
10
10
  import { Context, Failure } from "@monorepolint/config";
11
- import { createExpectedEntryErrorMessage, createStandardizedEntryErrorMessage, packageEntry } from "../packageEntry.js";
12
- import { AddErrorSpy, createTestingWorkspace, HOST_FACTORIES, TestingWorkspace } from "./utils.js";
13
- import { describe, expect, it, beforeEach, afterEach, jest } from "@jest/globals";
14
-
15
- const PACKAGE_MISSING_ENTRY =
16
- JSON.stringify(
17
- {
18
- name: "package",
19
- version: {},
20
- scripts: {},
21
- dependencies: {},
11
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
12
+ import {
13
+ createExpectedEntryErrorMessage,
14
+ createStandardizedEntryErrorMessage,
15
+ packageEntry,
16
+ } from "../packageEntry.js";
17
+ import {
18
+ AddErrorSpy,
19
+ createTestingWorkspace,
20
+ HOST_FACTORIES,
21
+ TestingWorkspace,
22
+ } from "./utils.js";
23
+
24
+ const PACKAGE_MISSING_ENTRY = JSON.stringify(
25
+ {
26
+ name: "package",
27
+ version: {},
28
+ scripts: {},
29
+ dependencies: {},
30
+ },
31
+ undefined,
32
+ 2,
33
+ ) + "\n";
34
+
35
+ const PACKAGE_LICENSE = JSON.stringify(
36
+ {
37
+ name: "package",
38
+ version: {},
39
+ scripts: {},
40
+ dependencies: {},
41
+ license: "UNLICENSED",
42
+ },
43
+ undefined,
44
+ 2,
45
+ ) + "\n";
46
+
47
+ const PACKAGE_REPOSITORY = JSON.stringify(
48
+ {
49
+ name: "package",
50
+ version: {},
51
+ scripts: {},
52
+ dependencies: {},
53
+ repository: {
54
+ type: "git",
55
+ url: "https://github.com:foo/foo",
22
56
  },
23
- undefined,
24
- 2
25
- ) + "\n";
26
-
27
- const PACKAGE_LICENSE =
28
- JSON.stringify(
29
- {
30
- name: "package",
31
- version: {},
32
- scripts: {},
33
- dependencies: {},
34
- license: "UNLICENSED",
35
- },
36
- undefined,
37
- 2
38
- ) + "\n";
39
-
40
- const PACKAGE_REPOSITORY =
41
- JSON.stringify(
42
- {
43
- name: "package",
44
- version: {},
45
- scripts: {},
46
- dependencies: {},
47
- repository: {
48
- type: "git",
49
- url: "https://github.com:foo/foo",
50
- },
51
- },
52
- undefined,
53
- 2
54
- ) + "\n";
57
+ },
58
+ undefined,
59
+ 2,
60
+ ) + "\n";
55
61
 
56
62
  describe.each(HOST_FACTORIES)("expectPackageEntries ($name)", (hostFactory) => {
57
63
  describe("fix: true", () => {
@@ -66,7 +72,7 @@ describe.each(HOST_FACTORIES)("expectPackageEntries ($name)", (hostFactory) => {
66
72
  });
67
73
  context = workspace.context; // minimizing delta
68
74
 
69
- spy = jest.spyOn(workspace.context, "addError");
75
+ spy = vi.spyOn(workspace.context, "addError");
70
76
  });
71
77
 
72
78
  afterEach(() => {
@@ -93,7 +99,7 @@ describe.each(HOST_FACTORIES)("expectPackageEntries ($name)", (hostFactory) => {
93
99
  file: "package.json",
94
100
  hasFixer: true,
95
101
  message: createStandardizedEntryErrorMessage("license"),
96
- })
102
+ }),
97
103
  );
98
104
 
99
105
  expect(workspace.readFile("package.json")).toEqual(PACKAGE_LICENSE);
@@ -122,7 +128,7 @@ describe.each(HOST_FACTORIES)("expectPackageEntries ($name)", (hostFactory) => {
122
128
  file: "package.json",
123
129
  hasFixer: true,
124
130
  message: createStandardizedEntryErrorMessage("repository"),
125
- })
131
+ }),
126
132
  );
127
133
 
128
134
  expect(workspace.readFile("package.json")).toEqual(PACKAGE_REPOSITORY);
@@ -165,7 +171,7 @@ describe.each(HOST_FACTORIES)("expectPackageEntries ($name)", (hostFactory) => {
165
171
  file: "package.json",
166
172
  hasFixer: false,
167
173
  message: createExpectedEntryErrorMessage("bugs"),
168
- })
174
+ }),
169
175
  );
170
176
  expect(workspace.readFile("package.json")).toEqual(PACKAGE_REPOSITORY);
171
177
  });
@@ -193,7 +199,7 @@ describe.each(HOST_FACTORIES)("expectPackageEntries ($name)", (hostFactory) => {
193
199
  file: "package.json",
194
200
  hasFixer: true,
195
201
  message: createStandardizedEntryErrorMessage("repository"),
196
- })
202
+ }),
197
203
  );
198
204
 
199
205
  const failure2: Failure = spy.mock.calls[1][0];
@@ -202,7 +208,7 @@ describe.each(HOST_FACTORIES)("expectPackageEntries ($name)", (hostFactory) => {
202
208
  file: "package.json",
203
209
  hasFixer: false,
204
210
  message: createExpectedEntryErrorMessage("bugs"),
205
- })
211
+ }),
206
212
  );
207
213
 
208
214
  expect(workspace.readFile("package.json")).toEqual(PACKAGE_REPOSITORY);
@@ -6,36 +6,39 @@
6
6
  */
7
7
 
8
8
  // tslint:disable:no-console
9
- import { AddErrorSpy, createTestingWorkspace, HOST_FACTORIES, TestingWorkspace } from "./utils.js";
10
9
  import { Context, Failure } from "@monorepolint/config";
10
+ import { beforeEach, describe, expect, it, vi } from "vitest";
11
11
  import { packageOrder } from "../packageOrder.js";
12
- import { describe, expect, it, beforeEach, jest } from "@jest/globals";
13
-
14
- const PACKAGE_UNORDERED =
15
- JSON.stringify(
16
- {
17
- scripts: {},
18
- dependencies: {},
19
- version: {},
20
- name: "package",
21
- },
22
- undefined,
23
- 2
24
- ) + "\n";
25
-
26
- const PACKAGE_UNORDERED_UNKOWN_KEYS =
27
- JSON.stringify(
28
- {
29
- butter: false,
30
- apple: false,
31
- scripts: {},
32
- dependencies: {},
33
- version: {},
34
- name: "package-unknown-keys",
35
- },
36
- undefined,
37
- 2
38
- ) + "\n";
12
+ import {
13
+ AddErrorSpy,
14
+ createTestingWorkspace,
15
+ HOST_FACTORIES,
16
+ TestingWorkspace,
17
+ } from "./utils.js";
18
+
19
+ const PACKAGE_UNORDERED = JSON.stringify(
20
+ {
21
+ scripts: {},
22
+ dependencies: {},
23
+ version: {},
24
+ name: "package",
25
+ },
26
+ undefined,
27
+ 2,
28
+ ) + "\n";
29
+
30
+ const PACKAGE_UNORDERED_UNKOWN_KEYS = JSON.stringify(
31
+ {
32
+ butter: false,
33
+ apple: false,
34
+ scripts: {},
35
+ dependencies: {},
36
+ version: {},
37
+ name: "package-unknown-keys",
38
+ },
39
+ undefined,
40
+ 2,
41
+ ) + "\n";
39
42
 
40
43
  const orderArray = ["name", "version", "scripts", "dependencies"];
41
44
 
@@ -44,43 +47,40 @@ const orderFunction = (_context: Context) => (a: string, b: string) => {
44
47
  return b.length - a.length || a.localeCompare(b);
45
48
  };
46
49
 
47
- const PACKAGE_ORDERED =
48
- JSON.stringify(
49
- {
50
- name: "package",
51
- version: {},
52
- scripts: {},
53
- dependencies: {},
54
- },
55
- undefined,
56
- 2
57
- ) + "\n";
58
-
59
- const PACKAGE_ORDERED_BY_LENGTH =
60
- JSON.stringify(
61
- {
62
- dependencies: {},
63
- scripts: {},
64
- version: {},
65
- name: "package",
66
- },
67
- undefined,
68
- 2
69
- ) + "\n";
70
-
71
- const PACKAGE_ORDERED_UNKOWN_KEYS =
72
- JSON.stringify(
73
- {
74
- name: "package-unknown-keys",
75
- version: {},
76
- scripts: {},
77
- dependencies: {},
78
- apple: false,
79
- butter: false,
80
- },
81
- undefined,
82
- 2
83
- ) + "\n";
50
+ const PACKAGE_ORDERED = JSON.stringify(
51
+ {
52
+ name: "package",
53
+ version: {},
54
+ scripts: {},
55
+ dependencies: {},
56
+ },
57
+ undefined,
58
+ 2,
59
+ ) + "\n";
60
+
61
+ const PACKAGE_ORDERED_BY_LENGTH = JSON.stringify(
62
+ {
63
+ dependencies: {},
64
+ scripts: {},
65
+ version: {},
66
+ name: "package",
67
+ },
68
+ undefined,
69
+ 2,
70
+ ) + "\n";
71
+
72
+ const PACKAGE_ORDERED_UNKOWN_KEYS = JSON.stringify(
73
+ {
74
+ name: "package-unknown-keys",
75
+ version: {},
76
+ scripts: {},
77
+ dependencies: {},
78
+ apple: false,
79
+ butter: false,
80
+ },
81
+ undefined,
82
+ 2,
83
+ ) + "\n";
84
84
 
85
85
  describe.each(HOST_FACTORIES)("expectPackageOrder ($name)", (hostFactory) => {
86
86
  describe("fix: true", () => {
@@ -95,7 +95,7 @@ describe.each(HOST_FACTORIES)("expectPackageOrder ($name)", (hostFactory) => {
95
95
  });
96
96
  context = workspace.context; // minimizing delta
97
97
 
98
- spy = jest.spyOn(workspace.context, "addError");
98
+ spy = vi.spyOn(workspace.context, "addError");
99
99
  });
100
100
 
101
101
  it("fixes order for expected keys", () => {
@@ -115,7 +115,7 @@ describe.each(HOST_FACTORIES)("expectPackageOrder ($name)", (hostFactory) => {
115
115
  file: "package.json",
116
116
  hasFixer: true,
117
117
  message: "Incorrect order of fields in package.json",
118
- })
118
+ }),
119
119
  );
120
120
 
121
121
  expect(workspace.readFile("package.json")).toEqual(PACKAGE_ORDERED);
@@ -138,10 +138,12 @@ describe.each(HOST_FACTORIES)("expectPackageOrder ($name)", (hostFactory) => {
138
138
  file: "package.json",
139
139
  hasFixer: true,
140
140
  message: "Incorrect order of fields in package.json",
141
- })
141
+ }),
142
142
  );
143
143
 
144
- expect(workspace.readFile("package.json")).toEqual(PACKAGE_ORDERED_UNKOWN_KEYS);
144
+ expect(workspace.readFile("package.json")).toEqual(
145
+ PACKAGE_ORDERED_UNKOWN_KEYS,
146
+ );
145
147
  });
146
148
 
147
149
  it("fixes order using function", () => {
@@ -161,10 +163,12 @@ describe.each(HOST_FACTORIES)("expectPackageOrder ($name)", (hostFactory) => {
161
163
  file: "package.json",
162
164
  hasFixer: true,
163
165
  message: "Incorrect order of fields in package.json",
164
- })
166
+ }),
165
167
  );
166
168
 
167
- expect(workspace.readFile("package.json")).toEqual(PACKAGE_ORDERED_BY_LENGTH);
169
+ expect(workspace.readFile("package.json")).toEqual(
170
+ PACKAGE_ORDERED_BY_LENGTH,
171
+ );
168
172
  });
169
173
 
170
174
  it("does nothing if already order", () => {
@@ -178,7 +182,9 @@ describe.each(HOST_FACTORIES)("expectPackageOrder ($name)", (hostFactory) => {
178
182
 
179
183
  expect(spy).not.toHaveBeenCalled();
180
184
 
181
- expect(workspace.readFile("package.json")).toEqual(PACKAGE_ORDERED_UNKOWN_KEYS);
185
+ expect(workspace.readFile("package.json")).toEqual(
186
+ PACKAGE_ORDERED_UNKOWN_KEYS,
187
+ );
182
188
  });
183
189
  });
184
190
  });
@@ -6,10 +6,15 @@
6
6
  */
7
7
 
8
8
  // tslint:disable:no-console
9
- import { describe, expect, it, beforeEach, jest } from "@jest/globals";
10
9
  import { Context, Failure } from "@monorepolint/config";
10
+ import { beforeEach, describe, expect, it, vi } from "vitest";
11
11
  import { packageScript } from "../packageScript.js";
12
- import { AddErrorSpy, createTestingWorkspace, HOST_FACTORIES, TestingWorkspace } from "./utils.js";
12
+ import {
13
+ AddErrorSpy,
14
+ createTestingWorkspace,
15
+ HOST_FACTORIES,
16
+ TestingWorkspace,
17
+ } from "./utils.js";
13
18
 
14
19
  const json = (a: unknown) => JSON.stringify(a, undefined, 2) + "\n";
15
20
 
@@ -41,7 +46,7 @@ describe.each(HOST_FACTORIES)("expectPackageScript ($name)", (hostFactory) => {
41
46
  host: hostFactory.make(),
42
47
  });
43
48
 
44
- spy = jest.spyOn(workspace.context, "addError");
49
+ spy = vi.spyOn(workspace.context, "addError");
45
50
  });
46
51
 
47
52
  it("handles an empty script section", () => {
@@ -63,7 +68,7 @@ describe.each(HOST_FACTORIES)("expectPackageScript ($name)", (hostFactory) => {
63
68
  file: "package.json",
64
69
  hasFixer: true,
65
70
  message: "No scripts block in package.json",
66
- })
71
+ }),
67
72
  );
68
73
  });
69
74
  });
@@ -79,7 +84,7 @@ describe.each(HOST_FACTORIES)("expectPackageScript ($name)", (hostFactory) => {
79
84
  host: hostFactory.make(),
80
85
  });
81
86
 
82
- spy = jest.spyOn(workspace.context, "addError");
87
+ spy = vi.spyOn(workspace.context, "addError");
83
88
  context = workspace.context; // minimizing delta
84
89
  });
85
90
 
@@ -102,10 +107,12 @@ describe.each(HOST_FACTORIES)("expectPackageScript ($name)", (hostFactory) => {
102
107
  file: "package.json",
103
108
  hasFixer: true,
104
109
  message: "No scripts block in package.json",
105
- })
110
+ }),
106
111
  );
107
112
 
108
- expect(JSON.parse(workspace.readFile("package.json")!).scripts).toEqual({});
113
+ expect(JSON.parse(workspace.readFile("package.json")!).scripts).toEqual(
114
+ {},
115
+ );
109
116
  });
110
117
 
111
118
  it("adds a script", () => {
@@ -127,13 +134,16 @@ describe.each(HOST_FACTORIES)("expectPackageScript ($name)", (hostFactory) => {
127
134
  file: "package.json",
128
135
  hasFixer: true,
129
136
  message: expect.stringContaining(
130
- `Expected standardized script entry for '${MISSING_SCRIPT_NAME}'`
137
+ `Expected standardized script entry for '${MISSING_SCRIPT_NAME}'`,
131
138
  ) as unknown as string,
132
- })
139
+ }),
133
140
  );
134
141
 
135
- expect(JSON.parse(workspace.readFile("package.json")!).scripts[MISSING_SCRIPT_NAME]).toEqual(
136
- MISSING_SCRIPT_VALUE
142
+ expect(
143
+ JSON.parse(workspace.readFile("package.json")!)
144
+ .scripts[MISSING_SCRIPT_NAME],
145
+ ).toEqual(
146
+ MISSING_SCRIPT_VALUE,
137
147
  );
138
148
  });
139
149
 
@@ -218,7 +228,9 @@ describe.each(HOST_FACTORIES)("expectPackageScript ($name)", (hostFactory) => {
218
228
  expect(errors.length).toBe(1);
219
229
  expect(errors[0][0].fixer).toBeDefined();
220
230
 
221
- expect(JSON.parse(workspace.readFile("package.json")!).scripts).toEqual({});
231
+ expect(JSON.parse(workspace.readFile("package.json")!).scripts).toEqual(
232
+ {},
233
+ );
222
234
  });
223
235
 
224
236
  it("can allow only empty", () => {
@@ -240,7 +252,9 @@ describe.each(HOST_FACTORIES)("expectPackageScript ($name)", (hostFactory) => {
240
252
  expect(errors.length).toBe(1);
241
253
  expect(errors[0][0].fixer).toBeDefined();
242
254
 
243
- expect(JSON.parse(workspace.readFile("package.json")!).scripts).toEqual({});
255
+ expect(JSON.parse(workspace.readFile("package.json")!).scripts).toEqual(
256
+ {},
257
+ );
244
258
  });
245
259
  });
246
260
  });
@@ -9,10 +9,10 @@ import { SimpleHost } from "@monorepolint/utils";
9
9
  import { readFileSync, writeFileSync } from "node:fs";
10
10
  import * as path from "node:path";
11
11
  import * as tmp from "tmp";
12
+ import { afterEach, describe, expect, it, vi } from "vitest";
12
13
  import { requireDependency } from "../requireDependency.js";
13
14
  import { makeDirectoryRecursively } from "../util/makeDirectory.js";
14
15
  import { jsonToString } from "./utils.js";
15
- import { describe, expect, it, afterEach, jest } from "@jest/globals";
16
16
 
17
17
  const PACKAGE_ROOT = jsonToString({
18
18
  workspaces: {
@@ -36,6 +36,7 @@ const PACKAGE_WITH_WRONG_ENTRIES = jsonToString({
36
36
  },
37
37
  devDependencies: {
38
38
  bar: "1.0.0",
39
+ baz: "1.0.0",
39
40
  },
40
41
  });
41
42
 
@@ -54,6 +55,7 @@ const OPTIONS = {
54
55
  },
55
56
  devDependencies: {
56
57
  bar: "^2.0.0",
58
+ baz: undefined,
57
59
  },
58
60
  } as const;
59
61
 
@@ -83,12 +85,14 @@ describe("requireDependency", () => {
83
85
  verbose: false,
84
86
  silent: true,
85
87
  },
86
- new SimpleHost()
88
+ new SimpleHost(),
87
89
  );
88
90
 
89
91
  function checkAndSpy(q: string) {
90
- const context = workspaceContext.createChildContext(path.resolve(dir.name, q));
91
- const addErrorSpy = jest.spyOn(context, "addError");
92
+ const context = workspaceContext.createChildContext(
93
+ path.resolve(dir.name, q),
94
+ );
95
+ const addErrorSpy = vi.spyOn(context, "addError");
92
96
  requireDependency({ options: OPTIONS }).check(context);
93
97
  return { context, addErrorSpy };
94
98
  }
@@ -109,7 +113,9 @@ describe("requireDependency", () => {
109
113
  }
110
114
 
111
115
  it("checks correctly", () => {
112
- const { addFile, workspaceContext, checkAndSpy } = makeWorkspace({ fix: false });
116
+ const { addFile, workspaceContext, checkAndSpy } = makeWorkspace({
117
+ fix: false,
118
+ });
113
119
  addFile("./package.json", PACKAGE_ROOT);
114
120
  addFile("./packages/none/package.json", PACKAGE_WITH_NO_ENTRIES);
115
121
  addFile("./packages/missing/package.json", PACKAGE_WITH_ENTRIES_MISSING);
@@ -125,7 +131,7 @@ describe("requireDependency", () => {
125
131
  expect(missing.addErrorSpy).toHaveBeenCalledTimes(2);
126
132
 
127
133
  const wrong = checkAndSpy("./packages/wrong");
128
- expect(wrong.addErrorSpy).toHaveBeenCalledTimes(2);
134
+ expect(wrong.addErrorSpy).toHaveBeenCalledTimes(3);
129
135
 
130
136
  const right = checkAndSpy("./packages/right");
131
137
  expect(right.addErrorSpy).toHaveBeenCalledTimes(0);
@@ -141,7 +147,7 @@ describe("requireDependency", () => {
141
147
  expect(missing.addErrorSpy).toHaveBeenCalledTimes(2);
142
148
 
143
149
  const wrong = checkAndSpy("./packages/wrong");
144
- expect(wrong.addErrorSpy).toHaveBeenCalledTimes(2);
150
+ expect(wrong.addErrorSpy).toHaveBeenCalledTimes(3);
145
151
 
146
152
  const missingContents = readFile("./packages/missing/package.json");
147
153
  expect(missingContents).toEqual(CORRECT_OUTPUT);
@@ -8,9 +8,9 @@
8
8
  import { AddErrorOptions, WorkspaceContext } from "@monorepolint/config";
9
9
  import { WorkspaceContextImpl } from "@monorepolint/core";
10
10
  import { CachingHost, Host, SimpleHost } from "@monorepolint/utils";
11
- import { expect, jest } from "@jest/globals";
12
11
  import * as path from "node:path";
13
12
  import * as tmp from "tmp";
13
+ import { expect, MockInstance } from "vitest";
14
14
 
15
15
  export function jsonToString(obj: unknown) {
16
16
  return JSON.stringify(obj, undefined, 2) + "\n";
@@ -22,7 +22,9 @@ interface TestingWorkspaceOpts {
22
22
  fixFlag: boolean;
23
23
  }
24
24
 
25
- export async function createTestingWorkspace(inboundOpts: TestingWorkspaceOpts) {
25
+ export async function createTestingWorkspace(
26
+ inboundOpts: TestingWorkspaceOpts,
27
+ ) {
26
28
  tmp.setGracefulCleanup();
27
29
  const tmpdir = tmp.dirSync();
28
30
  const opts = {
@@ -43,7 +45,11 @@ export async function createTestingWorkspace(inboundOpts: TestingWorkspaceOpts)
43
45
 
44
46
  return new DefaultTestingWorkspace(
45
47
  { ...opts, rootPath },
46
- new WorkspaceContextImpl(rootPath, { fix: opts.fixFlag, rules: [] }, opts.host)
48
+ new WorkspaceContextImpl(
49
+ rootPath,
50
+ { fix: opts.fixFlag, rules: [] },
51
+ opts.host,
52
+ ),
47
53
  );
48
54
  }
49
55
 
@@ -67,10 +73,11 @@ export interface TestingWorkspace {
67
73
  readFile(filePath: string): string;
68
74
 
69
75
  /**
70
- * Helper method for matching failures via jest `expect().toMatchObject
71
- *
76
+ * Helper method for matching failures via vi `expect().toMatchObject
72
77
  */
73
- failureMatcher(opts: { file: string; message: string; hasFixer: boolean }): any;
78
+ failureMatcher(
79
+ opts: { file: string; message: string; hasFixer: boolean },
80
+ ): any;
74
81
 
75
82
  readonly context: WorkspaceContext;
76
83
  }
@@ -78,7 +85,7 @@ export interface TestingWorkspace {
78
85
  class DefaultTestingWorkspace implements TestingWorkspace {
79
86
  constructor(
80
87
  private opts: RealTestingWorkspaceOpts,
81
- public readonly context: WorkspaceContext
88
+ public readonly context: WorkspaceContext,
82
89
  ) {}
83
90
 
84
91
  addProject(name: string, fields: object) {
@@ -110,7 +117,9 @@ class DefaultTestingWorkspace implements TestingWorkspace {
110
117
  }
111
118
 
112
119
  readFile(filePath: string) {
113
- return this.opts.host.readFile(this.getFilePath(filePath), { encoding: "utf-8" });
120
+ return this.opts.host.readFile(this.getFilePath(filePath), {
121
+ encoding: "utf-8",
122
+ });
114
123
  }
115
124
 
116
125
  failureMatcher(opts: { file: string; message: string; hasFixer: boolean }) {
@@ -122,7 +131,7 @@ class DefaultTestingWorkspace implements TestingWorkspace {
122
131
  }
123
132
  }
124
133
 
125
- export type AddErrorSpy = jest.SpiedFunction<(options: AddErrorOptions) => void>;
134
+ export type AddErrorSpy = MockInstance<(options: AddErrorOptions) => void>;
126
135
 
127
136
  export const HOST_FACTORIES: Array<{ name: string; make: () => Host }> = [
128
137
  { name: "SimpleHost", make: () => new SimpleHost() },