@monorepolint/rules 0.5.0-beta.1 → 0.5.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/.turbo/turbo-clean.log +4 -0
  2. package/.turbo/turbo-compile-typescript.log +4 -0
  3. package/.turbo/turbo-lint.log +4 -0
  4. package/.turbo/turbo-test.log +667 -0
  5. package/.turbo/turbo-transpile-typescript.log +14 -0
  6. package/CHANGELOG.md +29 -4
  7. package/build/js/index.js +1422 -0
  8. package/build/js/index.js.map +1 -0
  9. package/build/tsconfig.tsbuildinfo +1 -0
  10. package/build/types/__tests__/alphabeticalScripts.spec.d.ts +8 -0
  11. package/build/types/__tests__/alphabeticalScripts.spec.d.ts.map +1 -0
  12. package/build/types/__tests__/bannedDependencies.spec.d.ts +2 -0
  13. package/build/types/__tests__/bannedDependencies.spec.d.ts.map +1 -0
  14. package/build/types/__tests__/consistentDependencies.spec.d.ts +2 -0
  15. package/build/types/__tests__/consistentDependencies.spec.d.ts.map +1 -0
  16. package/build/types/__tests__/consistentVersions.spec.d.ts +8 -0
  17. package/build/types/__tests__/consistentVersions.spec.d.ts.map +1 -0
  18. package/build/types/__tests__/fileContents.spec.d.ts +8 -0
  19. package/build/types/__tests__/fileContents.spec.d.ts.map +1 -0
  20. package/build/types/__tests__/mustSatisfyPeerDependencies.spec.d.ts +8 -0
  21. package/build/types/__tests__/mustSatisfyPeerDependencies.spec.d.ts.map +1 -0
  22. package/build/types/__tests__/nestedWorkspaces.spec.d.ts +2 -0
  23. package/build/types/__tests__/nestedWorkspaces.spec.d.ts.map +1 -0
  24. package/build/types/__tests__/packageEntry.spec.d.ts +8 -0
  25. package/build/types/__tests__/packageEntry.spec.d.ts.map +1 -0
  26. package/build/types/__tests__/packageOrder.spec.d.ts +8 -0
  27. package/build/types/__tests__/packageOrder.spec.d.ts.map +1 -0
  28. package/build/types/__tests__/packageScript.spec.d.ts +8 -0
  29. package/build/types/__tests__/packageScript.spec.d.ts.map +1 -0
  30. package/build/types/__tests__/requireDependency.spec.d.ts +2 -0
  31. package/build/types/__tests__/requireDependency.spec.d.ts.map +1 -0
  32. package/build/types/__tests__/utils.d.ts +81 -0
  33. package/build/types/__tests__/utils.d.ts.map +1 -0
  34. package/build/types/alphabeticalDependencies.d.ts +8 -0
  35. package/build/types/alphabeticalDependencies.d.ts.map +1 -0
  36. package/build/types/alphabeticalScripts.d.ts +8 -0
  37. package/build/types/alphabeticalScripts.d.ts.map +1 -0
  38. package/build/types/bannedDependencies.d.ts +48 -0
  39. package/build/types/bannedDependencies.d.ts.map +1 -0
  40. package/build/types/consistentDependencies.d.ts +16 -0
  41. package/build/types/consistentDependencies.d.ts.map +1 -0
  42. package/build/types/consistentVersions.d.ts +19 -0
  43. package/build/types/consistentVersions.d.ts.map +1 -0
  44. package/build/types/fileContents.d.ts +24 -0
  45. package/build/types/fileContents.d.ts.map +1 -0
  46. package/build/types/index.d.ts +21 -0
  47. package/build/types/index.d.ts.map +1 -0
  48. package/build/types/mustSatisfyPeerDependencies.d.ts +333 -0
  49. package/build/types/mustSatisfyPeerDependencies.d.ts.map +1 -0
  50. package/build/types/nestedWorkspaces.d.ts +10 -0
  51. package/build/types/nestedWorkspaces.d.ts.map +1 -0
  52. package/build/types/packageEntry.d.ts +43 -0
  53. package/build/types/packageEntry.d.ts.map +1 -0
  54. package/build/types/packageOrder.d.ts +10 -0
  55. package/build/types/packageOrder.d.ts.map +1 -0
  56. package/build/types/packageScript.d.ts +32 -0
  57. package/build/types/packageScript.d.ts.map +1 -0
  58. package/build/types/requireDependency.d.ts +29 -0
  59. package/build/types/requireDependency.d.ts.map +1 -0
  60. package/build/types/standardTsconfig.d.ts +29 -0
  61. package/build/types/standardTsconfig.d.ts.map +1 -0
  62. package/build/types/util/checkAlpha.d.ts +10 -0
  63. package/build/types/util/checkAlpha.d.ts.map +1 -0
  64. package/build/types/util/createRuleFactory.d.ts +14 -0
  65. package/build/types/util/createRuleFactory.d.ts.map +1 -0
  66. package/build/types/util/makeDirectory.d.ts +8 -0
  67. package/build/types/util/makeDirectory.d.ts.map +1 -0
  68. package/build/types/util/packageDependencyGraphService.d.ts +37 -0
  69. package/build/types/util/packageDependencyGraphService.d.ts.map +1 -0
  70. package/package.json +4 -4
  71. package/src/alphabeticalDependencies.ts +2 -2
  72. package/src/alphabeticalScripts.ts +2 -2
  73. package/src/bannedDependencies.ts +2 -2
  74. package/src/consistentDependencies.ts +2 -2
  75. package/src/consistentVersions.ts +2 -2
  76. package/src/fileContents.ts +2 -2
  77. package/src/index.ts +8 -0
  78. package/src/mustSatisfyPeerDependencies.ts +2 -2
  79. package/src/nestedWorkspaces.ts +4 -4
  80. package/src/packageEntry.ts +2 -2
  81. package/src/packageOrder.ts +2 -2
  82. package/src/packageScript.ts +2 -2
  83. package/src/requireDependency.ts +2 -2
  84. package/src/standardTsconfig.ts +2 -2
  85. package/src/util/createRuleFactory.ts +33 -0
  86. package/src/public/util.ts +0 -1
  87. package/src/util/makeRule.ts +0 -29
