@monorepolint/rules 0.6.0-alpha.1 → 0.6.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +212 -667
- package/.turbo/turbo-transpile-typescript.log +5 -5
- package/CHANGELOG.md +33 -0
- package/build/js/index.js +12 -17
- package/build/js/index.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/types/__tests__/utils.d.ts +4 -9
- package/build/types/__tests__/utils.d.ts.map +1 -1
- package/build/types/fileContents.d.ts +1 -1
- package/build/types/fileContents.d.ts.map +1 -1
- package/build/types/standardTsconfig.d.ts.map +1 -1
- package/coverage/base.css +224 -0
- package/coverage/block-navigation.js +87 -0
- package/coverage/clover.xml +1546 -0
- package/coverage/coverage-final.json +19 -0
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +131 -0
- package/coverage/prettify.css +1 -0
- package/coverage/prettify.js +2 -0
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +196 -0
- package/coverage/src/alphabeticalDependencies.ts.html +142 -0
- package/coverage/src/alphabeticalScripts.ts.html +136 -0
- package/coverage/src/bannedDependencies.ts.html +559 -0
- package/coverage/src/consistentDependencies.ts.html +355 -0
- package/coverage/src/consistentVersions.ts.html +508 -0
- package/coverage/src/fileContents.ts.html +385 -0
- package/coverage/src/index.html +311 -0
- package/coverage/src/index.ts.html +169 -0
- package/coverage/src/mustSatisfyPeerDependencies.ts.html +2317 -0
- package/coverage/src/nestedWorkspaces.ts.html +265 -0
- package/coverage/src/packageEntry.ts.html +355 -0
- package/coverage/src/packageOrder.ts.html +454 -0
- package/coverage/src/packageScript.ts.html +382 -0
- package/coverage/src/requireDependency.ts.html +298 -0
- package/coverage/src/standardTsconfig.ts.html +490 -0
- package/coverage/src/util/checkAlpha.ts.html +262 -0
- package/coverage/src/util/createRuleFactory.ts.html +184 -0
- package/coverage/src/util/index.html +161 -0
- package/coverage/src/util/makeDirectory.ts.html +157 -0
- package/coverage/src/util/packageDependencyGraphService.ts.html +427 -0
- package/package.json +16 -20
- package/src/__tests__/alphabeticalScripts.spec.ts +2 -2
- package/src/__tests__/bannedDependencies.spec.ts +3 -3
- package/src/__tests__/consistentDependencies.spec.ts +2 -2
- package/src/__tests__/consistentVersions.spec.ts +3 -3
- package/src/__tests__/fileContents.spec.ts +3 -3
- package/src/__tests__/mustSatisfyPeerDependencies.spec.ts +3 -3
- package/src/__tests__/nestedWorkspaces.spec.ts +3 -3
- package/src/__tests__/packageEntry.spec.ts +2 -2
- package/src/__tests__/packageOrder.spec.ts +2 -2
- package/src/__tests__/packageScript.spec.ts +3 -3
- package/src/__tests__/requireDependency.spec.ts +2 -2
- package/src/__tests__/utils.ts +3 -3
- package/src/fileContents.ts +9 -3
- package/src/standardTsconfig.ts +1 -0
- package/vitest.config.mjs +14 -0
- package/jest.config.cjs +0 -4
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
// tslint:disable:no-console
|
|
9
|
-
import { describe, expect, it, beforeEach,
|
|
9
|
+
import { describe, expect, it, beforeEach, vi } from "vitest";
|
|
10
10
|
import { AddErrorSpy, createTestingWorkspace, HOST_FACTORIES, jsonToString, TestingWorkspace } from "./utils.js";
|
|
11
11
|
import { Context, Failure } from "@monorepolint/config";
|
|
12
12
|
import { alphabeticalScripts } from "../alphabeticalScripts.js";
|
|
@@ -43,7 +43,7 @@ describe.each(HOST_FACTORIES)("alphabeticalScripts ($name)", (hostFactory) => {
|
|
|
43
43
|
});
|
|
44
44
|
context = workspace.context; // minimizing delta
|
|
45
45
|
|
|
46
|
-
spy =
|
|
46
|
+
spy = vi.spyOn(workspace.context, "addError");
|
|
47
47
|
});
|
|
48
48
|
|
|
49
49
|
it("fixes unsorted scripts", () => {
|
|
@@ -4,7 +4,7 @@
|
|
|
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,
|
|
7
|
+
import { describe, expect, it, beforeEach, vi, afterEach } from "vitest";
|
|
8
8
|
import { WorkspaceContextImpl } from "@monorepolint/core";
|
|
9
9
|
import { SimpleHost } from "@monorepolint/utils";
|
|
10
10
|
import { writeFileSync } from "fs";
|
|
@@ -26,7 +26,7 @@ describe("bannedDependencies", () => {
|
|
|
26
26
|
cleanupJobs.push(() => dir.removeCallback());
|
|
27
27
|
cwd = dir.name;
|
|
28
28
|
|
|
29
|
-
const spy =
|
|
29
|
+
const spy = vi.spyOn(process, "cwd");
|
|
30
30
|
spy.mockReturnValue(cwd);
|
|
31
31
|
});
|
|
32
32
|
|
|
@@ -50,7 +50,7 @@ describe("bannedDependencies", () => {
|
|
|
50
50
|
);
|
|
51
51
|
|
|
52
52
|
function checkAndSpy(options: Options) {
|
|
53
|
-
const addErrorSpy =
|
|
53
|
+
const addErrorSpy = vi.spyOn(workspaceContext, "addError");
|
|
54
54
|
bannedDependencies({ options }).check(workspaceContext);
|
|
55
55
|
return { addErrorSpy };
|
|
56
56
|
}
|
|
@@ -12,7 +12,7 @@ import * as tmp from "tmp";
|
|
|
12
12
|
import { consistentDependencies, Options } from "../consistentDependencies.js";
|
|
13
13
|
import { makeDirectoryRecursively } from "../util/makeDirectory.js";
|
|
14
14
|
import { jsonToString } from "./utils.js";
|
|
15
|
-
import { describe, expect, it, afterEach,
|
|
15
|
+
import { describe, expect, it, afterEach, vi } from "vitest";
|
|
16
16
|
|
|
17
17
|
const PACKAGE_ROOT = jsonToString({
|
|
18
18
|
workspaces: {
|
|
@@ -76,7 +76,7 @@ describe("consistentDependencies", () => {
|
|
|
76
76
|
|
|
77
77
|
function checkAndSpy(q: string, opts?: Options) {
|
|
78
78
|
const context = workspaceContext.createChildContext(path.resolve(dir.name, q));
|
|
79
|
-
const addErrorSpy =
|
|
79
|
+
const addErrorSpy = vi.spyOn(context, "addError");
|
|
80
80
|
consistentDependencies({ options: opts }).check(context);
|
|
81
81
|
return { context, addErrorSpy };
|
|
82
82
|
}
|
|
@@ -11,7 +11,7 @@ import * as path from "path";
|
|
|
11
11
|
import * as tmp from "tmp";
|
|
12
12
|
import { consistentVersions, Options } from "../consistentVersions.js";
|
|
13
13
|
import { makeDirectoryRecursively } from "../util/makeDirectory.js";
|
|
14
|
-
import { describe, expect, it, beforeEach, afterEach,
|
|
14
|
+
import { describe, expect, it, beforeEach, afterEach, vi } from "vitest";
|
|
15
15
|
|
|
16
16
|
describe("consistentVersions", () => {
|
|
17
17
|
tmp.setGracefulCleanup();
|
|
@@ -24,7 +24,7 @@ describe("consistentVersions", () => {
|
|
|
24
24
|
cleanupJobs.push(() => dir.removeCallback());
|
|
25
25
|
cwd = dir.name;
|
|
26
26
|
|
|
27
|
-
const spy =
|
|
27
|
+
const spy = vi.spyOn(process, "cwd");
|
|
28
28
|
spy.mockReturnValue(cwd);
|
|
29
29
|
});
|
|
30
30
|
|
|
@@ -47,7 +47,7 @@ describe("consistentVersions", () => {
|
|
|
47
47
|
},
|
|
48
48
|
host
|
|
49
49
|
);
|
|
50
|
-
const addErrorSpy =
|
|
50
|
+
const addErrorSpy = vi.spyOn(workspaceContext, "addError");
|
|
51
51
|
|
|
52
52
|
function check(options: Options = { matchDependencyVersions: {} }) {
|
|
53
53
|
consistentVersions({ options }).check(workspaceContext);
|
|
@@ -9,14 +9,14 @@
|
|
|
9
9
|
import { createTestingWorkspace, HOST_FACTORIES, TestingWorkspace } from "./utils.js";
|
|
10
10
|
import { AddErrorOptions, Failure } from "@monorepolint/config";
|
|
11
11
|
import { fileContents } from "../fileContents.js";
|
|
12
|
-
import { describe, expect, it, beforeEach,
|
|
12
|
+
import { describe, expect, it, beforeEach, vi, MockInstance } from "vitest";
|
|
13
13
|
|
|
14
14
|
const EXPECTED_FOO_FILE = "hello world";
|
|
15
15
|
|
|
16
16
|
describe.each(HOST_FACTORIES)("fileContents ($name)", (hostFactory) => {
|
|
17
17
|
describe("fix: true", () => {
|
|
18
18
|
let workspace: TestingWorkspace;
|
|
19
|
-
let spy:
|
|
19
|
+
let spy: MockInstance<(opts: AddErrorOptions) => void>;
|
|
20
20
|
|
|
21
21
|
beforeEach(async () => {
|
|
22
22
|
workspace = await createTestingWorkspace({
|
|
@@ -25,7 +25,7 @@ describe.each(HOST_FACTORIES)("fileContents ($name)", (hostFactory) => {
|
|
|
25
25
|
});
|
|
26
26
|
workspace.writeFile("shared/foo-template.txt", EXPECTED_FOO_FILE);
|
|
27
27
|
|
|
28
|
-
spy =
|
|
28
|
+
spy = vi.spyOn(workspace.context, "addError");
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
it("works with async generator", async () => {
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
RANGE_REGEX,
|
|
22
22
|
} from "../mustSatisfyPeerDependencies.js";
|
|
23
23
|
import { makeDirectoryRecursively } from "../util/makeDirectory.js";
|
|
24
|
-
import { describe, expect, it, beforeEach, afterEach,
|
|
24
|
+
import { describe, expect, it, beforeEach, afterEach, vi } from "vitest";
|
|
25
25
|
|
|
26
26
|
const doesASatisfyB = (a: string, b: string) => {
|
|
27
27
|
if (!isValidRange(a)) {
|
|
@@ -54,7 +54,7 @@ describe("mustSatisfyPeerDependencies", () => {
|
|
|
54
54
|
cleanupJobs.push(() => dir.removeCallback());
|
|
55
55
|
cwd = dir.name;
|
|
56
56
|
|
|
57
|
-
const spy =
|
|
57
|
+
const spy = vi.spyOn(process, "cwd");
|
|
58
58
|
spy.mockReturnValue(cwd);
|
|
59
59
|
});
|
|
60
60
|
|
|
@@ -77,7 +77,7 @@ describe("mustSatisfyPeerDependencies", () => {
|
|
|
77
77
|
},
|
|
78
78
|
host
|
|
79
79
|
);
|
|
80
|
-
const addErrorSpy =
|
|
80
|
+
const addErrorSpy = vi.spyOn(workspaceContext, "addError");
|
|
81
81
|
|
|
82
82
|
async function check(options: Options) {
|
|
83
83
|
await mustSatisfyPeerDependencies({ options }).check(workspaceContext);
|
|
@@ -12,7 +12,7 @@ import * as tmp from "tmp";
|
|
|
12
12
|
import { nestedWorkspaces } from "../nestedWorkspaces.js";
|
|
13
13
|
import { makeDirectoryRecursively } from "../util/makeDirectory.js";
|
|
14
14
|
import { jsonToString } from "./utils.js";
|
|
15
|
-
import { describe, expect, it, beforeEach, afterEach,
|
|
15
|
+
import { describe, expect, it, beforeEach, afterEach, vi } from "vitest";
|
|
16
16
|
|
|
17
17
|
const EMPTY_PACKAGE = jsonToString({});
|
|
18
18
|
|
|
@@ -45,7 +45,7 @@ describe("nestedWorkspaces", () => {
|
|
|
45
45
|
cleanupJobs.push(() => dir.removeCallback());
|
|
46
46
|
cwd = dir.name;
|
|
47
47
|
|
|
48
|
-
const spy =
|
|
48
|
+
const spy = vi.spyOn(process, "cwd");
|
|
49
49
|
spy.mockReturnValue(cwd);
|
|
50
50
|
});
|
|
51
51
|
|
|
@@ -70,7 +70,7 @@ describe("nestedWorkspaces", () => {
|
|
|
70
70
|
);
|
|
71
71
|
|
|
72
72
|
async function checkAndSpy() {
|
|
73
|
-
const addErrorSpy =
|
|
73
|
+
const addErrorSpy = vi.spyOn(workspaceContext, "addError");
|
|
74
74
|
|
|
75
75
|
await nestedWorkspaces({}).check(workspaceContext);
|
|
76
76
|
return { addErrorSpy };
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
import { Context, Failure } from "@monorepolint/config";
|
|
11
11
|
import { createExpectedEntryErrorMessage, createStandardizedEntryErrorMessage, packageEntry } from "../packageEntry.js";
|
|
12
12
|
import { AddErrorSpy, createTestingWorkspace, HOST_FACTORIES, TestingWorkspace } from "./utils.js";
|
|
13
|
-
import { describe, expect, it, beforeEach, afterEach,
|
|
13
|
+
import { describe, expect, it, beforeEach, afterEach, vi } from "vitest";
|
|
14
14
|
|
|
15
15
|
const PACKAGE_MISSING_ENTRY =
|
|
16
16
|
JSON.stringify(
|
|
@@ -66,7 +66,7 @@ describe.each(HOST_FACTORIES)("expectPackageEntries ($name)", (hostFactory) => {
|
|
|
66
66
|
});
|
|
67
67
|
context = workspace.context; // minimizing delta
|
|
68
68
|
|
|
69
|
-
spy =
|
|
69
|
+
spy = vi.spyOn(workspace.context, "addError");
|
|
70
70
|
});
|
|
71
71
|
|
|
72
72
|
afterEach(() => {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import { AddErrorSpy, createTestingWorkspace, HOST_FACTORIES, TestingWorkspace } from "./utils.js";
|
|
10
10
|
import { Context, Failure } from "@monorepolint/config";
|
|
11
11
|
import { packageOrder } from "../packageOrder.js";
|
|
12
|
-
import { describe, expect, it, beforeEach,
|
|
12
|
+
import { describe, expect, it, beforeEach, vi } from "vitest";
|
|
13
13
|
|
|
14
14
|
const PACKAGE_UNORDERED =
|
|
15
15
|
JSON.stringify(
|
|
@@ -95,7 +95,7 @@ describe.each(HOST_FACTORIES)("expectPackageOrder ($name)", (hostFactory) => {
|
|
|
95
95
|
});
|
|
96
96
|
context = workspace.context; // minimizing delta
|
|
97
97
|
|
|
98
|
-
spy =
|
|
98
|
+
spy = vi.spyOn(workspace.context, "addError");
|
|
99
99
|
});
|
|
100
100
|
|
|
101
101
|
it("fixes order for expected keys", () => {
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
// tslint:disable:no-console
|
|
9
|
-
import { describe, expect, it, beforeEach,
|
|
9
|
+
import { describe, expect, it, beforeEach, vi } from "vitest";
|
|
10
10
|
import { Context, Failure } from "@monorepolint/config";
|
|
11
11
|
import { packageScript } from "../packageScript.js";
|
|
12
12
|
import { AddErrorSpy, createTestingWorkspace, HOST_FACTORIES, TestingWorkspace } from "./utils.js";
|
|
@@ -41,7 +41,7 @@ describe.each(HOST_FACTORIES)("expectPackageScript ($name)", (hostFactory) => {
|
|
|
41
41
|
host: hostFactory.make(),
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
-
spy =
|
|
44
|
+
spy = vi.spyOn(workspace.context, "addError");
|
|
45
45
|
});
|
|
46
46
|
|
|
47
47
|
it("handles an empty script section", () => {
|
|
@@ -79,7 +79,7 @@ describe.each(HOST_FACTORIES)("expectPackageScript ($name)", (hostFactory) => {
|
|
|
79
79
|
host: hostFactory.make(),
|
|
80
80
|
});
|
|
81
81
|
|
|
82
|
-
spy =
|
|
82
|
+
spy = vi.spyOn(workspace.context, "addError");
|
|
83
83
|
context = workspace.context; // minimizing delta
|
|
84
84
|
});
|
|
85
85
|
|
|
@@ -12,7 +12,7 @@ import * as tmp from "tmp";
|
|
|
12
12
|
import { requireDependency } from "../requireDependency.js";
|
|
13
13
|
import { makeDirectoryRecursively } from "../util/makeDirectory.js";
|
|
14
14
|
import { jsonToString } from "./utils.js";
|
|
15
|
-
import { describe, expect, it, afterEach,
|
|
15
|
+
import { describe, expect, it, afterEach, vi } from "vitest";
|
|
16
16
|
|
|
17
17
|
const PACKAGE_ROOT = jsonToString({
|
|
18
18
|
workspaces: {
|
|
@@ -88,7 +88,7 @@ describe("requireDependency", () => {
|
|
|
88
88
|
|
|
89
89
|
function checkAndSpy(q: string) {
|
|
90
90
|
const context = workspaceContext.createChildContext(path.resolve(dir.name, q));
|
|
91
|
-
const addErrorSpy =
|
|
91
|
+
const addErrorSpy = vi.spyOn(context, "addError");
|
|
92
92
|
requireDependency({ options: OPTIONS }).check(context);
|
|
93
93
|
return { context, addErrorSpy };
|
|
94
94
|
}
|
package/src/__tests__/utils.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
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,
|
|
11
|
+
import { expect, MockInstance } from "vitest";
|
|
12
12
|
import * as path from "node:path";
|
|
13
13
|
import * as tmp from "tmp";
|
|
14
14
|
|
|
@@ -67,7 +67,7 @@ export interface TestingWorkspace {
|
|
|
67
67
|
readFile(filePath: string): string;
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
|
-
* Helper method for matching failures via
|
|
70
|
+
* Helper method for matching failures via vi `expect().toMatchObject
|
|
71
71
|
*
|
|
72
72
|
*/
|
|
73
73
|
failureMatcher(opts: { file: string; message: string; hasFixer: boolean }): any;
|
|
@@ -122,7 +122,7 @@ class DefaultTestingWorkspace implements TestingWorkspace {
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
export type AddErrorSpy =
|
|
125
|
+
export type AddErrorSpy = MockInstance<(options: AddErrorOptions) => void>;
|
|
126
126
|
|
|
127
127
|
export const HOST_FACTORIES: Array<{ name: string; make: () => Host }> = [
|
|
128
128
|
{ name: "SimpleHost", make: () => new SimpleHost() },
|
package/src/fileContents.ts
CHANGED
|
@@ -21,7 +21,7 @@ const Options = r.Union(
|
|
|
21
21
|
r.Record({
|
|
22
22
|
file: r.String,
|
|
23
23
|
generator: r.Undefined.optional(),
|
|
24
|
-
template: r.String,
|
|
24
|
+
template: r.String.Or(r.Undefined),
|
|
25
25
|
templateFile: r.Undefined.optional(),
|
|
26
26
|
}),
|
|
27
27
|
|
|
@@ -44,10 +44,16 @@ export const fileContents = createRuleFactory<Options>({
|
|
|
44
44
|
const pathExists = context.host.exists(fullPath);
|
|
45
45
|
const actualContent = pathExists ? context.host.readFile(fullPath, { encoding: "utf-8" }) : undefined;
|
|
46
46
|
if (actualContent !== expectedContent) {
|
|
47
|
+
const longMessage =
|
|
48
|
+
pathExists && expectedContent == undefined ? undefined : diff(expectedContent, actualContent, { expand: true });
|
|
49
|
+
|
|
50
|
+
const message =
|
|
51
|
+
pathExists && expectedContent == undefined ? "File should not exist" : "Expect file contents to match";
|
|
52
|
+
|
|
47
53
|
context.addError({
|
|
48
54
|
file: fullPath,
|
|
49
|
-
message
|
|
50
|
-
longMessage
|
|
55
|
+
message,
|
|
56
|
+
longMessage,
|
|
51
57
|
fixer: () => {
|
|
52
58
|
if (expectedContent === undefined) {
|
|
53
59
|
if (pathExists) context.host.deleteFile(fullPath);
|
package/src/standardTsconfig.ts
CHANGED
|
@@ -39,6 +39,7 @@ const Options = r
|
|
|
39
39
|
return count === 1 || "Expect one of { generator, template, templateFile }";
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
42
43
|
export interface Options extends r.Static<typeof Options> {}
|
|
43
44
|
|
|
44
45
|
export const standardTsconfig = createRuleFactory<Options>({
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
|
|
2
|
+
import { coverageConfigDefaults, defineProject, defaultExclude } from 'vitest/config'
|
|
3
|
+
|
|
4
|
+
export default defineProject({
|
|
5
|
+
test: {
|
|
6
|
+
exclude: [...defaultExclude, "**/build/**"],
|
|
7
|
+
coverage: {
|
|
8
|
+
provider: "v8",
|
|
9
|
+
enabled: true,
|
|
10
|
+
exclude: [...coverageConfigDefaults.exclude, "vitest.config.*"]
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
})
|
|
14
|
+
|
package/jest.config.cjs
DELETED