@monorepolint/rules 0.5.0-alpha.9 → 0.5.0-alpha.95
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__/alphabeticalScripts.spec.d.ts +8 -0
- package/lib/__tests__/alphabeticalScripts.spec.d.ts.map +1 -0
- package/lib/__tests__/alphabeticalScripts.spec.js +61 -0
- package/lib/__tests__/alphabeticalScripts.spec.js.map +1 -0
- package/lib/__tests__/bannedDependencies.spec.d.ts +2 -0
- package/lib/__tests__/bannedDependencies.spec.d.ts.map +1 -0
- package/lib/__tests__/bannedDependencies.spec.js +161 -0
- package/lib/__tests__/bannedDependencies.spec.js.map +1 -0
- package/lib/__tests__/consistentDependencies.spec.js +30 -23
- package/lib/__tests__/consistentDependencies.spec.js.map +1 -1
- package/lib/__tests__/consistentVersions.spec.d.ts +8 -0
- package/lib/__tests__/consistentVersions.spec.d.ts.map +1 -0
- package/lib/__tests__/consistentVersions.spec.js +183 -0
- package/lib/__tests__/consistentVersions.spec.js.map +1 -0
- package/lib/__tests__/fileContents.spec.d.ts +8 -0
- package/lib/__tests__/fileContents.spec.d.ts.map +1 -0
- package/lib/__tests__/fileContents.spec.js +59 -0
- package/lib/__tests__/fileContents.spec.js.map +1 -0
- package/lib/__tests__/mustSatisfyPeerDependencies.spec.d.ts +8 -0
- package/lib/__tests__/mustSatisfyPeerDependencies.spec.d.ts.map +1 -0
- package/lib/__tests__/mustSatisfyPeerDependencies.spec.js +1063 -0
- package/lib/__tests__/mustSatisfyPeerDependencies.spec.js.map +1 -0
- package/lib/__tests__/nestedWorkspaces.spec.d.ts +2 -0
- package/lib/__tests__/nestedWorkspaces.spec.d.ts.map +1 -0
- package/lib/__tests__/nestedWorkspaces.spec.js +124 -0
- package/lib/__tests__/nestedWorkspaces.spec.js.map +1 -0
- package/lib/__tests__/packageEntry.spec.js +72 -27
- package/lib/__tests__/packageEntry.spec.js.map +1 -1
- package/lib/__tests__/packageOrder.spec.js +34 -33
- package/lib/__tests__/packageOrder.spec.js.map +1 -1
- package/lib/__tests__/packageScript.spec.js +50 -51
- package/lib/__tests__/packageScript.spec.js.map +1 -1
- package/lib/__tests__/requireDependency.spec.d.ts +2 -0
- package/lib/__tests__/requireDependency.spec.d.ts.map +1 -0
- package/lib/__tests__/requireDependency.spec.js +123 -0
- package/lib/__tests__/requireDependency.spec.js.map +1 -0
- package/lib/__tests__/utils.d.ts +69 -1
- package/lib/__tests__/utils.d.ts.map +1 -1
- package/lib/__tests__/utils.js +72 -12
- package/lib/__tests__/utils.js.map +1 -1
- package/lib/alphabeticalDependencies.d.ts +3 -1
- package/lib/alphabeticalDependencies.d.ts.map +1 -1
- package/lib/alphabeticalDependencies.js +5 -39
- package/lib/alphabeticalDependencies.js.map +1 -1
- package/lib/alphabeticalScripts.d.ts +12 -0
- package/lib/alphabeticalScripts.d.ts.map +1 -0
- package/lib/alphabeticalScripts.js +20 -0
- package/lib/alphabeticalScripts.js.map +1 -0
- package/lib/bannedDependencies.d.ts +23 -5
- package/lib/bannedDependencies.d.ts.map +1 -1
- package/lib/bannedDependencies.js +110 -36
- package/lib/bannedDependencies.js.map +1 -1
- package/lib/consistentDependencies.d.ts +8 -1
- package/lib/consistentDependencies.d.ts.map +1 -1
- package/lib/consistentDependencies.js +30 -12
- package/lib/consistentDependencies.js.map +1 -1
- package/lib/consistentVersions.d.ts +14 -0
- package/lib/consistentVersions.d.ts.map +1 -0
- package/lib/consistentVersions.js +94 -0
- package/lib/consistentVersions.js.map +1 -0
- package/lib/fileContents.d.ts +8 -8
- package/lib/fileContents.d.ts.map +1 -1
- package/lib/fileContents.js +32 -27
- package/lib/fileContents.js.map +1 -1
- package/lib/index.d.ts +5 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +19 -8
- package/lib/index.js.map +1 -1
- package/lib/mustSatisfyPeerDependencies.d.ts +240 -0
- package/lib/mustSatisfyPeerDependencies.d.ts.map +1 -0
- package/lib/mustSatisfyPeerDependencies.js +636 -0
- package/lib/mustSatisfyPeerDependencies.js.map +1 -0
- package/lib/nestedWorkspaces.d.ts +13 -0
- package/lib/nestedWorkspaces.d.ts.map +1 -0
- package/lib/nestedWorkspaces.js +50 -0
- package/lib/nestedWorkspaces.js.map +1 -0
- package/lib/packageEntry.d.ts +15 -6
- package/lib/packageEntry.d.ts.map +1 -1
- package/lib/packageEntry.js +53 -18
- package/lib/packageEntry.js.map +1 -1
- package/lib/packageOrder.d.ts +3 -3
- package/lib/packageOrder.d.ts.map +1 -1
- package/lib/packageOrder.js +8 -7
- package/lib/packageOrder.js.map +1 -1
- package/lib/packageScript.d.ts +10 -10
- package/lib/packageScript.js +6 -5
- package/lib/packageScript.js.map +1 -1
- package/lib/requireDependency.d.ts +15 -0
- package/lib/requireDependency.d.ts.map +1 -0
- package/lib/requireDependency.js +65 -0
- package/lib/requireDependency.js.map +1 -0
- package/lib/standardTsconfig.d.ts +20 -8
- package/lib/standardTsconfig.d.ts.map +1 -1
- package/lib/standardTsconfig.js +36 -18
- package/lib/standardTsconfig.js.map +1 -1
- package/lib/util/checkAlpha.d.ts +10 -0
- package/lib/util/checkAlpha.d.ts.map +1 -0
- package/lib/util/checkAlpha.js +51 -0
- package/lib/util/checkAlpha.js.map +1 -0
- package/lib/util/makeDirectory.d.ts +8 -0
- package/lib/util/makeDirectory.d.ts.map +1 -0
- package/lib/util/makeDirectory.js +28 -0
- package/lib/util/makeDirectory.js.map +1 -0
- package/lib/util/packageDependencyGraphService.d.ts +37 -0
- package/lib/util/packageDependencyGraphService.d.ts.map +1 -0
- package/lib/util/packageDependencyGraphService.js +70 -0
- package/lib/util/packageDependencyGraphService.js.map +1 -0
- package/package.json +18 -15
- package/src/__tests__/alphabeticalScripts.spec.ts +75 -0
- package/src/__tests__/bannedDependencies.spec.ts +191 -0
- package/src/__tests__/consistentDependencies.spec.ts +39 -26
- package/src/__tests__/consistentVersions.spec.ts +223 -0
- package/src/__tests__/fileContents.spec.ts +74 -0
- package/src/__tests__/mustSatisfyPeerDependencies.spec.ts +1188 -0
- package/src/__tests__/nestedWorkspaces.spec.ts +152 -0
- package/src/__tests__/packageEntry.spec.ts +98 -31
- package/src/__tests__/packageOrder.spec.ts +46 -40
- package/src/__tests__/packageScript.spec.ts +62 -54
- package/src/__tests__/requireDependency.spec.ts +151 -0
- package/src/__tests__/utils.ts +113 -11
- package/src/alphabeticalDependencies.ts +3 -47
- package/src/alphabeticalScripts.ts +19 -0
- package/src/bannedDependencies.ts +133 -43
- package/src/consistentDependencies.ts +34 -12
- package/src/consistentVersions.ts +140 -0
- package/src/fileContents.ts +31 -27
- package/src/index.ts +5 -0
- package/src/mustSatisfyPeerDependencies.ts +739 -0
- package/src/nestedWorkspaces.ts +59 -0
- package/src/packageEntry.ts +67 -24
- package/src/packageOrder.ts +6 -6
- package/src/packageScript.ts +3 -3
- package/src/requireDependency.ts +69 -0
- package/src/standardTsconfig.ts +40 -18
- package/src/util/checkAlpha.ts +59 -0
- package/src/util/makeDirectory.ts +24 -0
- package/src/util/packageDependencyGraphService.ts +114 -0
- package/tsconfig.tsbuildinfo +1 -2439
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright 2019 Palantir Technologies, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the MIT license. See LICENSE file in the project root for details.
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
7
|
+
import { RuleModule } from "@monorepolint/core";
|
|
8
|
+
import * as r from "runtypes";
|
|
9
|
+
export declare const Options: r.Literal<undefined>;
|
|
10
|
+
declare type Options = r.Static<typeof Options>;
|
|
11
|
+
export declare const nestedWorkspaces: RuleModule<typeof Options>;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=nestedWorkspaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nestedWorkspaces.d.ts","sourceRoot":"","sources":["../src/nestedWorkspaces.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAW,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGzD,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAE9B,eAAO,MAAM,OAAO,sBAAc,CAAC;AAEnC,aAAK,OAAO,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,OAAO,CAAC,CAAC;AAGxC,eAAO,MAAM,gBAAgB,EAAE,UAAU,CAAC,OAAO,OAAO,CAyCvD,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright 2019 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.nestedWorkspaces = exports.Options = void 0;
|
|
10
|
+
const tslib_1 = require("tslib");
|
|
11
|
+
const globby_1 = tslib_1.__importDefault(require("globby"));
|
|
12
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
13
|
+
const r = tslib_1.__importStar(require("runtypes"));
|
|
14
|
+
exports.Options = r.Undefined;
|
|
15
|
+
// Enforce that the root package.json contains all of the workspaces in the repo (including nested packages)
|
|
16
|
+
exports.nestedWorkspaces = {
|
|
17
|
+
check: (context) => {
|
|
18
|
+
const rootPackageJson = context.getWorkspaceContext().getPackageJson();
|
|
19
|
+
// Expand a set of globs covering all package.json files in the entire repo (except the root)
|
|
20
|
+
const packageJsonPaths = globby_1.default.sync(["*/**/package.json", "!**/node_modules/**"]);
|
|
21
|
+
const workspaces = Array.isArray(rootPackageJson.workspaces)
|
|
22
|
+
? rootPackageJson.workspaces
|
|
23
|
+
: rootPackageJson.workspaces !== undefined
|
|
24
|
+
? rootPackageJson.workspaces.packages
|
|
25
|
+
: undefined;
|
|
26
|
+
if (workspaces === undefined && packageJsonPaths.length > 0) {
|
|
27
|
+
context.addError({
|
|
28
|
+
file: context.getPackageJsonPath(),
|
|
29
|
+
message: 'The "workspace" field is missing, even though there are workspaces in the repository.',
|
|
30
|
+
});
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
// Build a set of globs for each package.json that exists in packages specified by a workspace.
|
|
34
|
+
const workspacePackageJsons = (workspaces || []).map((item) => `${item}/package.json`);
|
|
35
|
+
// Expand the globs to get an array of all package.json files that are in packages specified by a workspace.
|
|
36
|
+
const expandedWorkspacesGlobs = globby_1.default.sync([...workspacePackageJsons, "!**/node_modules/**"]);
|
|
37
|
+
// Ensure there are no package.jsons which are not included in the globbed workspaces set
|
|
38
|
+
const difference = packageJsonPaths.filter((packageJsonPath) => !expandedWorkspacesGlobs.includes(packageJsonPath));
|
|
39
|
+
if (difference.length !== 0) {
|
|
40
|
+
const differencesList = difference.map((packageJsonPath) => path_1.default.dirname(packageJsonPath)).join(", ");
|
|
41
|
+
context.addError({
|
|
42
|
+
file: context.getPackageJsonPath(),
|
|
43
|
+
message: `The "workspace" field is missing one or more values: ${differencesList}. ` +
|
|
44
|
+
'You may be able to use a glob to avoid listing each workspace individually, e.g. "packages/nested-workspace/*".',
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
optionsRuntype: exports.Options,
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=nestedWorkspaces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nestedWorkspaces.js","sourceRoot":"","sources":["../src/nestedWorkspaces.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAGH,4DAA4B;AAC5B,wDAAwB;AACxB,oDAA8B;AAEjB,QAAA,OAAO,GAAG,CAAC,CAAC,SAAS,CAAC;AAInC,4GAA4G;AAC/F,QAAA,gBAAgB,GAA+B;IAC1D,KAAK,EAAE,CAAC,OAAgB,EAAE,EAAE;QAC1B,MAAM,eAAe,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC,cAAc,EAAE,CAAC;QAEv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ACf,IAAI,EAAE,OAAO,CAAC,kBAAkB,EAAE;gBAClC,OAAO,EACL,wDAAwD,eAAe,IAAI;oBAC3E,iHAAiH;aACpH,CAAC,CAAC;SACJ;IACH,CAAC;IACD,cAAc,EAAE,eAAO;CACxB,CAAC"}
|
package/lib/packageEntry.d.ts
CHANGED
|
@@ -6,11 +6,20 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { RuleModule } from "@monorepolint/core";
|
|
8
8
|
import * as r from "runtypes";
|
|
9
|
-
export declare const Options: r.Record<{
|
|
10
|
-
entries: r.
|
|
11
|
-
}, false
|
|
9
|
+
export declare const Options: r.Union<[r.Intersect<[r.Record<{
|
|
10
|
+
entries: r.Dictionary<r.Unknown, string | number | symbol>;
|
|
11
|
+
}, false>, r.Partial<{
|
|
12
|
+
entriesExist: r.Literal<undefined>;
|
|
13
|
+
}, false>]>, r.Intersect<[r.Record<{
|
|
14
|
+
entriesExist: r.Array<r.String, false>;
|
|
15
|
+
}, false>, r.Partial<{
|
|
16
|
+
entries: r.Literal<undefined>;
|
|
17
|
+
}, false>]>, r.Record<{
|
|
18
|
+
entries: r.Dictionary<r.Unknown, string | number | symbol>;
|
|
19
|
+
entriesExist: r.Array<r.String, false>;
|
|
20
|
+
}, false>]>;
|
|
12
21
|
export declare type Options = r.Static<typeof Options>;
|
|
13
|
-
export declare const packageEntry: RuleModule<
|
|
14
|
-
|
|
15
|
-
|
|
22
|
+
export declare const packageEntry: RuleModule<typeof Options>;
|
|
23
|
+
export declare function createStandardizedEntryErrorMessage(key: string): string;
|
|
24
|
+
export declare function createExpectedEntryErrorMessage(key: string): string;
|
|
16
25
|
//# sourceMappingURL=packageEntry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageEntry.d.ts","sourceRoot":"","sources":["../src/packageEntry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAW,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGzD,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAE9B,eAAO,MAAM,OAAO
|
|
1
|
+
{"version":3,"file":"packageEntry.d.ts","sourceRoot":"","sources":["../src/packageEntry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAW,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGzD,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAE9B,eAAO,MAAM,OAAO;;;;;;;;;;;WAuBnB,CAAC;AAEF,oBAAY,OAAO,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,OAAO,CAAC,CAAC;AAE/C,eAAO,MAAM,YAAY,EAAE,UAAU,CAAC,OAAO,OAAO,CAyCnD,CAAC;AAEF,wBAAgB,mCAAmC,CAAC,GAAG,EAAE,MAAM,UAE9D;AAED,wBAAgB,+BAA+B,CAAC,GAAG,EAAE,MAAM,UAE1D"}
|
package/lib/packageEntry.js
CHANGED
|
@@ -6,35 +6,70 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.createExpectedEntryErrorMessage = exports.createStandardizedEntryErrorMessage = exports.packageEntry = exports.Options = void 0;
|
|
9
10
|
const tslib_1 = require("tslib");
|
|
10
11
|
const utils_1 = require("@monorepolint/utils");
|
|
11
12
|
const jest_diff_1 = tslib_1.__importDefault(require("jest-diff"));
|
|
12
13
|
const r = tslib_1.__importStar(require("runtypes"));
|
|
13
|
-
exports.Options = r.
|
|
14
|
+
exports.Options = r.Union(r
|
|
15
|
+
.Record({
|
|
16
|
+
entries: r.Dictionary(r.Unknown), // string => unknown, enforces existence of keys and their values
|
|
17
|
+
})
|
|
18
|
+
.And(r.Partial({
|
|
19
|
+
entriesExist: r.Undefined,
|
|
20
|
+
})), r
|
|
21
|
+
.Record({
|
|
22
|
+
entriesExist: r.Array(r.String), // enforces existence of keys, but not values
|
|
23
|
+
})
|
|
24
|
+
.And(r.Partial({
|
|
25
|
+
entries: r.Undefined,
|
|
26
|
+
})), r.Record({
|
|
14
27
|
entries: r.Dictionary(r.Unknown),
|
|
15
|
-
|
|
28
|
+
entriesExist: r.Array(r.String),
|
|
29
|
+
}));
|
|
16
30
|
exports.packageEntry = {
|
|
17
31
|
check: function expectPackageEntry(context, options) {
|
|
18
32
|
const packageJson = context.getPackageJson();
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
if (options.entries) {
|
|
34
|
+
for (const key of Object.keys(options.entries)) {
|
|
35
|
+
const value = options.entries[key];
|
|
36
|
+
const entryDiff = (0, jest_diff_1.default)(JSON.stringify(value) + "\n", (JSON.stringify(packageJson[key]) || "") + "\n");
|
|
37
|
+
if ((typeof value !== "object" && value !== packageJson[key]) ||
|
|
38
|
+
entryDiff == null ||
|
|
39
|
+
!entryDiff.includes("Compared values have no visual difference")) {
|
|
40
|
+
context.addError({
|
|
41
|
+
file: context.getPackageJsonPath(),
|
|
42
|
+
message: createStandardizedEntryErrorMessage(key),
|
|
43
|
+
longMessage: entryDiff,
|
|
44
|
+
fixer: () => {
|
|
45
|
+
(0, utils_1.mutateJson)(context.getPackageJsonPath(), context.host, (input) => {
|
|
46
|
+
input[key] = value;
|
|
47
|
+
return input;
|
|
48
|
+
});
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (options.entriesExist) {
|
|
55
|
+
for (const key of options.entriesExist) {
|
|
56
|
+
if (packageJson[key] === undefined) {
|
|
57
|
+
context.addError({
|
|
58
|
+
file: context.getPackageJsonPath(),
|
|
59
|
+
message: createExpectedEntryErrorMessage(key),
|
|
60
|
+
});
|
|
61
|
+
}
|
|
35
62
|
}
|
|
36
63
|
}
|
|
37
64
|
},
|
|
38
65
|
optionsRuntype: exports.Options,
|
|
39
66
|
};
|
|
67
|
+
function createStandardizedEntryErrorMessage(key) {
|
|
68
|
+
return `Expected standardized entry for '${key}'`;
|
|
69
|
+
}
|
|
70
|
+
exports.createStandardizedEntryErrorMessage = createStandardizedEntryErrorMessage;
|
|
71
|
+
function createExpectedEntryErrorMessage(key) {
|
|
72
|
+
return `Expected entry for '${key}' to exist`;
|
|
73
|
+
}
|
|
74
|
+
exports.createExpectedEntryErrorMessage = createExpectedEntryErrorMessage;
|
|
40
75
|
//# sourceMappingURL=packageEntry.js.map
|
package/lib/packageEntry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageEntry.js","sourceRoot":"","sources":["../src/packageEntry.ts"],"names":[],"mappings":";AAAA;;;;;GAKG
|
|
1
|
+
{"version":3,"file":"packageEntry.js","sourceRoot":"","sources":["../src/packageEntry.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAGH,+CAA8D;AAC9D,kEAA6B;AAC7B,oDAA8B;AAEjB,QAAA,OAAO,GAAG,CAAC,CAAC,KAAK,CAC5B,CAAC;KACE,MAAM,CAAC;IACN,OAAO,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,iEAAiE;CACpG,CAAC;KACD,GAAG,CACF,CAAC,CAAC,OAAO,CAAC;IACR,YAAY,EAAE,CAAC,CAAC,SAAS;CAC1B,CAAC,CACH,EACH,CAAC;KACE,MAAM,CAAC;IACN,YAAY,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,6CAA6C;CAC/E,CAAC;KACD,GAAG,CACF,CAAC,CAAC,OAAO,CAAC;IACR,OAAO,EAAE,CAAC,CAAC,SAAS;CACrB,CAAC,CACH,EACH,CAAC,CAAC,MAAM,CAAC;IACP,OAAO,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,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QAED,IAAI,OAAO,CAAC,YAAY,EAAE;YACxB,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,YAAY,EAAE;gBACtC,IAAI,WAAW,CAAC,GAAG,CAAC,KAAK,SAAS,EAAE;oBAClC,OAAO,CAAC,QAAQ,CAAC;wBACf,IAAI,EAAE,OAAO,CAAC,kBAAkB,EAAE;wBAClC,OAAO,EAAE,+BAA+B,CAAC,GAAG,CAAC;qBAC9C,CAAC,CAAC;iBACJ;aACF;SACF;IACH,CAAC;IACD,cAAc,EAAE,eAAO;CACxB,CAAC;AAEF,SAAgB,mCAAmC,CAAC,GAAW;IAC7D,OAAO,oCAAoC,GAAG,GAAG,CAAC;AACpD,CAAC;AAFD,kFAEC;AAED,SAAgB,+BAA+B,CAAC,GAAW;IACzD,OAAO,uBAAuB,GAAG,YAAY,CAAC;AAChD,CAAC;AAFD,0EAEC"}
|
package/lib/packageOrder.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { RuleModule } from "@monorepolint/core";
|
|
8
8
|
import * as r from "runtypes";
|
|
9
|
-
export declare const packageOrder: RuleModule<r.
|
|
10
|
-
order: r.
|
|
11
|
-
}, false>, r.Literal<undefined
|
|
9
|
+
export declare const packageOrder: RuleModule<r.Union<[r.Record<{
|
|
10
|
+
order: r.Union<[r.Array<r.String, false>, r.Function]>;
|
|
11
|
+
}, false>, r.Literal<undefined>]>>;
|
|
12
12
|
//# sourceMappingURL=packageOrder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageOrder.d.ts","sourceRoot":"","sources":["../src/packageOrder.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAW,UAAU,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"packageOrder.d.ts","sourceRoot":"","sources":["../src/packageOrder.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAW,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAyC9B,eAAO,MAAM,YAAY;;kCA8BM,CAAC"}
|
package/lib/packageOrder.js
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.packageOrder = void 0;
|
|
9
10
|
const tslib_1 = require("tslib");
|
|
10
|
-
const utils_1 = require("@monorepolint/utils");
|
|
11
11
|
const jest_diff_1 = tslib_1.__importDefault(require("jest-diff"));
|
|
12
12
|
const r = tslib_1.__importStar(require("runtypes"));
|
|
13
13
|
const Options = r
|
|
@@ -18,6 +18,7 @@ const Options = r
|
|
|
18
18
|
const defaultKeyOrder = [
|
|
19
19
|
"name",
|
|
20
20
|
"version",
|
|
21
|
+
"description",
|
|
21
22
|
"author",
|
|
22
23
|
"contributors",
|
|
23
24
|
"url",
|
|
@@ -47,20 +48,20 @@ exports.packageOrder = {
|
|
|
47
48
|
const packageJson = context.getPackageJson();
|
|
48
49
|
const packagePath = context.getPackageJsonPath();
|
|
49
50
|
const order = opts === undefined ? defaultKeyOrder : opts.order;
|
|
50
|
-
const
|
|
51
|
+
const comparator = isOrderFunction(order) ? order(context) : createComparator(order);
|
|
51
52
|
const actualOrder = Object.keys(packageJson);
|
|
52
|
-
const expectedOrder = actualOrder.slice().sort(
|
|
53
|
+
const expectedOrder = actualOrder.slice().sort(comparator); // sort mutates, so we need to copy the previous result
|
|
53
54
|
if (!arrayOrderCompare(actualOrder, expectedOrder)) {
|
|
54
55
|
context.addError({
|
|
55
56
|
file: packagePath,
|
|
56
57
|
message: "Incorrect order of fields in package.json",
|
|
57
|
-
longMessage: jest_diff_1.default(expectedOrder, actualOrder, { expand: true }),
|
|
58
|
+
longMessage: (0, jest_diff_1.default)(expectedOrder, actualOrder, { expand: true }),
|
|
58
59
|
fixer: () => {
|
|
59
60
|
const expectedPackageJson = {};
|
|
60
|
-
expectedOrder.forEach(key => {
|
|
61
|
+
expectedOrder.forEach((key) => {
|
|
61
62
|
expectedPackageJson[key] = packageJson[key];
|
|
62
63
|
});
|
|
63
|
-
|
|
64
|
+
context.host.writeJson(packagePath, expectedPackageJson);
|
|
64
65
|
},
|
|
65
66
|
});
|
|
66
67
|
}
|
|
@@ -75,7 +76,7 @@ function arrayOrderCompare(a, b) {
|
|
|
75
76
|
}
|
|
76
77
|
return true;
|
|
77
78
|
}
|
|
78
|
-
function
|
|
79
|
+
function createComparator(order) {
|
|
79
80
|
return (a, b) => {
|
|
80
81
|
const aIndex = order.indexOf(a);
|
|
81
82
|
const bIndex = order.indexOf(b);
|
package/lib/packageOrder.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageOrder.js","sourceRoot":"","sources":["../src/packageOrder.ts"],"names":[],"mappings":";AAAA;;;;;GAKG
|
|
1
|
+
{"version":3,"file":"packageOrder.js","sourceRoot":"","sources":["../src/packageOrder.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAGH,kEAA6B;AAC7B,oDAA8B;AAI9B,MAAM,OAAO,GAAG,CAAC;KACd,MAAM,CAAC;IACN,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC;CAC9C,CAAC;KACD,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;AAInB,MAAM,eAAe,GAAG;IACtB,MAAM;IACN,SAAS;IACT,aAAa;IACb,QAAQ;IACR,cAAc;IACd,KAAK;IACL,SAAS;IACT,SAAS;IACT,SAAS;IACT,KAAK;IACL,MAAM;IACN,QAAQ;IACR,SAAS;IACT,OAAO;IACP,aAAa;IACb,YAAY;IACZ,OAAO;IACP,aAAa;IACb,OAAO;IACP,SAAS;IACT,aAAa;IACb,cAAc;IACd,kBAAkB;IAClB,iBAAiB;IACjB,sBAAsB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C;IACD,cAAc,EAAE,OAAO;CACM,CAAC;AAEhC,SAAS,iBAAiB,CAAC,CAAwB,EAAE,CAAwB;IAC3E,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;QAC7C,IAAI,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,EAAE;YACzB,OAAO,KAAK,CAAC;SACd;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,gBAAgB,CAAC,KAA4B;IACpD,OAAO,CAAC,CAAS,EAAE,CAAS,EAAE,EAAE;QAC9B,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAChC,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAEhC,0EAA0E;QAC1E,IAAI,MAAM,IAAI,CAAC,IAAI,MAAM,GAAG,CAAC,EAAE;YAC7B,OAAO,CAAC,CAAC,CAAC;SACX;aAAM,IAAI,MAAM,GAAG,CAAC,IAAI,MAAM,IAAI,CAAC,EAAE;YACpC,OAAO,CAAC,CAAC;SACV;QAED,sEAAsE;QACtE,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;QAEjC,IAAI,QAAQ,KAAK,CAAC,EAAE;YAClB,OAAO,QAAQ,CAAC;SACjB;aAAM;YACL,OAAO,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;SAC3B;IACH,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,eAAe,CAAC,KAA4C;IACnE,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC"}
|
package/lib/packageScript.d.ts
CHANGED
|
@@ -7,19 +7,19 @@
|
|
|
7
7
|
import { RuleModule } from "@monorepolint/core";
|
|
8
8
|
import * as r from "runtypes";
|
|
9
9
|
export declare const Options: r.Record<{
|
|
10
|
-
scripts: r.
|
|
11
|
-
options: r.Array<r.
|
|
12
|
-
}, false>, r.
|
|
13
|
-
fixValue: r.
|
|
14
|
-
}
|
|
10
|
+
scripts: r.Dictionary<r.Union<[r.String, r.Intersect<[r.Record<{
|
|
11
|
+
options: r.Array<r.Union<[r.String, r.Literal<undefined>]>, false>;
|
|
12
|
+
}, false>, r.Partial<{
|
|
13
|
+
fixValue: r.Union<[r.String, r.Literal<undefined>, r.Literal<false>]>;
|
|
14
|
+
}, false>]>]>, string | number | symbol>;
|
|
15
15
|
}, false>;
|
|
16
16
|
export declare type Options = r.Static<typeof Options>;
|
|
17
17
|
export declare const MSG_NO_SCRIPTS_BLOCK = "No scripts block in package.json";
|
|
18
18
|
export declare const packageScript: RuleModule<r.Record<{
|
|
19
|
-
scripts: r.
|
|
20
|
-
options: r.Array<r.
|
|
21
|
-
}, false>, r.
|
|
22
|
-
fixValue: r.
|
|
23
|
-
}
|
|
19
|
+
scripts: r.Dictionary<r.Union<[r.String, r.Intersect<[r.Record<{
|
|
20
|
+
options: r.Array<r.Union<[r.String, r.Literal<undefined>]>, false>;
|
|
21
|
+
}, false>, r.Partial<{
|
|
22
|
+
fixValue: r.Union<[r.String, r.Literal<undefined>, r.Literal<false>]>;
|
|
23
|
+
}, false>]>]>, string | number | symbol>;
|
|
24
24
|
}, false>>;
|
|
25
25
|
//# sourceMappingURL=packageScript.d.ts.map
|
package/lib/packageScript.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.packageScript = exports.MSG_NO_SCRIPTS_BLOCK = exports.Options = void 0;
|
|
9
10
|
const tslib_1 = require("tslib");
|
|
10
11
|
const utils_1 = require("@monorepolint/utils");
|
|
11
12
|
const jest_diff_1 = tslib_1.__importDefault(require("jest-diff"));
|
|
@@ -17,7 +18,7 @@ exports.Options = r.Record({
|
|
|
17
18
|
})
|
|
18
19
|
.And(r.Partial({
|
|
19
20
|
fixValue: r.Union(r.String, r.Undefined, r.Literal(false)),
|
|
20
|
-
})))),
|
|
21
|
+
})))), // string => string
|
|
21
22
|
});
|
|
22
23
|
exports.MSG_NO_SCRIPTS_BLOCK = "No scripts block in package.json";
|
|
23
24
|
exports.packageScript = {
|
|
@@ -28,7 +29,7 @@ exports.packageScript = {
|
|
|
28
29
|
file: context.getPackageJsonPath(),
|
|
29
30
|
message: exports.MSG_NO_SCRIPTS_BLOCK,
|
|
30
31
|
fixer: () => {
|
|
31
|
-
utils_1.mutateJson(context.getPackageJsonPath(), input => {
|
|
32
|
+
(0, utils_1.mutateJson)(context.getPackageJsonPath(), context.host, (input) => {
|
|
32
33
|
input.scripts = {};
|
|
33
34
|
return input;
|
|
34
35
|
});
|
|
@@ -61,7 +62,7 @@ exports.packageScript = {
|
|
|
61
62
|
if (fixValue !== false && (fixValue !== undefined || fixToEmpty === true)) {
|
|
62
63
|
const q = fixValue;
|
|
63
64
|
fixer = () => {
|
|
64
|
-
utils_1.mutateJson(context.getPackageJsonPath(), input => {
|
|
65
|
+
(0, utils_1.mutateJson)(context.getPackageJsonPath(), context.host, (input) => {
|
|
65
66
|
if (fixToEmpty && q === undefined) {
|
|
66
67
|
delete input.scripts[name];
|
|
67
68
|
}
|
|
@@ -73,12 +74,12 @@ exports.packageScript = {
|
|
|
73
74
|
};
|
|
74
75
|
}
|
|
75
76
|
const validOptionsString = Array.from(allowedValues.values())
|
|
76
|
-
.map(a => (a === undefined ? "(empty)" : `'${a}'`))
|
|
77
|
+
.map((a) => (a === undefined ? "(empty)" : `'${a}'`))
|
|
77
78
|
.join(", ");
|
|
78
79
|
context.addError({
|
|
79
80
|
file: context.getPackageJsonPath(),
|
|
80
81
|
message: `Expected standardized script entry for '${name}'. Valid options: ${validOptionsString}`,
|
|
81
|
-
longMessage: jest_diff_1.default(validOptionsString + "\n", (packageJson.scripts[name] || "") + "\n"),
|
|
82
|
+
longMessage: (0, jest_diff_1.default)(validOptionsString + "\n", (packageJson.scripts[name] || "") + "\n"),
|
|
82
83
|
fixer,
|
|
83
84
|
});
|
|
84
85
|
}
|
package/lib/packageScript.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageScript.js","sourceRoot":"","sources":["../src/packageScript.ts"],"names":[],"mappings":";AAAA;;;;;GAKG
|
|
1
|
+
{"version":3,"file":"packageScript.js","sourceRoot":"","sources":["../src/packageScript.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAGH,+CAA8D;AAC9D,kEAA6B;AAC7B,oDAA8B;AAEjB,QAAA,OAAO,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9B,OAAO,EAAE,CAAC,CAAC,UAAU,CACnB,CAAC,CAAC,KAAK,CACL,CAAC,CAAC,MAAM,EACR,CAAC;SACE,MAAM,CAAC;QACN,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;KAC3C,CAAC;SACD,GAAG,CACF,CAAC,CAAC,OAAO,CAAC;QACR,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;KAC3D,CAAC,CACH,CACJ,CACF,EAAE,mBAAmB;CACvB,CAAC,CAAC;AAIU,QAAA,oBAAoB,GAAG,kCAAkC,CAAC;AAE1D,QAAA,aAAa,GAAG;IAC3B,KAAK,EAAE,SAAS,mBAAmB,CAAC,OAAgB,EAAE,OAAgB;QACpE,MAAM,WAAW,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;QAC7C,IAAI,WAAW,CAAC,OAAO,KAAK,SAAS,EAAE;YACrC,OAAO,CAAC,QAAQ,CAAC;gBACf,IAAI,EAAE,OAAO,CAAC,kBAAkB,EAAE;gBAClC,OAAO,EAAE,4BAAoB;gBAC7B,KAAK,EAAE,GAA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3
|
+
*
|
|
4
|
+
* Licensed under the MIT license. See LICENSE file in the project root for details.
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
7
|
+
import { RuleModule } from "@monorepolint/core";
|
|
8
|
+
import * as r from "runtypes";
|
|
9
|
+
export declare const requireDependency: RuleModule<r.Partial<{
|
|
10
|
+
dependencies: r.Dictionary<r.String, string | number | symbol>;
|
|
11
|
+
devDependencies: r.Dictionary<r.String, string | number | symbol>;
|
|
12
|
+
peerDependencies: r.Dictionary<r.String, string | number | symbol>;
|
|
13
|
+
optionalDependencies: r.Dictionary<r.String, string | number | symbol>;
|
|
14
|
+
}, false>>;
|
|
15
|
+
//# sourceMappingURL=requireDependency.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requireDependency.d.ts","sourceRoot":"","sources":["../src/requireDependency.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAW,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGzD,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAW9B,eAAO,MAAM,iBAAiB;;;;;UA+CC,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright 2019 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.requireDependency = void 0;
|
|
10
|
+
const tslib_1 = require("tslib");
|
|
11
|
+
const utils_1 = require("@monorepolint/utils");
|
|
12
|
+
const jest_diff_1 = tslib_1.__importDefault(require("jest-diff"));
|
|
13
|
+
const r = tslib_1.__importStar(require("runtypes"));
|
|
14
|
+
const Options = r.Partial({
|
|
15
|
+
dependencies: r.Dictionary(r.String),
|
|
16
|
+
devDependencies: r.Dictionary(r.String),
|
|
17
|
+
peerDependencies: r.Dictionary(r.String),
|
|
18
|
+
optionalDependencies: r.Dictionary(r.String),
|
|
19
|
+
});
|
|
20
|
+
exports.requireDependency = {
|
|
21
|
+
check: function expectPackageEntry(context, options) {
|
|
22
|
+
const packageJson = context.getPackageJson();
|
|
23
|
+
const packageJsonPath = context.getPackageJsonPath();
|
|
24
|
+
[
|
|
25
|
+
"dependencies",
|
|
26
|
+
"devDependencies",
|
|
27
|
+
"peerDependencies",
|
|
28
|
+
"optionalDependencies",
|
|
29
|
+
].forEach((type) => {
|
|
30
|
+
if (!options[type]) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (packageJson[type] === undefined) {
|
|
34
|
+
context.addError({
|
|
35
|
+
file: packageJsonPath,
|
|
36
|
+
message: `No ${type} block, cannot add required ${type}.`,
|
|
37
|
+
fixer: () => {
|
|
38
|
+
(0, utils_1.mutateJson)(packageJsonPath, context.host, (input) => {
|
|
39
|
+
input[type] = options[type];
|
|
40
|
+
return input;
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
for (const [dep, version] of Object.entries(options[type])) {
|
|
47
|
+
if (packageJson[type][dep] !== version) {
|
|
48
|
+
context.addError({
|
|
49
|
+
file: packageJsonPath,
|
|
50
|
+
message: `Expected dependency ${dep}@${version}`,
|
|
51
|
+
longMessage: (0, jest_diff_1.default)(`${dep}@${version}\n`, `${dep}@${packageJson[type][dep] || "missing"}\n`),
|
|
52
|
+
fixer: () => {
|
|
53
|
+
(0, utils_1.mutateJson)(packageJsonPath, context.host, (input) => {
|
|
54
|
+
input[type] = { ...input[type], [dep]: version };
|
|
55
|
+
return input;
|
|
56
|
+
});
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
optionsRuntype: Options,
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=requireDependency.js.map
|
|
@@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AAO,KAAK,CAAC;wBACf,CAAC,CAAC,CAAC;oBACL,CAAC;iBACF,CAAC,CAAC;gBACH,OAAO;aACR;YAED,KAAK,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAE,CAAC,EAAE;gBAC3D,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,OAAO,EAAE;oBACtC,OAAO,CAAC,QAAQ,CAAC;wBACf,IAAI,EAAE,eAAe;wBACrB,OAAO,EAAE,uBAAuB,GAAG,IAAI,OAAO,EAAE;wBAChD,WAAW,EAAE,IAAA,mBAAI,EAAC,GAAG,GAAG,IAAI,OAAO,IAAI,EAAE,GAAG,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,SAAS,IAAI,CAAE;wBAC5F,KAAK,EAAE,GAAG,EAAE;4BACV,IAAA,kBAAU,EAAc,eAAe,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE;gCAC/D,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,CAAC;gCACjD,OAAO,KAAK,CAAC;4BACf,CAAC,CAAC,CAAC;wBACL,CAAC;qBACF,CAAC,CAAC;iBACJ;aACF;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IACD,cAAc,EAAE,OAAO;CACM,CAAC"}
|
|
@@ -6,28 +6,40 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { RuleModule } from "@monorepolint/core";
|
|
8
8
|
import * as r from "runtypes";
|
|
9
|
-
declare const Options: r.Constraint<r.
|
|
9
|
+
declare const Options: r.Constraint<r.Partial<{
|
|
10
|
+
file: r.String;
|
|
10
11
|
generator: r.Function;
|
|
11
|
-
|
|
12
|
+
tsconfigReferenceFile: r.String;
|
|
13
|
+
template: r.Union<[r.Record<{}, false>, r.String]>;
|
|
12
14
|
templateFile: r.String;
|
|
13
|
-
excludedReferences: r.
|
|
14
|
-
|
|
15
|
+
excludedReferences: r.Union<[r.Array<r.String, false>, r.Literal<undefined>]>;
|
|
16
|
+
additionalReferences: r.Union<[r.Array<r.String, false>, r.Literal<undefined>]>;
|
|
17
|
+
}, false>, {
|
|
18
|
+
file?: string | undefined;
|
|
15
19
|
generator?: ((...args: any[]) => any) | undefined;
|
|
20
|
+
tsconfigReferenceFile?: string | undefined;
|
|
16
21
|
template?: string | {} | undefined;
|
|
17
22
|
templateFile?: string | undefined;
|
|
18
23
|
excludedReferences?: string[] | undefined;
|
|
24
|
+
additionalReferences?: string[] | undefined;
|
|
19
25
|
}, unknown>;
|
|
20
26
|
export declare type Options = r.Static<typeof Options>;
|
|
21
|
-
export declare const standardTsconfig: RuleModule<r.Constraint<r.
|
|
27
|
+
export declare const standardTsconfig: RuleModule<r.Constraint<r.Partial<{
|
|
28
|
+
file: r.String;
|
|
22
29
|
generator: r.Function;
|
|
23
|
-
|
|
30
|
+
tsconfigReferenceFile: r.String;
|
|
31
|
+
template: r.Union<[r.Record<{}, false>, r.String]>;
|
|
24
32
|
templateFile: r.String;
|
|
25
|
-
excludedReferences: r.
|
|
26
|
-
|
|
33
|
+
excludedReferences: r.Union<[r.Array<r.String, false>, r.Literal<undefined>]>;
|
|
34
|
+
additionalReferences: r.Union<[r.Array<r.String, false>, r.Literal<undefined>]>;
|
|
35
|
+
}, false>, {
|
|
36
|
+
file?: string | undefined;
|
|
27
37
|
generator?: ((...args: any[]) => any) | undefined;
|
|
38
|
+
tsconfigReferenceFile?: string | undefined;
|
|
28
39
|
template?: string | {} | undefined;
|
|
29
40
|
templateFile?: string | undefined;
|
|
30
41
|
excludedReferences?: string[] | undefined;
|
|
42
|
+
additionalReferences?: string[] | undefined;
|
|
31
43
|
}, unknown>>;
|
|
32
44
|
export {};
|
|
33
45
|
//# sourceMappingURL=standardTsconfig.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standardTsconfig.d.ts","sourceRoot":"","sources":["../src/standardTsconfig.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAW,UAAU,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"standardTsconfig.d.ts","sourceRoot":"","sources":["../src/standardTsconfig.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAW,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAIzD,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAI9B,QAAA,MAAM,OAAO;;;;;;;;;;;;;;;;WAuBT,CAAC;AAEL,oBAAY,OAAO,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,OAAO,CAAC,CAAC;AAE/C,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;YAiCE,CAAC"}
|