@monorepolint/rules 0.5.0-alpha.97 → 0.5.0-alpha.98
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/lib/__tests__/bannedDependencies.spec.js +1 -1
- package/lib/__tests__/bannedDependencies.spec.js.map +1 -1
- package/lib/__tests__/consistentDependencies.spec.js +1 -1
- package/lib/__tests__/consistentDependencies.spec.js.map +1 -1
- package/lib/__tests__/consistentVersions.spec.js +1 -1
- package/lib/__tests__/consistentVersions.spec.js.map +1 -1
- package/lib/__tests__/mustSatisfyPeerDependencies.spec.js +1 -1
- package/lib/__tests__/mustSatisfyPeerDependencies.spec.js.map +1 -1
- package/lib/__tests__/nestedWorkspaces.spec.js +1 -1
- package/lib/__tests__/nestedWorkspaces.spec.js.map +1 -1
- package/lib/__tests__/requireDependency.spec.js +1 -1
- package/lib/__tests__/requireDependency.spec.js.map +1 -1
- package/lib/__tests__/utils.d.ts +1 -1
- package/lib/__tests__/utils.d.ts.map +1 -1
- package/lib/__tests__/utils.js +1 -1
- package/lib/__tests__/utils.js.map +1 -1
- package/lib/alphabeticalDependencies.d.ts +12 -1
- package/lib/alphabeticalDependencies.d.ts.map +1 -1
- package/lib/alphabeticalDependencies.js +3 -1
- package/lib/alphabeticalDependencies.js.map +1 -1
- package/lib/alphabeticalScripts.d.ts +12 -1
- package/lib/alphabeticalScripts.d.ts.map +1 -1
- package/lib/alphabeticalScripts.js +3 -1
- package/lib/alphabeticalScripts.js.map +1 -1
- package/lib/bannedDependencies.d.ts +102 -1
- package/lib/bannedDependencies.d.ts.map +1 -1
- package/lib/bannedDependencies.js +3 -1
- package/lib/bannedDependencies.js.map +1 -1
- package/lib/consistentDependencies.d.ts +22 -1
- package/lib/consistentDependencies.d.ts.map +1 -1
- package/lib/consistentDependencies.js +3 -1
- package/lib/consistentDependencies.js.map +1 -1
- package/lib/consistentVersions.d.ts +34 -1
- package/lib/consistentVersions.d.ts.map +1 -1
- package/lib/consistentVersions.js +3 -1
- package/lib/consistentVersions.js.map +1 -1
- package/lib/fileContents.d.ts +87 -1
- package/lib/fileContents.d.ts.map +1 -1
- package/lib/fileContents.js +3 -1
- package/lib/fileContents.js.map +1 -1
- package/lib/index.d.ts +13 -13
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +14 -1
- package/lib/index.js.map +1 -1
- package/lib/mustSatisfyPeerDependencies.d.ts +482 -1
- package/lib/mustSatisfyPeerDependencies.d.ts.map +1 -1
- package/lib/mustSatisfyPeerDependencies.js +3 -1
- package/lib/mustSatisfyPeerDependencies.js.map +1 -1
- package/lib/nestedWorkspaces.d.ts +12 -1
- package/lib/nestedWorkspaces.d.ts.map +1 -1
- package/lib/nestedWorkspaces.js +3 -1
- package/lib/nestedWorkspaces.js.map +1 -1
- package/lib/packageEntry.d.ts +91 -1
- package/lib/packageEntry.d.ts.map +1 -1
- package/lib/packageEntry.js +3 -1
- package/lib/packageEntry.js.map +1 -1
- package/lib/packageOrder.d.ts +22 -1
- package/lib/packageOrder.d.ts.map +1 -1
- package/lib/packageOrder.js +3 -1
- package/lib/packageOrder.js.map +1 -1
- package/lib/packageScript.d.ts +78 -1
- package/lib/packageScript.d.ts.map +1 -1
- package/lib/packageScript.js +3 -1
- package/lib/packageScript.js.map +1 -1
- package/lib/requireDependency.d.ts +85 -1
- package/lib/requireDependency.d.ts.map +1 -1
- package/lib/requireDependency.js +3 -1
- package/lib/requireDependency.js.map +1 -1
- package/lib/standardTsconfig.d.ts +70 -2
- package/lib/standardTsconfig.d.ts.map +1 -1
- package/lib/standardTsconfig.js +3 -1
- package/lib/standardTsconfig.js.map +1 -1
- package/lib/util/checkAlpha.d.ts +1 -1
- package/lib/util/checkAlpha.d.ts.map +1 -1
- package/lib/util/createNewRuleConversion.d.ts +30 -0
- package/lib/util/createNewRuleConversion.d.ts.map +1 -0
- package/lib/util/createNewRuleConversion.js +33 -0
- package/lib/util/createNewRuleConversion.js.map +1 -0
- package/package.json +5 -4
- package/src/__tests__/alphabeticalScripts.spec.ts +1 -1
- package/src/__tests__/bannedDependencies.spec.ts +2 -2
- package/src/__tests__/consistentDependencies.spec.ts +2 -2
- package/src/__tests__/consistentVersions.spec.ts +2 -2
- package/src/__tests__/fileContents.spec.ts +1 -1
- package/src/__tests__/mustSatisfyPeerDependencies.spec.ts +2 -2
- package/src/__tests__/nestedWorkspaces.spec.ts +2 -2
- package/src/__tests__/packageEntry.spec.ts +1 -1
- package/src/__tests__/packageOrder.spec.ts +1 -1
- package/src/__tests__/packageScript.spec.ts +1 -1
- package/src/__tests__/requireDependency.spec.ts +2 -2
- package/src/__tests__/utils.ts +3 -2
- package/src/alphabeticalDependencies.ts +4 -1
- package/src/alphabeticalScripts.ts +4 -1
- package/src/bannedDependencies.ts +3 -1
- package/src/consistentDependencies.ts +4 -1
- package/src/consistentVersions.ts +4 -1
- package/src/fileContents.ts +4 -2
- package/src/index.ts +13 -13
- package/src/mustSatisfyPeerDependencies.ts +7 -1
- package/src/nestedWorkspaces.ts +4 -1
- package/src/packageEntry.ts +4 -1
- package/src/packageOrder.ts +4 -1
- package/src/packageScript.ts +4 -1
- package/src/requireDependency.ts +4 -1
- package/src/standardTsconfig.ts +5 -2
- package/src/util/checkAlpha.ts +1 -1
- package/src/util/createNewRuleConversion.ts +38 -0
- package/tsconfig.json +3 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright 2022 Palantir Technologies, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the MIT license. See LICENSE file in the project root for details.
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
7
|
+
import { Checker, Context, NewRuleModule, RuleModule, RuleEntry } from "@monorepolint/config";
|
|
8
|
+
import * as r from "runtypes";
|
|
9
|
+
export declare class NewRuleConverterBase<T extends r.Runtype<unknown>> implements NewRuleModule<T> {
|
|
10
|
+
readonly name: string;
|
|
11
|
+
checkFunc: Checker<T>;
|
|
12
|
+
readonly optionsRuntype: T;
|
|
13
|
+
readonly ruleEntry: RuleEntry<r.Static<T>>;
|
|
14
|
+
readonly id: string;
|
|
15
|
+
options: r.Static<T> | undefined;
|
|
16
|
+
constructor(name: string, checkFunc: Checker<T>, optionsRuntype: T, ruleEntry: RuleEntry<r.Static<T>>);
|
|
17
|
+
check: (context: Context) => void | Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export declare function createNewRuleConversion<T extends r.Runtype<unknown>>(name: string, old: RuleModule<T>): {
|
|
20
|
+
new (ruleEntry: RuleEntry<r.Static<T>>): {
|
|
21
|
+
readonly id: string;
|
|
22
|
+
options: r.Static<T> | undefined;
|
|
23
|
+
readonly name: string;
|
|
24
|
+
checkFunc: Checker<T>;
|
|
25
|
+
readonly optionsRuntype: T;
|
|
26
|
+
readonly ruleEntry: RuleEntry<r.Static<T>>;
|
|
27
|
+
check: (context: Context) => void | Promise<void>;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=createNewRuleConversion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createNewRuleConversion.d.ts","sourceRoot":"","sources":["../../src/util/createNewRuleConversion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC9F,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAK9B,qBAAa,oBAAoB,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAE,YAAW,aAAa,CAAC,CAAC,CAAC;aAKvE,IAAI,EAAE,MAAM;IACrB,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;aACZ,cAAc,EAAE,CAAC;aACjB,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAPnD,SAAgB,EAAE,EAAE,MAAM,CAAC;IAC3B,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;gBAGf,IAAI,EAAE,MAAM,EACrB,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC,EACZ,cAAc,EAAE,CAAC,EACjB,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAO5C,KAAK,YAAa,OAAO,0BAAsE;CACvG;AAED,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC;oBAE3E,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;;;;;;;;;EAIhD"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright 2022 Palantir Technologies, Inc.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the MIT license. See LICENSE file in the project root for details.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.createNewRuleConversion = exports.NewRuleConverterBase = void 0;
|
|
10
|
+
// tslint:disable max-classes-per-file
|
|
11
|
+
let id = 0;
|
|
12
|
+
class NewRuleConverterBase {
|
|
13
|
+
constructor(name, checkFunc, optionsRuntype, ruleEntry) {
|
|
14
|
+
this.name = name;
|
|
15
|
+
this.checkFunc = checkFunc;
|
|
16
|
+
this.optionsRuntype = optionsRuntype;
|
|
17
|
+
this.ruleEntry = ruleEntry;
|
|
18
|
+
this.check = (context) => this.checkFunc(context, this.ruleEntry.options, { id: this.id });
|
|
19
|
+
this.options = ruleEntry.options;
|
|
20
|
+
this.id = `${this.name} :: ${id++}`;
|
|
21
|
+
//
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.NewRuleConverterBase = NewRuleConverterBase;
|
|
25
|
+
function createNewRuleConversion(name, old) {
|
|
26
|
+
return class NewRule extends NewRuleConverterBase {
|
|
27
|
+
constructor(ruleEntry) {
|
|
28
|
+
super(name, old.check, old.optionsRuntype, ruleEntry);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
exports.createNewRuleConversion = createNewRuleConversion;
|
|
33
|
+
//# sourceMappingURL=createNewRuleConversion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createNewRuleConversion.js","sourceRoot":"","sources":["../../src/util/createNewRuleConversion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAKH,sCAAsC;AAEtC,IAAI,EAAE,GAAG,CAAC,CAAC;AACX,MAAa,oBAAoB;IAI/B,YACkB,IAAY,EACrB,SAAqB,EACZ,cAAiB,EACjB,SAAiC;QAHjC,SAAI,GAAJ,IAAI,CAAQ;QACrB,cAAS,GAAT,SAAS,CAAY;QACZ,mBAAc,GAAd,cAAc,CAAG;QACjB,cAAS,GAAT,SAAS,CAAwB;QAO5C,UAAK,GAAG,CAAC,OAAgB,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;QALpG,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC;QACjC,IAAI,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC,IAAI,OAAO,EAAE,EAAE,EAAE,CAAC;QACpC,EAAE;IACJ,CAAC;CAGF;AAhBD,oDAgBC;AAED,SAAgB,uBAAuB,CAA+B,IAAY,EAAE,GAAkB;IACpG,OAAO,MAAM,OAAQ,SAAQ,oBAAuB;QAClD,YAAY,SAAiC;YAC3C,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;QACxD,CAAC;KACF,CAAC;AACJ,CAAC;AAND,0DAMC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monorepolint/rules",
|
|
3
|
-
"version": "0.5.0-alpha.
|
|
3
|
+
"version": "0.5.0-alpha.98+32ec612",
|
|
4
4
|
"author": "Eric L Anderson (https://github.com/ericanderson)",
|
|
5
5
|
"contributors": [
|
|
6
6
|
"Mac Lockard (https://github.com/maclockard)"
|
|
@@ -19,8 +19,9 @@
|
|
|
19
19
|
"test:watch": "../../node_modules/.bin/jest --colors --passWithNoTests --watch"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@monorepolint/
|
|
23
|
-
"@monorepolint/
|
|
22
|
+
"@monorepolint/config": "^0.5.0-alpha.98+32ec612",
|
|
23
|
+
"@monorepolint/core": "^0.5.0-alpha.98+32ec612",
|
|
24
|
+
"@monorepolint/utils": "^0.5.0-alpha.98+32ec612",
|
|
24
25
|
"globby": "^11.0.1",
|
|
25
26
|
"jest-diff": "^26.0.1",
|
|
26
27
|
"resolve-package-path": "^3.1.0",
|
|
@@ -37,5 +38,5 @@
|
|
|
37
38
|
"publishConfig": {
|
|
38
39
|
"access": "public"
|
|
39
40
|
},
|
|
40
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "32ec6128225ca7b5462bb02375b2d9b03c1d7c3a"
|
|
41
42
|
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
// tslint:disable:no-console
|
|
9
9
|
import { AddErrorSpy, createTestingWorkspace, HOST_FACTORIES, jsonToString, TestingWorkspace } from "./utils";
|
|
10
|
-
import { Context, Failure } from "@monorepolint/
|
|
10
|
+
import { Context, Failure } from "@monorepolint/config";
|
|
11
11
|
import { alphabeticalScripts } from "../alphabeticalScripts";
|
|
12
12
|
import { createIncorrectOrderErrorMessage } from "../util/checkAlpha";
|
|
13
13
|
|
|
@@ -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 {
|
|
7
|
+
import { WorkspaceContextImpl } from "@monorepolint/core";
|
|
8
8
|
import { SimpleHost } from "@monorepolint/utils";
|
|
9
9
|
import { writeFileSync } from "fs";
|
|
10
10
|
import * as path from "path";
|
|
@@ -38,7 +38,7 @@ describe("bannedDependencies", () => {
|
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
function makeWorkspace() {
|
|
41
|
-
const workspaceContext = new
|
|
41
|
+
const workspaceContext = new WorkspaceContextImpl(
|
|
42
42
|
cwd!,
|
|
43
43
|
{
|
|
44
44
|
rules: [],
|
|
@@ -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 {
|
|
7
|
+
import { WorkspaceContextImpl } from "@monorepolint/core";
|
|
8
8
|
import { SimpleHost } from "@monorepolint/utils";
|
|
9
9
|
import { readFileSync, writeFileSync } from "fs";
|
|
10
10
|
import * as path from "path";
|
|
@@ -62,7 +62,7 @@ describe("consistentDependencies", () => {
|
|
|
62
62
|
const dir: tmp.DirResult = tmp.dirSync({ unsafeCleanup: true });
|
|
63
63
|
cleanupJobs.push(() => dir.removeCallback());
|
|
64
64
|
|
|
65
|
-
const workspaceContext = new
|
|
65
|
+
const workspaceContext = new WorkspaceContextImpl(
|
|
66
66
|
dir.name,
|
|
67
67
|
{
|
|
68
68
|
rules: [],
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
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";
|
|
@@ -36,7 +36,7 @@ describe("consistentVersions", () => {
|
|
|
36
36
|
|
|
37
37
|
function makeWorkspace(fix = false) {
|
|
38
38
|
const host: Host = new SimpleHost();
|
|
39
|
-
const workspaceContext = new
|
|
39
|
+
const workspaceContext = new WorkspaceContextImpl(
|
|
40
40
|
cwd!,
|
|
41
41
|
{
|
|
42
42
|
rules: [],
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
// tslint:disable:no-console
|
|
9
9
|
import { createTestingWorkspace, HOST_FACTORIES, TestingWorkspace } from "./utils";
|
|
10
|
-
import { AddErrorOptions, Failure } from "@monorepolint/
|
|
10
|
+
import { AddErrorOptions, Failure } from "@monorepolint/config";
|
|
11
11
|
import { fileContents } from "../fileContents";
|
|
12
12
|
|
|
13
13
|
const EXPECTED_FOO_FILE = "hello world";
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
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";
|
|
@@ -66,7 +66,7 @@ describe("mustSatisfyPeerDependencies", () => {
|
|
|
66
66
|
|
|
67
67
|
function makeWorkspace(fix = false) {
|
|
68
68
|
const host: Host = new SimpleHost();
|
|
69
|
-
const workspaceContext = new
|
|
69
|
+
const workspaceContext = new WorkspaceContextImpl(
|
|
70
70
|
cwd!,
|
|
71
71
|
{
|
|
72
72
|
rules: [],
|
|
@@ -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 {
|
|
7
|
+
import { WorkspaceContextImpl } from "@monorepolint/core";
|
|
8
8
|
import { SimpleHost } from "@monorepolint/utils";
|
|
9
9
|
import { writeFileSync } from "fs";
|
|
10
10
|
import * as path from "path";
|
|
@@ -57,7 +57,7 @@ describe("nestedWorkspaces", () => {
|
|
|
57
57
|
|
|
58
58
|
function makeWorkspace() {
|
|
59
59
|
const host = new SimpleHost();
|
|
60
|
-
const workspaceContext = new
|
|
60
|
+
const workspaceContext = new WorkspaceContextImpl(
|
|
61
61
|
cwd!,
|
|
62
62
|
{
|
|
63
63
|
rules: [],
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
// tslint:disable:no-console
|
|
9
9
|
|
|
10
|
-
import { Context, Failure } from "@monorepolint/
|
|
10
|
+
import { Context, Failure } from "@monorepolint/config";
|
|
11
11
|
import { createExpectedEntryErrorMessage, createStandardizedEntryErrorMessage, packageEntry } from "../packageEntry";
|
|
12
12
|
import { AddErrorSpy, createTestingWorkspace, HOST_FACTORIES, TestingWorkspace } from "./utils";
|
|
13
13
|
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
// tslint:disable:no-console
|
|
9
9
|
import { AddErrorSpy, createTestingWorkspace, HOST_FACTORIES, TestingWorkspace } from "./utils";
|
|
10
|
-
import { Context, Failure } from "@monorepolint/
|
|
10
|
+
import { Context, Failure } from "@monorepolint/config";
|
|
11
11
|
import { packageOrder } from "../packageOrder";
|
|
12
12
|
|
|
13
13
|
const PACKAGE_UNORDERED =
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
// tslint:disable:no-console
|
|
9
9
|
|
|
10
|
-
import { Context, Failure } from "@monorepolint/
|
|
10
|
+
import { Context, Failure } from "@monorepolint/config";
|
|
11
11
|
import { packageScript } from "../packageScript";
|
|
12
12
|
import { AddErrorSpy, createTestingWorkspace, HOST_FACTORIES, TestingWorkspace } from "./utils";
|
|
13
13
|
|
|
@@ -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 {
|
|
7
|
+
import { WorkspaceContextImpl } from "@monorepolint/core";
|
|
8
8
|
import { SimpleHost } from "@monorepolint/utils";
|
|
9
9
|
import { readFileSync, writeFileSync } from "fs";
|
|
10
10
|
import * as path from "path";
|
|
@@ -74,7 +74,7 @@ describe("requireDependency", () => {
|
|
|
74
74
|
const dir: tmp.DirResult = tmp.dirSync({ unsafeCleanup: true });
|
|
75
75
|
cleanupJobs.push(() => dir.removeCallback());
|
|
76
76
|
|
|
77
|
-
const workspaceContext = new
|
|
77
|
+
const workspaceContext = new WorkspaceContextImpl(
|
|
78
78
|
dir.name,
|
|
79
79
|
{
|
|
80
80
|
rules: [],
|
package/src/__tests__/utils.ts
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
*
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { AddErrorOptions, WorkspaceContext } from "@monorepolint/
|
|
8
|
+
import { AddErrorOptions, WorkspaceContext } from "@monorepolint/config";
|
|
9
|
+
import { WorkspaceContextImpl } from "@monorepolint/core";
|
|
9
10
|
import { CachingHost, Host, SimpleHost } from "@monorepolint/utils";
|
|
10
11
|
import * as path from "path";
|
|
11
12
|
import * as tmp from "tmp";
|
|
@@ -41,7 +42,7 @@ export async function createTestingWorkspace(inboundOpts: TestingWorkspaceOpts)
|
|
|
41
42
|
|
|
42
43
|
return new DefaultTestingWorkspace(
|
|
43
44
|
{ ...opts, rootPath },
|
|
44
|
-
new
|
|
45
|
+
new WorkspaceContextImpl(rootPath, { fix: opts.fixFlag, rules: [] }, opts.host)
|
|
45
46
|
);
|
|
46
47
|
}
|
|
47
48
|
|
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
*
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { Context, RuleModule } from "@monorepolint/
|
|
8
|
+
import { Context, RuleModule } from "@monorepolint/config";
|
|
9
9
|
import * as r from "runtypes";
|
|
10
10
|
import { checkAlpha } from "./util/checkAlpha";
|
|
11
|
+
import { createNewRuleConversion } from "./util/createNewRuleConversion";
|
|
11
12
|
|
|
12
13
|
const Options = r.Undefined;
|
|
13
14
|
|
|
@@ -19,3 +20,5 @@ export const alphabeticalDependencies: RuleModule<typeof Options> = {
|
|
|
19
20
|
},
|
|
20
21
|
optionsRuntype: Options,
|
|
21
22
|
};
|
|
23
|
+
|
|
24
|
+
export const AlphabeticalDependencies = createNewRuleConversion("AlphabetialDependencies", alphabeticalDependencies);
|
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
*
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { Context, RuleModule } from "@monorepolint/
|
|
8
|
+
import { Context, RuleModule } from "@monorepolint/config";
|
|
9
9
|
import * as r from "runtypes";
|
|
10
10
|
import { checkAlpha } from "./util/checkAlpha";
|
|
11
|
+
import { createNewRuleConversion } from "./util/createNewRuleConversion";
|
|
11
12
|
|
|
12
13
|
const Options = r.Undefined;
|
|
13
14
|
|
|
@@ -17,3 +18,5 @@ export const alphabeticalScripts: RuleModule<typeof Options> = {
|
|
|
17
18
|
},
|
|
18
19
|
optionsRuntype: Options,
|
|
19
20
|
};
|
|
21
|
+
|
|
22
|
+
export const AlphabeticalScripts = createNewRuleConversion("AlphabeticalScripts", alphabeticalScripts);
|
|
@@ -5,11 +5,12 @@
|
|
|
5
5
|
*
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { Context, RuleModule } from "@monorepolint/
|
|
8
|
+
import { Context, RuleModule } from "@monorepolint/config";
|
|
9
9
|
import { matchesAnyGlob } from "@monorepolint/utils";
|
|
10
10
|
import { AggregateTiming } from "@monorepolint/utils";
|
|
11
11
|
import path from "path";
|
|
12
12
|
import * as r from "runtypes";
|
|
13
|
+
import { createNewRuleConversion } from "./util/createNewRuleConversion";
|
|
13
14
|
import { IPackageDependencyGraphNode, PackageDependencyGraphService } from "./util/packageDependencyGraphService";
|
|
14
15
|
|
|
15
16
|
// FIXME: This rule is messed. bannedTransitiveDependencies doesnt glob
|
|
@@ -113,6 +114,7 @@ export const bannedDependencies: RuleModule<typeof Options> & {
|
|
|
113
114
|
aggregateTiming.printResults();
|
|
114
115
|
},
|
|
115
116
|
};
|
|
117
|
+
export const BannedDependencies = createNewRuleConversion("BannedDependencies", bannedDependencies);
|
|
116
118
|
|
|
117
119
|
function populateProblemsExact(banned: Set<string>, dependencies: ReadonlyArray<string>, violations: Set<string>) {
|
|
118
120
|
for (const dependency of dependencies) {
|
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
*
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { Context, RuleModule } from "@monorepolint/
|
|
8
|
+
import { Context, RuleModule } from "@monorepolint/config";
|
|
9
9
|
import diff from "jest-diff";
|
|
10
10
|
import * as r from "runtypes";
|
|
11
|
+
import { createNewRuleConversion } from "./util/createNewRuleConversion";
|
|
11
12
|
|
|
12
13
|
const Options = r
|
|
13
14
|
.Record({
|
|
@@ -27,6 +28,8 @@ export const consistentDependencies = {
|
|
|
27
28
|
optionsRuntype: Options,
|
|
28
29
|
} as RuleModule<typeof Options>;
|
|
29
30
|
|
|
31
|
+
export const ConsistentDependencies = createNewRuleConversion("ConsistentDependencies", consistentDependencies);
|
|
32
|
+
|
|
30
33
|
function checkDeps(context: Context, args: Options, block: "dependencies" | "devDependencies" | "peerDependencies") {
|
|
31
34
|
const packageJson = context.getPackageJson();
|
|
32
35
|
const packagePath = context.getPackageJsonPath();
|
|
@@ -5,10 +5,11 @@
|
|
|
5
5
|
*
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { Context, RuleModule } from "@monorepolint/
|
|
8
|
+
import { Context, RuleModule } from "@monorepolint/config";
|
|
9
9
|
import { mutateJson, PackageJson } from "@monorepolint/utils";
|
|
10
10
|
import * as r from "runtypes";
|
|
11
11
|
import { coerce, SemVer } from "semver";
|
|
12
|
+
import { createNewRuleConversion } from "./util/createNewRuleConversion";
|
|
12
13
|
|
|
13
14
|
export const Options = r.Record({
|
|
14
15
|
matchDependencyVersions: r.Dictionary(r.Union(r.String, r.Array(r.String))),
|
|
@@ -138,3 +139,5 @@ const ensurePackageMatchesSomeVersion = (
|
|
|
138
139
|
});
|
|
139
140
|
}
|
|
140
141
|
};
|
|
142
|
+
|
|
143
|
+
export const ConsistentVersions = createNewRuleConversion("ConsistentVersions", consistentVersions);
|
package/src/fileContents.ts
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
*
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { Context } from "@monorepolint/
|
|
9
|
-
import { RuleModule } from "@monorepolint/core";
|
|
8
|
+
import { Context, RuleModule } from "@monorepolint/config";
|
|
10
9
|
import diff from "jest-diff";
|
|
11
10
|
import * as path from "path";
|
|
12
11
|
import * as r from "runtypes";
|
|
12
|
+
import { createNewRuleConversion } from "./util/createNewRuleConversion";
|
|
13
13
|
|
|
14
14
|
const Options = r.Union(
|
|
15
15
|
r.Record({
|
|
@@ -89,3 +89,5 @@ function getExpectedContents(context: Context, opts: Options) {
|
|
|
89
89
|
return opts.template;
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
+
|
|
93
|
+
export const FileContents = createNewRuleConversion("FileContents", fileContents);
|
package/src/index.ts
CHANGED
|
@@ -5,16 +5,16 @@
|
|
|
5
5
|
*
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
export { alphabeticalDependencies } from "./alphabeticalDependencies";
|
|
9
|
-
export { alphabeticalScripts } from "./alphabeticalScripts";
|
|
10
|
-
export { bannedDependencies } from "./bannedDependencies";
|
|
11
|
-
export { consistentDependencies } from "./consistentDependencies";
|
|
12
|
-
export { consistentVersions } from "./consistentVersions";
|
|
13
|
-
export { fileContents } from "./fileContents";
|
|
14
|
-
export { mustSatisfyPeerDependencies } from "./mustSatisfyPeerDependencies";
|
|
15
|
-
export { packageOrder } from "./packageOrder";
|
|
16
|
-
export { packageEntry } from "./packageEntry";
|
|
17
|
-
export { packageScript } from "./packageScript";
|
|
18
|
-
export { standardTsconfig } from "./standardTsconfig";
|
|
19
|
-
export { nestedWorkspaces } from "./nestedWorkspaces";
|
|
20
|
-
export { requireDependency } from "./requireDependency";
|
|
8
|
+
export { alphabeticalDependencies, AlphabeticalDependencies } from "./alphabeticalDependencies";
|
|
9
|
+
export { alphabeticalScripts, AlphabeticalScripts } from "./alphabeticalScripts";
|
|
10
|
+
export { bannedDependencies, BannedDependencies } from "./bannedDependencies";
|
|
11
|
+
export { consistentDependencies, ConsistentDependencies } from "./consistentDependencies";
|
|
12
|
+
export { consistentVersions, ConsistentVersions } from "./consistentVersions";
|
|
13
|
+
export { fileContents, FileContents } from "./fileContents";
|
|
14
|
+
export { mustSatisfyPeerDependencies, MustSatisfyPeerDependencies } from "./mustSatisfyPeerDependencies";
|
|
15
|
+
export { packageOrder, PackageOrder } from "./packageOrder";
|
|
16
|
+
export { packageEntry, PackageEntry } from "./packageEntry";
|
|
17
|
+
export { packageScript, PackageScript } from "./packageScript";
|
|
18
|
+
export { standardTsconfig, StandardTsConfig } from "./standardTsconfig";
|
|
19
|
+
export { nestedWorkspaces, NestedWorkspaces } from "./nestedWorkspaces";
|
|
20
|
+
export { requireDependency, RequireDependency } from "./requireDependency";
|
|
@@ -5,12 +5,13 @@
|
|
|
5
5
|
*
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { Context, RuleModule } from "@monorepolint/
|
|
8
|
+
import { Context, RuleModule } from "@monorepolint/config";
|
|
9
9
|
import { Host, mutateJson, PackageJson } from "@monorepolint/utils";
|
|
10
10
|
import path from "path";
|
|
11
11
|
import resolvePackagePath from "resolve-package-path";
|
|
12
12
|
import * as r from "runtypes";
|
|
13
13
|
import { coerce } from "semver";
|
|
14
|
+
import { createNewRuleConversion } from "./util/createNewRuleConversion";
|
|
14
15
|
|
|
15
16
|
const Options = r.Union(
|
|
16
17
|
r.Partial({
|
|
@@ -188,6 +189,11 @@ export const mustSatisfyPeerDependencies: RuleModule<typeof Options> = {
|
|
|
188
189
|
optionsRuntype: Options,
|
|
189
190
|
};
|
|
190
191
|
|
|
192
|
+
export const MustSatisfyPeerDependencies = createNewRuleConversion(
|
|
193
|
+
"MustSatisfyPeerDependencies",
|
|
194
|
+
mustSatisfyPeerDependencies
|
|
195
|
+
);
|
|
196
|
+
|
|
191
197
|
/**
|
|
192
198
|
* separating on `|`, this regex allows any of the following formats:
|
|
193
199
|
* - `*`
|
package/src/nestedWorkspaces.ts
CHANGED
|
@@ -5,10 +5,11 @@
|
|
|
5
5
|
*
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { Context, RuleModule } from "@monorepolint/
|
|
8
|
+
import { Context, RuleModule } from "@monorepolint/config";
|
|
9
9
|
import globby from "globby";
|
|
10
10
|
import path from "path";
|
|
11
11
|
import * as r from "runtypes";
|
|
12
|
+
import { createNewRuleConversion } from "./util/createNewRuleConversion";
|
|
12
13
|
|
|
13
14
|
export const Options = r.Undefined;
|
|
14
15
|
|
|
@@ -57,3 +58,5 @@ export const nestedWorkspaces: RuleModule<typeof Options> = {
|
|
|
57
58
|
},
|
|
58
59
|
optionsRuntype: Options,
|
|
59
60
|
};
|
|
61
|
+
|
|
62
|
+
export const NestedWorkspaces = createNewRuleConversion("NestedWorkspaces", nestedWorkspaces);
|
package/src/packageEntry.ts
CHANGED
|
@@ -5,10 +5,11 @@
|
|
|
5
5
|
*
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { Context, RuleModule } from "@monorepolint/
|
|
8
|
+
import { Context, RuleModule } from "@monorepolint/config";
|
|
9
9
|
import { mutateJson, PackageJson } from "@monorepolint/utils";
|
|
10
10
|
import diff from "jest-diff";
|
|
11
11
|
import * as r from "runtypes";
|
|
12
|
+
import { createNewRuleConversion } from "./util/createNewRuleConversion";
|
|
12
13
|
|
|
13
14
|
export const Options = r.Union(
|
|
14
15
|
r
|
|
@@ -80,6 +81,8 @@ export const packageEntry: RuleModule<typeof Options> = {
|
|
|
80
81
|
optionsRuntype: Options,
|
|
81
82
|
};
|
|
82
83
|
|
|
84
|
+
export const PackageEntry = createNewRuleConversion("PackageEntry", packageEntry);
|
|
85
|
+
|
|
83
86
|
export function createStandardizedEntryErrorMessage(key: string) {
|
|
84
87
|
return `Expected standardized entry for '${key}'`;
|
|
85
88
|
}
|
package/src/packageOrder.ts
CHANGED
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
*
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { Context, RuleModule } from "@monorepolint/
|
|
8
|
+
import { Context, RuleModule } from "@monorepolint/config";
|
|
9
9
|
import diff from "jest-diff";
|
|
10
10
|
import * as r from "runtypes";
|
|
11
|
+
import { createNewRuleConversion } from "./util/createNewRuleConversion";
|
|
11
12
|
|
|
12
13
|
type OrderFunction = (context: Context) => (a: string, b: string) => number;
|
|
13
14
|
|
|
@@ -80,6 +81,8 @@ export const packageOrder = {
|
|
|
80
81
|
optionsRuntype: Options,
|
|
81
82
|
} as RuleModule<typeof Options>;
|
|
82
83
|
|
|
84
|
+
export const PackageOrder = createNewRuleConversion("PackageOrder", packageOrder);
|
|
85
|
+
|
|
83
86
|
function arrayOrderCompare(a: ReadonlyArray<string>, b: ReadonlyArray<string>) {
|
|
84
87
|
for (let index = 0; index < a.length; index++) {
|
|
85
88
|
if (a[index] !== b[index]) {
|
package/src/packageScript.ts
CHANGED
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
*
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { Context, RuleModule } from "@monorepolint/
|
|
8
|
+
import { Context, RuleModule } from "@monorepolint/config";
|
|
9
9
|
import { mutateJson, PackageJson } from "@monorepolint/utils";
|
|
10
|
+
import { createNewRuleConversion } from "./util/createNewRuleConversion";
|
|
10
11
|
import diff from "jest-diff";
|
|
11
12
|
import * as r from "runtypes";
|
|
12
13
|
|
|
@@ -101,3 +102,5 @@ export const packageScript = {
|
|
|
101
102
|
},
|
|
102
103
|
optionsRuntype: Options,
|
|
103
104
|
} as RuleModule<typeof Options>;
|
|
105
|
+
|
|
106
|
+
export const PackageScript = createNewRuleConversion("PackageScript", packageScript);
|
package/src/requireDependency.ts
CHANGED
|
@@ -5,10 +5,11 @@
|
|
|
5
5
|
*
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { Context, RuleModule } from "@monorepolint/
|
|
8
|
+
import { Context, RuleModule } from "@monorepolint/config";
|
|
9
9
|
import { mutateJson, PackageJson } from "@monorepolint/utils";
|
|
10
10
|
import diff from "jest-diff";
|
|
11
11
|
import * as r from "runtypes";
|
|
12
|
+
import { createNewRuleConversion } from "./util/createNewRuleConversion";
|
|
12
13
|
|
|
13
14
|
const Options = r.Partial({
|
|
14
15
|
dependencies: r.Dictionary(r.String),
|
|
@@ -67,3 +68,5 @@ export const requireDependency = {
|
|
|
67
68
|
},
|
|
68
69
|
optionsRuntype: Options,
|
|
69
70
|
} as RuleModule<typeof Options>;
|
|
71
|
+
|
|
72
|
+
export const RequireDependency = createNewRuleConversion("RequireDependency", requireDependency);
|
package/src/standardTsconfig.ts
CHANGED
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
*
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { Context, RuleModule } from "@monorepolint/
|
|
8
|
+
import { Context, RuleModule } from "@monorepolint/config";
|
|
9
9
|
import { matchesAnyGlob } from "@monorepolint/utils";
|
|
10
10
|
import diff from "jest-diff";
|
|
11
|
+
import { createNewRuleConversion } from "./util/createNewRuleConversion";
|
|
11
12
|
import * as path from "path";
|
|
12
13
|
import * as r from "runtypes";
|
|
13
14
|
|
|
@@ -38,7 +39,7 @@ const Options = r
|
|
|
38
39
|
return count === 1 || "Expect one of { generator, template, templateFile }";
|
|
39
40
|
});
|
|
40
41
|
|
|
41
|
-
export
|
|
42
|
+
export interface Options extends r.Static<typeof Options> {}
|
|
42
43
|
|
|
43
44
|
export const standardTsconfig = {
|
|
44
45
|
check: async function expectStandardTsconfig(context: Context, opts: Options) {
|
|
@@ -75,6 +76,8 @@ export const standardTsconfig = {
|
|
|
75
76
|
optionsRuntype: Options,
|
|
76
77
|
} as RuleModule<typeof Options>;
|
|
77
78
|
|
|
79
|
+
export const StandardTsConfig = createNewRuleConversion("StandardTsconfig", standardTsconfig);
|
|
80
|
+
|
|
78
81
|
function getGenerator(context: Context, opts: Options) {
|
|
79
82
|
if (opts.generator) {
|
|
80
83
|
return opts.generator;
|
package/src/util/checkAlpha.ts
CHANGED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright 2022 Palantir Technologies, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the MIT license. See LICENSE file in the project root for details.
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { Checker, Context, NewRuleModule, RuleModule, RuleEntry } from "@monorepolint/config";
|
|
9
|
+
import * as r from "runtypes";
|
|
10
|
+
|
|
11
|
+
// tslint:disable max-classes-per-file
|
|
12
|
+
|
|
13
|
+
let id = 0;
|
|
14
|
+
export class NewRuleConverterBase<T extends r.Runtype<unknown>> implements NewRuleModule<T> {
|
|
15
|
+
public readonly id: string;
|
|
16
|
+
options: r.Static<T> | undefined;
|
|
17
|
+
|
|
18
|
+
constructor(
|
|
19
|
+
public readonly name: string,
|
|
20
|
+
public checkFunc: Checker<T>,
|
|
21
|
+
public readonly optionsRuntype: T,
|
|
22
|
+
public readonly ruleEntry: RuleEntry<r.Static<T>>
|
|
23
|
+
) {
|
|
24
|
+
this.options = ruleEntry.options;
|
|
25
|
+
this.id = `${this.name} :: ${id++}`;
|
|
26
|
+
//
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public check = (context: Context) => this.checkFunc(context, this.ruleEntry.options, { id: this.id });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function createNewRuleConversion<T extends r.Runtype<unknown>>(name: string, old: RuleModule<T>) {
|
|
33
|
+
return class NewRule extends NewRuleConverterBase<T> {
|
|
34
|
+
constructor(ruleEntry: RuleEntry<r.Static<T>>) {
|
|
35
|
+
super(name, old.check, old.optionsRuntype, ruleEntry);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|