@monorepolint/rules 0.6.0-alpha.2 → 0.6.0-alpha.4
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/.turbo/turbo-clean.log +1 -1
- package/.turbo/turbo-compile-typescript.log +1 -1
- package/.turbo/turbo-lint.log +1 -1
- package/.turbo/turbo-test.log +161 -102
- package/.turbo/turbo-transpile-typescript.log +4 -4
- package/CHANGELOG.md +19 -0
- package/build/js/index.js +429 -241
- package/build/js/index.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/types/__tests__/utils.d.ts +0 -1
- package/build/types/__tests__/utils.d.ts.map +1 -1
- package/build/types/bannedDependencies.d.ts.map +1 -1
- package/build/types/fileContents.d.ts.map +1 -1
- package/build/types/forceError.d.ts +4 -0
- package/build/types/forceError.d.ts.map +1 -0
- package/build/types/index.d.ts +5 -3
- package/build/types/index.d.ts.map +1 -1
- package/build/types/mustSatisfyPeerDependencies.d.ts.map +1 -1
- package/build/types/nestedWorkspaces.d.ts.map +1 -1
- package/build/types/oncePerPackage.d.ts +11 -0
- package/build/types/oncePerPackage.d.ts.map +1 -0
- package/build/types/packageEntry.d.ts.map +1 -1
- package/build/types/packageOrder.d.ts.map +1 -1
- package/build/types/packageScript.d.ts.map +1 -1
- package/build/types/requireDependency.d.ts +12 -12
- package/build/types/requireDependency.d.ts.map +1 -1
- package/build/types/util/checkAlpha.d.ts.map +1 -1
- package/build/types/util/createRuleFactory.d.ts.map +1 -1
- package/build/types/util/packageDependencyGraphService.d.ts.map +1 -1
- package/coverage/clover.xml +1201 -813
- package/coverage/coverage-final.json +20 -18
- package/coverage/index.html +20 -20
- package/coverage/src/alphabeticalDependencies.ts.html +11 -11
- package/coverage/src/alphabeticalScripts.ts.html +5 -5
- package/coverage/src/bannedDependencies.ts.html +76 -28
- package/coverage/src/consistentDependencies.ts.html +51 -18
- package/coverage/src/consistentVersions.ts.html +144 -48
- package/coverage/src/fileContents.ts.html +47 -23
- package/coverage/src/forceError.ts.html +184 -0
- package/coverage/src/index.html +96 -66
- package/coverage/src/index.ts.html +39 -33
- package/coverage/src/mustSatisfyPeerDependencies.ts.html +323 -80
- package/coverage/src/nestedWorkspaces.ts.html +47 -20
- package/coverage/src/oncePerPackage.ts.html +181 -0
- package/coverage/src/packageEntry.ts.html +40 -19
- package/coverage/src/packageOrder.ts.html +30 -12
- package/coverage/src/packageScript.ts.html +81 -27
- package/coverage/src/requireDependency.ts.html +77 -32
- package/coverage/src/standardTsconfig.ts.html +84 -21
- package/coverage/src/util/checkAlpha.ts.html +18 -9
- package/coverage/src/util/createRuleFactory.ts.html +16 -4
- package/coverage/src/util/index.html +17 -17
- package/coverage/src/util/makeDirectory.ts.html +5 -5
- package/coverage/src/util/packageDependencyGraphService.ts.html +94 -19
- package/package.json +4 -5
- package/src/__tests__/alphabeticalScripts.spec.ts +12 -4
- package/src/__tests__/bannedDependencies.spec.ts +45 -16
- package/src/__tests__/consistentDependencies.spec.ts +11 -5
- package/src/__tests__/consistentVersions.spec.ts +72 -18
- package/src/__tests__/fileContents.spec.ts +5 -5
- package/src/__tests__/mustSatisfyPeerDependencies.spec.ts +191 -76
- package/src/__tests__/nestedWorkspaces.spec.ts +10 -7
- package/src/__tests__/packageEntry.spec.ts +48 -47
- package/src/__tests__/packageOrder.spec.ts +72 -71
- package/src/__tests__/packageScript.spec.ts +19 -10
- package/src/__tests__/requireDependency.spec.ts +12 -6
- package/src/__tests__/utils.ts +16 -7
- package/src/bannedDependencies.ts +32 -16
- package/src/consistentDependencies.ts +19 -8
- package/src/consistentVersions.ts +70 -38
- package/src/fileContents.ts +19 -11
- package/src/forceError.ts +33 -0
- package/src/index.ts +5 -3
- package/src/mustSatisfyPeerDependencies.ts +141 -60
- package/src/nestedWorkspaces.ts +19 -10
- package/src/oncePerPackage.ts +32 -0
- package/src/packageEntry.ts +18 -11
- package/src/packageOrder.ts +9 -3
- package/src/packageScript.ts +37 -19
- package/src/requireDependency.ts +26 -11
- package/src/standardTsconfig.ts +31 -10
- package/src/util/checkAlpha.ts +5 -2
- package/src/util/createRuleFactory.ts +6 -2
- package/src/util/packageDependencyGraphService.ts +38 -13
- package/vitest.config.mjs +6 -7
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
* Licensed under the MIT license. See LICENSE file in the project root for details.
|
|
5
5
|
*
|
|
6
6
|
*/
|
|
7
|
-
import { describe, expect, it, beforeEach, vi, afterEach } from "vitest";
|
|
8
7
|
import { WorkspaceContextImpl } from "@monorepolint/core";
|
|
9
8
|
import { SimpleHost } from "@monorepolint/utils";
|
|
10
9
|
import { writeFileSync } from "fs";
|
|
11
10
|
import * as path from "path";
|
|
12
11
|
import * as tmp from "tmp";
|
|
12
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
13
13
|
import { bannedDependencies, Options } from "../bannedDependencies.js";
|
|
14
14
|
import { makeDirectoryRecursively } from "../util/makeDirectory.js";
|
|
15
15
|
import { jsonToString } from "./utils.js";
|
|
@@ -46,7 +46,7 @@ describe("bannedDependencies", () => {
|
|
|
46
46
|
verbose: false,
|
|
47
47
|
silent: true,
|
|
48
48
|
},
|
|
49
|
-
new SimpleHost()
|
|
49
|
+
new SimpleHost(),
|
|
50
50
|
);
|
|
51
51
|
|
|
52
52
|
function checkAndSpy(options: Options) {
|
|
@@ -77,15 +77,21 @@ describe("bannedDependencies", () => {
|
|
|
77
77
|
});
|
|
78
78
|
addFile("./package.json", rootPackageJson);
|
|
79
79
|
|
|
80
|
-
const { addErrorSpy: addErrorSpy1 } = checkAndSpy({
|
|
80
|
+
const { addErrorSpy: addErrorSpy1 } = checkAndSpy({
|
|
81
|
+
bannedDependencies: ["ccc"],
|
|
82
|
+
});
|
|
81
83
|
expect(addErrorSpy1).toHaveBeenCalledTimes(1);
|
|
82
84
|
addErrorSpy1.mockReset();
|
|
83
85
|
|
|
84
|
-
const { addErrorSpy: addErrorSpy2 } = checkAndSpy({
|
|
86
|
+
const { addErrorSpy: addErrorSpy2 } = checkAndSpy({
|
|
87
|
+
bannedDependencies: ["ddd"],
|
|
88
|
+
});
|
|
85
89
|
expect(addErrorSpy2).toHaveBeenCalledTimes(0);
|
|
86
90
|
addErrorSpy2.mockReset();
|
|
87
91
|
|
|
88
|
-
const { addErrorSpy: addErrorSpy3 } = checkAndSpy({
|
|
92
|
+
const { addErrorSpy: addErrorSpy3 } = checkAndSpy({
|
|
93
|
+
bannedDependencies: ["ccc", "ddd"],
|
|
94
|
+
});
|
|
89
95
|
expect(addErrorSpy3).toHaveBeenCalledTimes(1);
|
|
90
96
|
addErrorSpy3.mockReset();
|
|
91
97
|
});
|
|
@@ -100,15 +106,21 @@ describe("bannedDependencies", () => {
|
|
|
100
106
|
});
|
|
101
107
|
addFile("./package.json", rootPackageJson);
|
|
102
108
|
|
|
103
|
-
const { addErrorSpy: addErrorSpy1 } = checkAndSpy({
|
|
109
|
+
const { addErrorSpy: addErrorSpy1 } = checkAndSpy({
|
|
110
|
+
bannedDependencies: ["c*c"],
|
|
111
|
+
});
|
|
104
112
|
expect(addErrorSpy1).toHaveBeenCalledTimes(1);
|
|
105
113
|
addErrorSpy1.mockReset();
|
|
106
114
|
|
|
107
|
-
const { addErrorSpy: addErrorSpy2 } = checkAndSpy({
|
|
115
|
+
const { addErrorSpy: addErrorSpy2 } = checkAndSpy({
|
|
116
|
+
bannedDependencies: ["d*d"],
|
|
117
|
+
});
|
|
108
118
|
expect(addErrorSpy2).toHaveBeenCalledTimes(0);
|
|
109
119
|
addErrorSpy2.mockReset();
|
|
110
120
|
|
|
111
|
-
const { addErrorSpy: addErrorSpy3 } = checkAndSpy({
|
|
121
|
+
const { addErrorSpy: addErrorSpy3 } = checkAndSpy({
|
|
122
|
+
bannedDependencies: ["c*c", "d*d"],
|
|
123
|
+
});
|
|
112
124
|
expect(addErrorSpy3).toHaveBeenCalledTimes(1);
|
|
113
125
|
addErrorSpy3.mockReset();
|
|
114
126
|
});
|
|
@@ -123,15 +135,21 @@ describe("bannedDependencies", () => {
|
|
|
123
135
|
});
|
|
124
136
|
addFile("./package.json", rootPackageJson);
|
|
125
137
|
|
|
126
|
-
const { addErrorSpy: addErrorSpy1 } = checkAndSpy({
|
|
138
|
+
const { addErrorSpy: addErrorSpy1 } = checkAndSpy({
|
|
139
|
+
bannedDependencies: { glob: ["c*c"] },
|
|
140
|
+
});
|
|
127
141
|
expect(addErrorSpy1).toHaveBeenCalledTimes(1);
|
|
128
142
|
addErrorSpy1.mockReset();
|
|
129
143
|
|
|
130
|
-
const { addErrorSpy: addErrorSpy2 } = checkAndSpy({
|
|
144
|
+
const { addErrorSpy: addErrorSpy2 } = checkAndSpy({
|
|
145
|
+
bannedDependencies: { glob: ["d*d"] },
|
|
146
|
+
});
|
|
131
147
|
expect(addErrorSpy2).toHaveBeenCalledTimes(0);
|
|
132
148
|
addErrorSpy2.mockReset();
|
|
133
149
|
|
|
134
|
-
const { addErrorSpy: addErrorSpy3 } = checkAndSpy({
|
|
150
|
+
const { addErrorSpy: addErrorSpy3 } = checkAndSpy({
|
|
151
|
+
bannedDependencies: { glob: ["c*c", "d*d"] },
|
|
152
|
+
});
|
|
135
153
|
expect(addErrorSpy3).toHaveBeenCalledTimes(1);
|
|
136
154
|
addErrorSpy3.mockReset();
|
|
137
155
|
});
|
|
@@ -146,15 +164,21 @@ describe("bannedDependencies", () => {
|
|
|
146
164
|
});
|
|
147
165
|
addFile("./package.json", rootPackageJson);
|
|
148
166
|
|
|
149
|
-
const { addErrorSpy: addErrorSpy1 } = checkAndSpy({
|
|
167
|
+
const { addErrorSpy: addErrorSpy1 } = checkAndSpy({
|
|
168
|
+
bannedDependencies: { exact: ["ccc"] },
|
|
169
|
+
});
|
|
150
170
|
expect(addErrorSpy1).toHaveBeenCalledTimes(1);
|
|
151
171
|
addErrorSpy1.mockReset();
|
|
152
172
|
|
|
153
|
-
const { addErrorSpy: addErrorSpy2 } = checkAndSpy({
|
|
173
|
+
const { addErrorSpy: addErrorSpy2 } = checkAndSpy({
|
|
174
|
+
bannedDependencies: { exact: ["ddd"] },
|
|
175
|
+
});
|
|
154
176
|
expect(addErrorSpy2).toHaveBeenCalledTimes(0);
|
|
155
177
|
addErrorSpy2.mockReset();
|
|
156
178
|
|
|
157
|
-
const { addErrorSpy: addErrorSpy3 } = checkAndSpy({
|
|
179
|
+
const { addErrorSpy: addErrorSpy3 } = checkAndSpy({
|
|
180
|
+
bannedDependencies: { exact: ["ccc", "ddd"] },
|
|
181
|
+
});
|
|
158
182
|
expect(addErrorSpy3).toHaveBeenCalledTimes(1);
|
|
159
183
|
addErrorSpy3.mockReset();
|
|
160
184
|
});
|
|
@@ -181,9 +205,14 @@ describe("bannedDependencies", () => {
|
|
|
181
205
|
},
|
|
182
206
|
});
|
|
183
207
|
addFile("./node_modules/aaa/node_modules/bbb/package.json", bbbPackageJson);
|
|
184
|
-
addFile(
|
|
208
|
+
addFile(
|
|
209
|
+
"./node_modules/aaa/node_modules/bbb/node_modules/ddd/package.json",
|
|
210
|
+
EMPTY_PACKAGE,
|
|
211
|
+
);
|
|
185
212
|
addFile("./node_modules/aaa/node_modules/ccc/package.json", EMPTY_PACKAGE);
|
|
186
213
|
|
|
187
|
-
expect(
|
|
214
|
+
expect(
|
|
215
|
+
checkAndSpy({ bannedTransitiveDependencies: ["ccc", "ddd"] }).addErrorSpy,
|
|
216
|
+
).toHaveBeenCalledTimes(2);
|
|
188
217
|
});
|
|
189
218
|
});
|
|
@@ -9,10 +9,10 @@ import { SimpleHost } from "@monorepolint/utils";
|
|
|
9
9
|
import { readFileSync, writeFileSync } from "fs";
|
|
10
10
|
import * as path from "path";
|
|
11
11
|
import * as tmp from "tmp";
|
|
12
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
12
13
|
import { consistentDependencies, Options } from "../consistentDependencies.js";
|
|
13
14
|
import { makeDirectoryRecursively } from "../util/makeDirectory.js";
|
|
14
15
|
import { jsonToString } from "./utils.js";
|
|
15
|
-
import { describe, expect, it, afterEach, vi } from "vitest";
|
|
16
16
|
|
|
17
17
|
const PACKAGE_ROOT = jsonToString({
|
|
18
18
|
workspaces: {
|
|
@@ -71,11 +71,13 @@ describe("consistentDependencies", () => {
|
|
|
71
71
|
verbose: false,
|
|
72
72
|
silent: true,
|
|
73
73
|
},
|
|
74
|
-
new SimpleHost()
|
|
74
|
+
new SimpleHost(),
|
|
75
75
|
);
|
|
76
76
|
|
|
77
77
|
function checkAndSpy(q: string, opts?: Options) {
|
|
78
|
-
const context = workspaceContext.createChildContext(
|
|
78
|
+
const context = workspaceContext.createChildContext(
|
|
79
|
+
path.resolve(dir.name, q),
|
|
80
|
+
);
|
|
79
81
|
const addErrorSpy = vi.spyOn(context, "addError");
|
|
80
82
|
consistentDependencies({ options: opts }).check(context);
|
|
81
83
|
return { context, addErrorSpy };
|
|
@@ -97,7 +99,9 @@ describe("consistentDependencies", () => {
|
|
|
97
99
|
}
|
|
98
100
|
|
|
99
101
|
it("checks correctly", () => {
|
|
100
|
-
const { addFile, workspaceContext, checkAndSpy } = makeWorkspace({
|
|
102
|
+
const { addFile, workspaceContext, checkAndSpy } = makeWorkspace({
|
|
103
|
+
fix: false,
|
|
104
|
+
});
|
|
101
105
|
addFile("./package.json", PACKAGE_ROOT);
|
|
102
106
|
addFile("./packages/star/package.json", PACKAGE_CHILD_WITH_STAR);
|
|
103
107
|
addFile("./packages/latest/package.json", PACKAGE_CHILD_WITH_LATEST);
|
|
@@ -136,7 +140,9 @@ describe("consistentDependencies", () => {
|
|
|
136
140
|
addFile("./package.json", PACKAGE_ROOT);
|
|
137
141
|
addFile("./packages/wrong/package.json", PACKAGE_CHILD_WITH_WRONG_VERSION);
|
|
138
142
|
|
|
139
|
-
const ignored = checkAndSpy("./packages/wrong", {
|
|
143
|
+
const ignored = checkAndSpy("./packages/wrong", {
|
|
144
|
+
ignoredDependencies: ["foo"],
|
|
145
|
+
});
|
|
140
146
|
expect(ignored.addErrorSpy).toHaveBeenCalledTimes(0);
|
|
141
147
|
});
|
|
142
148
|
});
|
|
@@ -9,9 +9,9 @@ import { WorkspaceContextImpl } from "@monorepolint/core";
|
|
|
9
9
|
import { Host, PackageJson, SimpleHost } from "@monorepolint/utils";
|
|
10
10
|
import * as path from "path";
|
|
11
11
|
import * as tmp from "tmp";
|
|
12
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
12
13
|
import { consistentVersions, Options } from "../consistentVersions.js";
|
|
13
14
|
import { makeDirectoryRecursively } from "../util/makeDirectory.js";
|
|
14
|
-
import { describe, expect, it, beforeEach, afterEach, vi } from "vitest";
|
|
15
15
|
|
|
16
16
|
describe("consistentVersions", () => {
|
|
17
17
|
tmp.setGracefulCleanup();
|
|
@@ -45,7 +45,7 @@ describe("consistentVersions", () => {
|
|
|
45
45
|
verbose: false,
|
|
46
46
|
silent: true,
|
|
47
47
|
},
|
|
48
|
-
host
|
|
48
|
+
host,
|
|
49
49
|
);
|
|
50
50
|
const addErrorSpy = vi.spyOn(workspaceContext, "addError");
|
|
51
51
|
|
|
@@ -56,7 +56,11 @@ describe("consistentVersions", () => {
|
|
|
56
56
|
return { addErrorSpy, check, host };
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
function addPackageJson(
|
|
59
|
+
function addPackageJson(
|
|
60
|
+
host: Host,
|
|
61
|
+
filePath: string,
|
|
62
|
+
packageJson: PackageJson,
|
|
63
|
+
) {
|
|
60
64
|
const dirPath = path.resolve(cwd!, path.dirname(filePath));
|
|
61
65
|
const resolvedFilePath = path.resolve(cwd!, filePath);
|
|
62
66
|
|
|
@@ -99,15 +103,24 @@ describe("consistentVersions", () => {
|
|
|
99
103
|
|
|
100
104
|
it("Fixes packages that have an incorrect dependency version", async () => {
|
|
101
105
|
const { addErrorSpy, check, host } = makeWorkspace(true);
|
|
102
|
-
const readTestPackageJson = addPackageJson(
|
|
106
|
+
const readTestPackageJson = addPackageJson(
|
|
107
|
+
host,
|
|
108
|
+
"./package.json",
|
|
109
|
+
testPackageJson,
|
|
110
|
+
);
|
|
103
111
|
|
|
104
112
|
const requiredGreatLibVersion = "1.2.3";
|
|
105
113
|
expect(addErrorSpy).toHaveBeenCalledTimes(0);
|
|
106
114
|
check({
|
|
107
|
-
matchDependencyVersions: {
|
|
115
|
+
matchDependencyVersions: {
|
|
116
|
+
both: testPackageJson.dependencies!.both,
|
|
117
|
+
greatLib: requiredGreatLibVersion,
|
|
118
|
+
},
|
|
108
119
|
});
|
|
109
120
|
expect(addErrorSpy).toHaveBeenCalledTimes(1);
|
|
110
|
-
expect(readTestPackageJson().dependencies!.greatLib).toEqual(
|
|
121
|
+
expect(readTestPackageJson().dependencies!.greatLib).toEqual(
|
|
122
|
+
requiredGreatLibVersion,
|
|
123
|
+
);
|
|
111
124
|
});
|
|
112
125
|
|
|
113
126
|
it("Ignores packages that have a correct dependency version", async () => {
|
|
@@ -126,13 +139,24 @@ describe("consistentVersions", () => {
|
|
|
126
139
|
|
|
127
140
|
it("Fixes packages that have an incorrect devDependency version", async () => {
|
|
128
141
|
const { addErrorSpy, check, host } = makeWorkspace(true);
|
|
129
|
-
const readTestPackageJson = addPackageJson(
|
|
142
|
+
const readTestPackageJson = addPackageJson(
|
|
143
|
+
host,
|
|
144
|
+
"./package.json",
|
|
145
|
+
testPackageJson,
|
|
146
|
+
);
|
|
130
147
|
|
|
131
148
|
const requiredElseLibVersion = "1.2.3";
|
|
132
149
|
expect(addErrorSpy).toHaveBeenCalledTimes(0);
|
|
133
|
-
check({
|
|
150
|
+
check({
|
|
151
|
+
matchDependencyVersions: {
|
|
152
|
+
both: testPackageJson.dependencies!.both,
|
|
153
|
+
else: requiredElseLibVersion,
|
|
154
|
+
},
|
|
155
|
+
});
|
|
134
156
|
expect(addErrorSpy).toHaveBeenCalledTimes(1);
|
|
135
|
-
expect(readTestPackageJson().devDependencies!.else).toEqual(
|
|
157
|
+
expect(readTestPackageJson().devDependencies!.else).toEqual(
|
|
158
|
+
requiredElseLibVersion,
|
|
159
|
+
);
|
|
136
160
|
});
|
|
137
161
|
|
|
138
162
|
it("Ignores packages that have a correct devDependency version", async () => {
|
|
@@ -151,14 +175,22 @@ describe("consistentVersions", () => {
|
|
|
151
175
|
|
|
152
176
|
it("Fixes packages that have an incorrect dependency and devDependency versions", async () => {
|
|
153
177
|
const { addErrorSpy, check, host } = makeWorkspace(true);
|
|
154
|
-
const readTestPackageJson = addPackageJson(
|
|
178
|
+
const readTestPackageJson = addPackageJson(
|
|
179
|
+
host,
|
|
180
|
+
"./package.json",
|
|
181
|
+
testPackageJson,
|
|
182
|
+
);
|
|
155
183
|
|
|
156
184
|
const requiredBothVersion = "1.2.3";
|
|
157
185
|
expect(addErrorSpy).toHaveBeenCalledTimes(0);
|
|
158
186
|
check({ matchDependencyVersions: { both: requiredBothVersion } });
|
|
159
187
|
expect(addErrorSpy).toHaveBeenCalledTimes(2);
|
|
160
|
-
expect(readTestPackageJson().dependencies!.both).toEqual(
|
|
161
|
-
|
|
188
|
+
expect(readTestPackageJson().dependencies!.both).toEqual(
|
|
189
|
+
requiredBothVersion,
|
|
190
|
+
);
|
|
191
|
+
expect(readTestPackageJson().devDependencies!.both).toEqual(
|
|
192
|
+
requiredBothVersion,
|
|
193
|
+
);
|
|
162
194
|
});
|
|
163
195
|
});
|
|
164
196
|
|
|
@@ -187,13 +219,35 @@ describe("consistentVersions", () => {
|
|
|
187
219
|
addPackageJson(host, "./package.json", testPackageJson);
|
|
188
220
|
|
|
189
221
|
expect(addErrorSpy).toHaveBeenCalledTimes(0);
|
|
190
|
-
check({
|
|
222
|
+
check({
|
|
223
|
+
matchDependencyVersions: {
|
|
224
|
+
greatLib: [testPackageJson.dependencies!.greatLib],
|
|
225
|
+
},
|
|
226
|
+
});
|
|
191
227
|
expect(addErrorSpy).toHaveBeenCalledTimes(0);
|
|
192
|
-
check({
|
|
228
|
+
check({
|
|
229
|
+
matchDependencyVersions: {
|
|
230
|
+
greatLib: ["1", "2", testPackageJson.dependencies!.greatLib],
|
|
231
|
+
},
|
|
232
|
+
});
|
|
193
233
|
expect(addErrorSpy).toHaveBeenCalledTimes(0);
|
|
194
|
-
check({
|
|
234
|
+
check({
|
|
235
|
+
matchDependencyVersions: {
|
|
236
|
+
greatLib: [
|
|
237
|
+
"1",
|
|
238
|
+
"2",
|
|
239
|
+
testPackageJson.dependencies!.greatLib,
|
|
240
|
+
"99",
|
|
241
|
+
"100",
|
|
242
|
+
],
|
|
243
|
+
},
|
|
244
|
+
});
|
|
195
245
|
expect(addErrorSpy).toHaveBeenCalledTimes(0);
|
|
196
|
-
check({
|
|
246
|
+
check({
|
|
247
|
+
matchDependencyVersions: {
|
|
248
|
+
greatLib: [testPackageJson.dependencies!.greatLib, "99", "100"],
|
|
249
|
+
},
|
|
250
|
+
});
|
|
197
251
|
expect(addErrorSpy).toHaveBeenCalledTimes(0);
|
|
198
252
|
});
|
|
199
253
|
|
|
@@ -212,12 +266,12 @@ describe("consistentVersions", () => {
|
|
|
212
266
|
expect(addErrorSpy.mock.calls[0][0].message).toEqual(
|
|
213
267
|
`Expected dependency on both to match one of '["99","100"]', got '${
|
|
214
268
|
testPackageJson.dependencies!.both
|
|
215
|
-
}' instead
|
|
269
|
+
}' instead.`,
|
|
216
270
|
);
|
|
217
271
|
expect(addErrorSpy.mock.calls[1][0].message).toEqual(
|
|
218
272
|
`Expected devDependency on both to match one of '["99","100"]', got '${
|
|
219
273
|
testPackageJson.devDependencies!.both
|
|
220
|
-
}' instead
|
|
274
|
+
}' instead.`,
|
|
221
275
|
);
|
|
222
276
|
});
|
|
223
277
|
});
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
// tslint:disable:no-console
|
|
9
|
-
import { createTestingWorkspace, HOST_FACTORIES, TestingWorkspace } from "./utils.js";
|
|
10
9
|
import { AddErrorOptions, Failure } from "@monorepolint/config";
|
|
10
|
+
import { beforeEach, describe, expect, it, MockInstance, vi } from "vitest";
|
|
11
11
|
import { fileContents } from "../fileContents.js";
|
|
12
|
-
import {
|
|
12
|
+
import { createTestingWorkspace, HOST_FACTORIES, TestingWorkspace } from "./utils.js";
|
|
13
13
|
|
|
14
14
|
const EXPECTED_FOO_FILE = "hello world";
|
|
15
15
|
|
|
@@ -44,7 +44,7 @@ describe.each(HOST_FACTORIES)("fileContents ($name)", (hostFactory) => {
|
|
|
44
44
|
file: "foo.txt",
|
|
45
45
|
hasFixer: true,
|
|
46
46
|
message: "Expect file contents to match",
|
|
47
|
-
})
|
|
47
|
+
}),
|
|
48
48
|
);
|
|
49
49
|
|
|
50
50
|
expect(workspace.readFile("foo.txt")).toEqual(EXPECTED_FOO_FILE);
|
|
@@ -68,7 +68,7 @@ describe.each(HOST_FACTORIES)("fileContents ($name)", (hostFactory) => {
|
|
|
68
68
|
file: "foo.txt",
|
|
69
69
|
hasFixer: true,
|
|
70
70
|
message: "Expect file contents to match",
|
|
71
|
-
})
|
|
71
|
+
}),
|
|
72
72
|
);
|
|
73
73
|
|
|
74
74
|
expect(workspace.readFile("foo.txt")).toEqual(EXPECTED_FOO_FILE);
|
|
@@ -92,7 +92,7 @@ describe.each(HOST_FACTORIES)("fileContents ($name)", (hostFactory) => {
|
|
|
92
92
|
file: "nested/foo.txt",
|
|
93
93
|
hasFixer: true,
|
|
94
94
|
message: "Expect file contents to match",
|
|
95
|
-
})
|
|
95
|
+
}),
|
|
96
96
|
);
|
|
97
97
|
|
|
98
98
|
expect(workspace.readFile("nested/foo.txt")).toEqual(EXPECTED_FOO_FILE);
|