@@ -0,0 +1,43 @@
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 * as r from "runtypes";
8
+ export declare const Options: r.Union<[r.Intersect<[r.Record<{
9
+ entries: r.Dictionary<r.Unknown, string | number | symbol>;
10
+ }, false>, r.Partial<{
11
+ entriesExist: r.Literal<undefined>;
12
+ }, false>]>, r.Intersect<[r.Record<{
13
+ entriesExist: r.Array<r.String, false>;
14
+ }, false>, r.Partial<{
15
+ entries: r.Literal<undefined>;
16
+ }, false>]>, r.Record<{
17
+ entries: r.Dictionary<r.Unknown, string | number | symbol>;
18
+ entriesExist: r.Array<r.String, false>;
19
+ }, false>]>;
20
+ export type Options = r.Static<typeof Options>;
21
+ export declare const packageEntry: import("./util/createRuleFactory.js").RuleFactoryFn<({
22
+ entries: {
23
+ [x: string]: unknown;
24
+ [x: number]: unknown;
25
+ [x: symbol]: unknown;
26
+ };
27
+ } & {
28
+ entriesExist?: undefined;
29
+ }) | ({
30
+ entriesExist: string[];
31
+ } & {
32
+ entries?: undefined;
33
+ }) | {
34
+ entries: {
35
+ [x: string]: unknown;
36
+ [x: number]: unknown;
37
+ [x: symbol]: unknown;
38
+ };
39
+ entriesExist: string[];
40
+ }>;
41
+ export declare function createStandardizedEntryErrorMessage(key: string): string;
42
+ export declare function createExpectedEntryErrorMessage(key: string): string;
43
+ //# sourceMappingURL=packageEntry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"packageEntry.d.ts","sourceRoot":"","sources":["../../src/packageEntry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAG9B,eAAO,MAAM,OAAO;;;;;;;;;;;WAuBnB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,OAAO,CAAC,CAAC;AAE/C,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;EA0CvB,CAAC;AAEH,wBAAgB,mCAAmC,CAAC,GAAG,EAAE,MAAM,UAE9D;AAED,wBAAgB,+BAA+B,CAAC,GAAG,EAAE,MAAM,UAE1D"}
@@ -0,0 +1,10 @@
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
+ export declare const packageOrder: import("./util/createRuleFactory.js").RuleFactoryFn<{
8
+ order: string[] | ((...args: any[]) => any);
9
+ } | undefined>;
10
+ //# sourceMappingURL=packageOrder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"packageOrder.d.ts","sourceRoot":"","sources":["../../src/packageOrder.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAgDH,eAAO,MAAM,YAAY;;cAgCvB,CAAC"}
@@ -0,0 +1,32 @@
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 * as r from "runtypes";
8
+ export declare const Options: r.Record<{
9
+ scripts: r.Dictionary<r.Union<[r.String, r.Record<{
10
+ options: r.Array<r.Union<[r.String, r.Literal<undefined>]>, false>;
11
+ fixValue: r.Optional<r.Union<[r.String, r.Literal<undefined>, r.Literal<false>]>>;
12
+ }, false>]>, string | number | symbol>;
13
+ }, false>;
14
+ export type Options = r.Static<typeof Options>;
15
+ export declare const MSG_NO_SCRIPTS_BLOCK = "No scripts block in package.json";
16
+ export declare const packageScript: import("./util/createRuleFactory.js").RuleFactoryFn<{
17
+ scripts: {
18
+ [x: string]: string | {
19
+ options: (string | undefined)[];
20
+ fixValue?: string | false | undefined;
21
+ };
22
+ [x: number]: string | {
23
+ options: (string | undefined)[];
24
+ fixValue?: string | false | undefined;
25
+ };
26
+ [x: symbol]: string | {
27
+ options: (string | undefined)[];
28
+ fixValue?: string | false | undefined;
29
+ };
30
+ };
31
+ }>;
32
+ //# sourceMappingURL=packageScript.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"packageScript.d.ts","sourceRoot":"","sources":["../../src/packageScript.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAG9B,eAAO,MAAM,OAAO;;;;;SAUlB,CAAC;AAEH,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,OAAO,CAAC,CAAC;AAE/C,eAAO,MAAM,oBAAoB,qCAAqC,CAAC;AAEvE,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;EAsExB,CAAC"}
@@ -0,0 +1,29 @@
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
+ export declare const requireDependency: import("./util/createRuleFactory.js").RuleFactoryFn<{
8
+ dependencies?: {
9
+ [x: string]: string;
10
+ [x: number]: string;
11
+ [x: symbol]: string;
12
+ } | undefined;
13
+ devDependencies?: {
14
+ [x: string]: string;
15
+ [x: number]: string;
16
+ [x: symbol]: string;
17
+ } | undefined;
18
+ peerDependencies?: {
19
+ [x: string]: string;
20
+ [x: number]: string;
21
+ [x: symbol]: string;
22
+ } | undefined;
23
+ optionalDependencies?: {
24
+ [x: string]: string;
25
+ [x: number]: string;
26
+ [x: symbol]: string;
27
+ } | undefined;
28
+ }>;
29
+ //# sourceMappingURL=requireDependency.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requireDependency.d.ts","sourceRoot":"","sources":["../../src/requireDependency.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAiBH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;EAgD5B,CAAC"}
@@ -0,0 +1,29 @@
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 * as r from "runtypes";
8
+ declare const Options: r.Constraint<r.Partial<{
9
+ file: r.String;
10
+ generator: r.Function;
11
+ tsconfigReferenceFile: r.String;
12
+ template: r.Union<[r.Record<{}, false>, r.String]>;
13
+ templateFile: r.String;
14
+ excludedReferences: r.Union<[r.Array<r.String, false>, r.Literal<undefined>]>;
15
+ additionalReferences: r.Union<[r.Array<r.String, false>, r.Literal<undefined>]>;
16
+ }, false>, {
17
+ file?: string | undefined;
18
+ generator?: ((...args: any[]) => any) | undefined;
19
+ tsconfigReferenceFile?: string | undefined;
20
+ template?: string | {} | undefined;
21
+ templateFile?: string | undefined;
22
+ excludedReferences?: string[] | undefined;
23
+ additionalReferences?: string[] | undefined;
24
+ }, unknown>;
25
+ export interface Options extends r.Static<typeof Options> {
26
+ }
27
+ export declare const standardTsconfig: import("./util/createRuleFactory.js").RuleFactoryFn<Options>;
28
+ export {};
29
+ //# sourceMappingURL=standardTsconfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standardTsconfig.d.ts","sourceRoot":"","sources":["../../src/standardTsconfig.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAK9B,QAAA,MAAM,OAAO;;;;;;;;;;;;;;;;WAuBT,CAAC;AAEL,MAAM,WAAW,OAAQ,SAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,OAAO,CAAC;CAAG;AAE5D,eAAO,MAAM,gBAAgB,8DAkC3B,CAAC"}
@@ -0,0 +1,10 @@
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 { Context } from "@monorepolint/config";
8
+ export declare function checkAlpha(context: Context, block: "dependencies" | "devDependencies" | "peerDependencies" | "scripts"): void;
9
+ export declare function createIncorrectOrderErrorMessage(block: string, packageName: string): string;
10
+ //# sourceMappingURL=checkAlpha.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkAlpha.d.ts","sourceRoot":"","sources":["../../../src/util/checkAlpha.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAG/C,wBAAgB,UAAU,CACxB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,cAAc,GAAG,iBAAiB,GAAG,kBAAkB,GAAG,SAAS,QAgC3E;AAYD,wBAAgB,gCAAgC,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,UAElF"}
@@ -0,0 +1,14 @@
1
+ import { Context, RuleEntry, RuleModule } from "@monorepolint/config";
2
+ export type ValidateOptionsFn<X> = (options: unknown) => asserts options is X;
3
+ export type RuleFactoryFn<T> = (ruleEntry: RuleEntry<T>) => RuleModule<T>;
4
+ export type RuleCheckFn<O> = (context: Context, options: O, extra: {
5
+ id: string;
6
+ }) => Promise<unknown> | unknown;
7
+ export interface RuleFactoryOptions<X> {
8
+ name: string;
9
+ check: RuleCheckFn<X>;
10
+ printStats?: () => void;
11
+ validateOptions: ValidateOptionsFn<X>;
12
+ }
13
+ export declare function createRuleFactory<X>({ name, check, validateOptions, printStats, }: RuleFactoryOptions<X>): RuleFactoryFn<X>;
14
+ //# sourceMappingURL=createRuleFactory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createRuleFactory.d.ts","sourceRoot":"","sources":["../../../src/util/createRuleFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEtE,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,IAAI,CAAC,CAAC;AAC9E,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,CAAC;AAC1E,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AAEjH,MAAM,WAAW,kBAAkB,CAAC,CAAC;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,eAAe,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC;CACvC;AAGD,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,EACnC,IAAI,EACJ,KAAK,EACL,eAAe,EACf,UAAU,GACX,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAa1C"}
@@ -0,0 +1,8 @@
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
+ export declare function makeDirectoryRecursively(directoryPath: string): void;
8
+ //# sourceMappingURL=makeDirectory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"makeDirectory.d.ts","sourceRoot":"","sources":["../../../src/util/makeDirectory.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,wBAAgB,wBAAwB,CAAC,aAAa,EAAE,MAAM,QAa7D"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @license Copyright 2019 Palantir Technologies, Inc. All rights reserved.
3
+ */
4
+ import { Host, PackageJson } from "@monorepolint/utils";
5
+ /** Interface for a node in a package dependency graph. */
6
+ export interface IPackageDependencyGraphNode {
7
+ packageJson: PackageJson;
8
+ dependencies: Map<string, IPackageDependencyGraphNode>;
9
+ paths: {
10
+ packageJsonPath: string;
11
+ rootDirectory: string;
12
+ };
13
+ }
14
+ /** Service abstraction for constructing and traversing package dependency graphs. */
15
+ export interface IPackageDependencyGraphService {
16
+ /** Construct a graph of package dependencies. */
17
+ buildDependencyGraph(packageJsonPath: string, host: Host, maxDepth?: number): IPackageDependencyGraphNode;
18
+ /** Traverse a package dependency graph. */
19
+ traverse(root: IPackageDependencyGraphNode, opts?: {
20
+ /** Traverse each unique path to a given package (potentially slow). */
21
+ traverseAllPaths?: boolean;
22
+ }): IterableIterator<IPackageDependencyGraphNode & {
23
+ importPath: IPackageDependencyGraphNode[];
24
+ }>;
25
+ }
26
+ /** Default implementation of the package dependency graph service. */
27
+ export declare class PackageDependencyGraphService implements IPackageDependencyGraphService {
28
+ /** Construct a graph of package dependencies and return the root node. */
29
+ buildDependencyGraph(startPackageJsonPath: string, host: Host, maxDepth?: number): IPackageDependencyGraphNode;
30
+ /** Traverse a package dependency graph with an iterator. */
31
+ traverse(root: IPackageDependencyGraphNode, opts?: {
32
+ traverseAllPaths: boolean;
33
+ }): IterableIterator<IPackageDependencyGraphNode & {
34
+ importPath: IPackageDependencyGraphNode[];
35
+ }>;
36
+ }
37
+ //# sourceMappingURL=packageDependencyGraphService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"packageDependencyGraphService.d.ts","sourceRoot":"","sources":["../../../src/util/packageDependencyGraphService.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAIxD,0DAA0D;AAC1D,MAAM,WAAW,2BAA2B;IAC1C,WAAW,EAAE,WAAW,CAAC;IACzB,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,2BAA2B,CAAC,CAAC;IACvD,KAAK,EAAE;QACL,eAAe,EAAE,MAAM,CAAC;QACxB,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;CACH;AAED,qFAAqF;AACrF,MAAM,WAAW,8BAA8B;IAC7C,iDAAiD;IACjD,oBAAoB,CAAC,eAAe,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,2BAA2B,CAAC;IAE1G,2CAA2C;IAC3C,QAAQ,CACN,IAAI,EAAE,2BAA2B,EACjC,IAAI,CAAC,EAAE;QACL,uEAAuE;QACvE,gBAAgB,CAAC,EAAE,OAAO,CAAC;KAC5B,GACA,gBAAgB,CAAC,2BAA2B,GAAG;QAAE,UAAU,EAAE,2BAA2B,EAAE,CAAA;KAAE,CAAC,CAAC;CAClG;AAED,sEAAsE;AACtE,qBAAa,6BAA8B,YAAW,8BAA8B;IAClF,0EAA0E;IACnE,oBAAoB,CACzB,oBAAoB,EAAE,MAAM,EAC5B,IAAI,EAAE,IAAI,EACV,QAAQ,CAAC,EAAE,MAAM,GAChB,2BAA2B;IAuC9B,4DAA4D;IACpD,QAAQ,CACd,IAAI,EAAE,2BAA2B,EACjC,IAAI;;KAA8B,GACjC,gBAAgB,CAAC,2BAA2B,GAAG;QAAE,UAAU,EAAE,2BAA2B,EAAE,CAAA;KAAE,CAAC;CA8BjG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monorepolint/rules",
3
- "version": "0.5.0-beta.1",
3
+ "version": "0.5.0-beta.10",
4
4
  "author": "Eric L Anderson (https://github.com/ericanderson)",
5
5
  "contributors": [
6
6
  "Mac Lockard (https://github.com/maclockard)"
@@ -28,9 +28,9 @@
28
28
  "runtypes": "^6.7.0",
29
29
  "semver": "^7.6.0",
30
30
  "tslib": "^2.6.2",
31
- "@monorepolint/core": "^0.5.0-beta.1",
32
- "@monorepolint/config": "^0.5.0-beta.1",
33
- "@monorepolint/utils": "^0.5.0-beta.1"
31
+ "@monorepolint/core": "^0.5.0-beta.10",
32
+ "@monorepolint/config": "^0.5.0-beta.10",
33
+ "@monorepolint/utils": "^0.5.0-beta.10"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@jest/globals": "^29.7.0",
@@ -6,9 +6,9 @@
6
6
  */
7
7
 
8
8
  import { checkAlpha } from "./util/checkAlpha.js";
9
- import { makeRule } from "./util/makeRule.js";
9
+ import { createRuleFactory } from "./util/createRuleFactory.js";
10
10
 
11
- export const alphabeticalDependencies = makeRule<undefined>({
11
+ export const alphabeticalDependencies = createRuleFactory<undefined>({
12
12
  name: "alphabeticalDependencies",
13
13
  check: (context) => {
14
14
  checkAlpha(context, "dependencies");
@@ -6,9 +6,9 @@
6
6
  */
7
7
 
8
8
  import { checkAlpha } from "./util/checkAlpha.js";
9
- import { makeRule } from "./util/makeRule.js";
9
+ import { createRuleFactory } from "./util/createRuleFactory.js";
10
10
 
11
- export const alphabeticalScripts = makeRule<undefined>({
11
+ export const alphabeticalScripts = createRuleFactory<undefined>({
12
12
  name: "alphabeticalScripts",
13
13
  check: (context) => {
14
14
  checkAlpha(context, "scripts");
@@ -10,7 +10,7 @@ import { matchesAnyGlob } from "@monorepolint/utils";
10
10
  import { AggregateTiming } from "@monorepolint/utils";
11
11
  import * as path from "node:path";
12
12
  import * as r from "runtypes";
13
- import { makeRule } from "./util/makeRule.js";
13
+ import { createRuleFactory } from "./util/createRuleFactory.js";
14
14
  import { IPackageDependencyGraphNode, PackageDependencyGraphService } from "./util/packageDependencyGraphService.js";
15
15
  // FIXME: This rule is messed. bannedTransitiveDependencies doesnt glob
16
16
 
@@ -49,7 +49,7 @@ const setCache = new Map<ReadonlyArray<string>, Set<string>>();
49
49
 
50
50
  const aggregateTiming = new AggregateTiming(":bannedDependencies stats");
51
51
 
52
- export const bannedDependencies = makeRule<Options>({
52
+ export const bannedDependencies = createRuleFactory<Options>({
53
53
  name: "bannedDependencies",
54
54
  check: (context, opts, extra) => {
55
55
  aggregateTiming.start(extra?.id ?? "unknown id");
@@ -8,7 +8,7 @@
8
8
  import { Context } from "@monorepolint/config";
9
9
  import { diff } from "jest-diff";
10
10
  import * as r from "runtypes";
11
- import { makeRule } from "./util/makeRule.js";
11
+ import { createRuleFactory } from "./util/createRuleFactory.js";
12
12
  const Options = r
13
13
  .Record({
14
14
  ignoredDependencies: r.Array(r.String).Or(r.Undefined),
@@ -18,7 +18,7 @@ export type Options = r.Static<typeof Options>;
18
18
 
19
19
  const skippedVersions = ["*", "latest"];
20
20
 
21
- export const consistentDependencies = makeRule<Options>({
21
+ export const consistentDependencies = createRuleFactory<Options>({
22
22
  name: "consistentDependencies",
23
23
  check: (context, args) => {
24
24
  checkDeps(context, args, "dependencies");
@@ -9,14 +9,14 @@ import { Context } 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 { makeRule } from "./util/makeRule.js";
12
+ import { createRuleFactory } from "./util/createRuleFactory.js";
13
13
  export const Options = r.Record({
14
14
  matchDependencyVersions: r.Dictionary(r.Union(r.String, r.Array(r.String))),
15
15
  });
16
16
 
17
17
  export type Options = r.Static<typeof Options>;
18
18
 
19
- export const consistentVersions = makeRule({
19
+ export const consistentVersions = createRuleFactory({
20
20
  name: "consistentVersions",
21
21
  check: checkConsistentVersions,
22
22
  validateOptions: Options.check,
@@ -9,7 +9,7 @@ import { Context } from "@monorepolint/config";
9
9
  import { diff } from "jest-diff";
10
10
  import * as path from "path";
11
11
  import * as r from "runtypes";
12
- import { makeRule } from "./util/makeRule.js";
12
+ import { createRuleFactory } from "./util/createRuleFactory.js";
13
13
  const Options = r.Union(
14
14
  r.Record({
15
15
  file: r.String,
@@ -35,7 +35,7 @@ const Options = r.Union(
35
35
 
36
36
  type Options = r.Static<typeof Options>;
37
37
 
38
- export const fileContents = makeRule<Options>({
38
+ export const fileContents = createRuleFactory<Options>({
39
39
  name: "fileContents",
40
40
  check: async (context, opts) => {
41
41
  const fullPath = path.join(context.packageDir, opts.file);
package/src/index.ts CHANGED
@@ -18,3 +18,11 @@ export { packageScript } from "./packageScript.js";
18
18
  export { standardTsconfig } from "./standardTsconfig.js";
19
19
  export { nestedWorkspaces } from "./nestedWorkspaces.js";
20
20
  export { requireDependency } from "./requireDependency.js";
21
+
22
+ export {
23
+ createRuleFactory,
24
+ RuleCheckFn,
25
+ RuleFactoryFn,
26
+ RuleFactoryOptions,
27
+ ValidateOptionsFn,
28
+ } from "./util/createRuleFactory.js";
@@ -11,7 +11,7 @@ import * as path from "node:path";
11
11
  import * as r from "runtypes";
12
12
  import { coerce } from "semver";
13
13
  import resolvePackagePath from "resolve-package-path";
14
- import { makeRule } from "./util/makeRule.js";
14
+ import { createRuleFactory } from "./util/createRuleFactory.js";
15
15
 
16
16
  const Options = r.Union(
17
17
  r.Partial({
@@ -184,7 +184,7 @@ const Options = r.Union(
184
184
 
185
185
  export type Options = r.Static<typeof Options>;
186
186
 
187
- export const mustSatisfyPeerDependencies = makeRule({
187
+ export const mustSatisfyPeerDependencies = createRuleFactory({
188
188
  name: "mustSatisfyPeerDependencies",
189
189
  check: checkSatisfyPeerDependencies,
190
190
  validateOptions: Options.check,
@@ -8,14 +8,14 @@
8
8
  import * as globby from "globby";
9
9
  import * as path from "node:path";
10
10
  import * as r from "runtypes";
11
- import { makeRule } from "./util/makeRule.js";
11
+ import { createRuleFactory } from "./util/createRuleFactory.js";
12
12
 
13
13
  export const Options = r.Undefined;
14
14
 
15
15
  type Options = r.Static<typeof Options>;
16
16
 
17
17
  // Enforce that the root package.json contains all of the workspaces in the repo (including nested packages)
18
- export const nestedWorkspaces = makeRule({
18
+ export const nestedWorkspaces = createRuleFactory({
19
19
  name: "nestedWorkspaces",
20
20
  check: (context) => {
21
21
  const rootPackageJson = context.getWorkspaceContext().getPackageJson();
@@ -26,8 +26,8 @@ export const nestedWorkspaces = makeRule({
26
26
  const workspaces = Array.isArray(rootPackageJson.workspaces)
27
27
  ? rootPackageJson.workspaces
28
28
  : rootPackageJson.workspaces !== undefined
29
- ? rootPackageJson.workspaces.packages
30
- : undefined;
29
+ ? rootPackageJson.workspaces.packages
30
+ : undefined;
31
31
 
32
32
  if (workspaces === undefined && packageJsonPaths.length > 0) {
33
33
  context.addError({
@@ -8,7 +8,7 @@
8
8
  import { mutateJson, PackageJson } from "@monorepolint/utils";
9
9
  import { diff } from "jest-diff";
10
10
  import * as r from "runtypes";
11
- import { makeRule } from "./util/makeRule.js";
11
+ import { createRuleFactory } from "./util/createRuleFactory.js";
12
12
 
13
13
  export const Options = r.Union(
14
14
  r
@@ -37,7 +37,7 @@ export const Options = r.Union(
37
37
 
38
38
  export type Options = r.Static<typeof Options>;
39
39
 
40
- export const packageEntry = makeRule<Options>({
40
+ export const packageEntry = createRuleFactory<Options>({
41
41
  name: "packageEntry",
42
42
  check: (context, options) => {
43
43
  const packageJson = context.getPackageJson();
@@ -8,7 +8,7 @@
8
8
  import { Context } from "@monorepolint/config";
9
9
  import { diff } from "jest-diff";
10
10
  import * as r from "runtypes";
11
- import { makeRule } from "./util/makeRule.js";
11
+ import { createRuleFactory } from "./util/createRuleFactory.js";
12
12
  type OrderFunction = (context: Context) => (a: string, b: string) => number;
13
13
 
14
14
  const Options = r
@@ -51,7 +51,7 @@ const defaultKeyOrder = [
51
51
  "publishConfig",
52
52
  ];
53
53
 
54
- export const packageOrder = makeRule<Options>({
54
+ export const packageOrder = createRuleFactory<Options>({
55
55
  name: "packageOrder",
56
56
  check: (context, opts) => {
57
57
  const packageJson = context.getPackageJson();
@@ -8,7 +8,7 @@
8
8
  import { mutateJson, PackageJson } from "@monorepolint/utils";
9
9
  import { diff } from "jest-diff";
10
10
  import * as r from "runtypes";
11
- import { makeRule } from "./util/makeRule.js";
11
+ import { createRuleFactory } from "./util/createRuleFactory.js";
12
12
 
13
13
  export const Options = r.Record({
14
14
  scripts: r.Dictionary(
@@ -26,7 +26,7 @@ export type Options = r.Static<typeof Options>;
26
26
 
27
27
  export const MSG_NO_SCRIPTS_BLOCK = "No scripts block in package.json";
28
28
 
29
- export const packageScript = makeRule<Options>({
29
+ export const packageScript = createRuleFactory<Options>({
30
30
  name: "packageScript",
31
31
  check: (context, options) => {
32
32
  const packageJson = context.getPackageJson();
@@ -9,7 +9,7 @@ import { Context } 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 { makeRule } from "./util/makeRule.js";
12
+ import { createRuleFactory } from "./util/createRuleFactory.js";
13
13
 
14
14
  const Options = r.Partial({
15
15
  dependencies: r.Dictionary(r.String),
@@ -20,7 +20,7 @@ const Options = r.Partial({
20
20
 
21
21
  type Options = r.Static<typeof Options>;
22
22
 
23
- export const requireDependency = makeRule({
23
+ export const requireDependency = createRuleFactory({
24
24
  name: "requireDependency",
25
25
  check: function expectPackageEntry(context: Context, options: Options) {
26
26
  const packageJson = context.getPackageJson();
@@ -10,7 +10,7 @@ import { matchesAnyGlob } from "@monorepolint/utils";
10
10
  import { diff } from "jest-diff";
11
11
  import * as path from "path";
12
12
  import * as r from "runtypes";
13
- import { makeRule } from "./util/makeRule.js";
13
+ import { createRuleFactory } from "./util/createRuleFactory.js";
14
14
 
15
15
  const DEFAULT_TSCONFIG_FILENAME = "tsconfig.json";
16
16
 
@@ -41,7 +41,7 @@ const Options = r
41
41
 
42
42
  export interface Options extends r.Static<typeof Options> {}
43
43
 
44
- export const standardTsconfig = makeRule<Options>({
44
+ export const standardTsconfig = createRuleFactory<Options>({
45
45
  name: "standardTsconfig",
46
46
  check: async (context, opts) => {
47
47
  const tsconfigFileName = opts.file ?? DEFAULT_TSCONFIG_FILENAME;
@@ -0,0 +1,33 @@
1
+ import { Context, RuleEntry, RuleModule } from "@monorepolint/config";
2
+
3
+ export type ValidateOptionsFn<X> = (options: unknown) => asserts options is X;
4
+ export type RuleFactoryFn<T> = (ruleEntry: RuleEntry<T>) => RuleModule<T>;
5
+ export type RuleCheckFn<O> = (context: Context, options: O, extra: { id: string }) => Promise<unknown> | unknown;
6
+
7
+ export interface RuleFactoryOptions<X> {
8
+ name: string;
9
+ check: RuleCheckFn<X>;
10
+ printStats?: () => void;
11
+ validateOptions: ValidateOptionsFn<X>;
12
+ }
13
+
14
+ let globalId = 0;
15
+ export function createRuleFactory<X>({
16
+ name,
17
+ check,
18
+ validateOptions,
19
+ printStats,
20
+ }: RuleFactoryOptions<X>): RuleFactoryFn<X> {
21
+ return function (ruleEntry) {
22
+ const id = ruleEntry.id ?? `${name} :: ${globalId++}`;
23
+ return {
24
+ id,
25
+ // eslint-disable-next-line @typescript-eslint/no-extra-non-null-assertion
26
+ check: (context) => check(context, ruleEntry.options!!, { id }),
27
+ name,
28
+ validateOptions,
29
+ ruleEntry,
30
+ printStats,
31
+ };
32
+ };
33
+ }
@@ -1 +0,0 @@
1
- export { makeRule } from "../util/makeRule.js";
@@ -1,29 +0,0 @@
1
- import { Context, RuleEntry, RuleModule } from "@monorepolint/config";
2
-
3
- let globalId = 0;
4
- export function makeRule<X>({
5
- name,
6
- check,
7
- validateOptions,
8
- printStats,
9
- }: {
10
- name: string;
11
- check: (context: Context, options: X, extra: { id: string }) => Promise<unknown> | unknown;
12
- printStats?: () => void;
13
- validateOptions: (options: unknown) => asserts options is X;
14
- }): RuleFunction<X> {
15
- return function (ruleEntry) {
16
- const id = `${name} :: ${globalId++}`;
17
- return {
18
- id,
19
- // eslint-disable-next-line @typescript-eslint/no-extra-non-null-assertion
20
- check: (context) => check(context, ruleEntry.options!!, { id }),
21
- name,
22
- validateOptions,
23
- ruleEntry,
24
- printStats,
25
- };
26
- };
27
- }
28
-
29
- type RuleFunction<T> = (ruleEntry: RuleEntry<T>) => RuleModule<T>;