@monorepolint/rules 0.5.0-alpha.103 → 0.5.0-alpha.106

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 (71) hide show
  1. package/.turbo/turbo-lint.log +34 -31
  2. package/.turbo/turbo-test.log +173 -166
  3. package/.turbo/turbo-transpile-typescript.log +4 -8
  4. package/build/js/index.js +75 -91
  5. package/build/js/index.js.map +1 -1
  6. package/build/tsconfig.tsbuildinfo +1 -1
  7. package/build/types/alphabeticalDependencies.d.ts +1 -15
  8. package/build/types/alphabeticalDependencies.d.ts.map +1 -1
  9. package/build/types/alphabeticalScripts.d.ts +1 -15
  10. package/build/types/alphabeticalScripts.d.ts.map +1 -1
  11. package/build/types/bannedDependencies.d.ts +36 -104
  12. package/build/types/bannedDependencies.d.ts.map +1 -1
  13. package/build/types/consistentDependencies.d.ts +3 -23
  14. package/build/types/consistentDependencies.d.ts.map +1 -1
  15. package/build/types/consistentVersions.d.ts +8 -34
  16. package/build/types/consistentVersions.d.ts.map +1 -1
  17. package/build/types/fileContents.d.ts +17 -89
  18. package/build/types/fileContents.d.ts.map +1 -1
  19. package/build/types/index.d.ts +13 -13
  20. package/build/types/index.d.ts.map +1 -1
  21. package/build/types/mustSatisfyPeerDependencies.d.ts +189 -483
  22. package/build/types/mustSatisfyPeerDependencies.d.ts.map +1 -1
  23. package/build/types/nestedWorkspaces.d.ts +1 -15
  24. package/build/types/nestedWorkspaces.d.ts.map +1 -1
  25. package/build/types/packageEntry.d.ts +30 -91
  26. package/build/types/packageEntry.d.ts.map +1 -1
  27. package/build/types/packageOrder.d.ts +3 -23
  28. package/build/types/packageOrder.d.ts.map +1 -1
  29. package/build/types/packageScript.d.ts +16 -68
  30. package/build/types/packageScript.d.ts.map +1 -1
  31. package/build/types/public/util.d.ts +2 -0
  32. package/build/types/public/util.d.ts.map +1 -0
  33. package/build/types/requireDependency.d.ts +22 -86
  34. package/build/types/requireDependency.d.ts.map +1 -1
  35. package/build/types/standardTsconfig.d.ts +9 -69
  36. package/build/types/standardTsconfig.d.ts.map +1 -1
  37. package/build/types/util/makeRule.d.ts +13 -0
  38. package/build/types/util/makeRule.d.ts.map +1 -0
  39. package/package.json +18 -12
  40. package/src/__tests__/alphabeticalScripts.spec.ts +2 -2
  41. package/src/__tests__/bannedDependencies.spec.ts +1 -3
  42. package/src/__tests__/consistentDependencies.spec.ts +2 -2
  43. package/src/__tests__/consistentVersions.spec.ts +1 -1
  44. package/src/__tests__/fileContents.spec.ts +16 -12
  45. package/src/__tests__/mustSatisfyPeerDependencies.spec.ts +1 -1
  46. package/src/__tests__/nestedWorkspaces.spec.ts +1 -1
  47. package/src/__tests__/packageEntry.spec.ts +40 -30
  48. package/src/__tests__/packageOrder.spec.ts +20 -12
  49. package/src/__tests__/packageScript.spec.ts +55 -39
  50. package/src/__tests__/requireDependency.spec.ts +2 -2
  51. package/src/alphabeticalDependencies.ts +5 -7
  52. package/src/alphabeticalScripts.ts +5 -7
  53. package/src/bannedDependencies.ts +6 -8
  54. package/src/consistentDependencies.ts +6 -7
  55. package/src/consistentVersions.ts +5 -6
  56. package/src/fileContents.ts +7 -8
  57. package/src/index.ts +13 -13
  58. package/src/mustSatisfyPeerDependencies.ts +5 -9
  59. package/src/nestedWorkspaces.ts +6 -7
  60. package/src/packageEntry.ts +6 -7
  61. package/src/packageOrder.ts +6 -7
  62. package/src/packageScript.ts +5 -7
  63. package/src/public/util.ts +1 -0
  64. package/src/requireDependency.ts +6 -6
  65. package/src/standardTsconfig.ts +7 -9
  66. package/src/util/makeRule.ts +29 -0
  67. package/build/js/index.cjs +0 -1491
  68. package/build/js/index.cjs.map +0 -1
  69. package/build/types/util/createNewRuleConversion.d.ts +0 -30
  70. package/build/types/util/createNewRuleConversion.d.ts.map +0 -1
  71. package/src/util/createNewRuleConversion.ts +0 -38
@@ -49,7 +49,7 @@ describe.each(HOST_FACTORIES)("alphabeticalScripts ($name)", (hostFactory) => {
49
49
  it("fixes unsorted scripts", () => {
50
50
  workspace.writeFile("package.json", PACKAGE_SCRIPTS_UNSORTED);
51
51
 
52
- alphabeticalScripts.check(context, undefined);
52
+ alphabeticalScripts({}).check(context);
53
53
 
54
54
  expect(spy).toHaveBeenCalledTimes(1);
55
55
 
@@ -68,7 +68,7 @@ describe.each(HOST_FACTORIES)("alphabeticalScripts ($name)", (hostFactory) => {
68
68
  it("does nothing if already sorted", () => {
69
69
  workspace.writeFile("package.json", PACKAGE_SCRIPTS_SORTED);
70
70
 
71
- alphabeticalScripts.check(context, undefined);
71
+ alphabeticalScripts({}).check(context);
72
72
 
73
73
  expect(spy).toHaveBeenCalledTimes(0);
74
74
  });
@@ -51,9 +51,7 @@ describe("bannedDependencies", () => {
51
51
 
52
52
  function checkAndSpy(options: Options) {
53
53
  const addErrorSpy = jest.spyOn(workspaceContext, "addError");
54
- bannedDependencies.check(workspaceContext, {
55
- ...options,
56
- });
54
+ bannedDependencies({ options }).check(workspaceContext);
57
55
  return { addErrorSpy };
58
56
  }
59
57
 
@@ -77,7 +77,7 @@ describe("consistentDependencies", () => {
77
77
  function checkAndSpy(q: string, opts?: Options) {
78
78
  const context = workspaceContext.createChildContext(path.resolve(dir.name, q));
79
79
  const addErrorSpy = jest.spyOn(context, "addError");
80
- consistentDependencies.check(context, opts);
80
+ consistentDependencies({ options: opts }).check(context);
81
81
  return { context, addErrorSpy };
82
82
  }
83
83
 
@@ -104,7 +104,7 @@ describe("consistentDependencies", () => {
104
104
  addFile("./packages/right/package.json", PACKAGE_CHILD_WITH_RIGHT_VERSION);
105
105
  addFile("./packages/wrong/package.json", PACKAGE_CHILD_WITH_WRONG_VERSION);
106
106
 
107
- consistentDependencies.check(workspaceContext, undefined);
107
+ consistentDependencies({}).check(workspaceContext);
108
108
 
109
109
  const star = checkAndSpy("./packages/star");
110
110
  expect(star.addErrorSpy).toHaveBeenCalledTimes(0);
@@ -50,7 +50,7 @@ describe("consistentVersions", () => {
50
50
  const addErrorSpy = jest.spyOn(workspaceContext, "addError");
51
51
 
52
52
  function check(options: Options = { matchDependencyVersions: {} }) {
53
- consistentVersions.check(workspaceContext, options);
53
+ consistentVersions({ options }).check(workspaceContext);
54
54
  }
55
55
 
56
56
  return { addErrorSpy, check, host };
@@ -29,12 +29,14 @@ describe.each(HOST_FACTORIES)("fileContents ($name)", (hostFactory) => {
29
29
  });
30
30
 
31
31
  it("fixes missing file", () => {
32
- fileContents.check(workspace.context, {
33
- file: "foo.txt",
34
- templateFile: "shared/foo-template.txt",
35
- generator: undefined,
36
- template: undefined,
37
- });
32
+ fileContents({
33
+ options: {
34
+ file: "foo.txt",
35
+ templateFile: "shared/foo-template.txt",
36
+ generator: undefined,
37
+ template: undefined,
38
+ },
39
+ }).check(workspace.context);
38
40
 
39
41
  expect(spy).toHaveBeenCalledTimes(1);
40
42
 
@@ -51,12 +53,14 @@ describe.each(HOST_FACTORIES)("fileContents ($name)", (hostFactory) => {
51
53
  });
52
54
 
53
55
  it("fixes missing nested file", () => {
54
- fileContents.check(workspace.context, {
55
- file: "nested/foo.txt",
56
- templateFile: "shared/foo-template.txt",
57
- generator: undefined,
58
- template: undefined,
59
- });
56
+ fileContents({
57
+ options: {
58
+ file: "nested/foo.txt",
59
+ templateFile: "shared/foo-template.txt",
60
+ generator: undefined,
61
+ template: undefined,
62
+ },
63
+ }).check(workspace.context);
60
64
 
61
65
  expect(spy).toHaveBeenCalledTimes(1);
62
66
 
@@ -80,7 +80,7 @@ describe("mustSatisfyPeerDependencies", () => {
80
80
  const addErrorSpy = jest.spyOn(workspaceContext, "addError");
81
81
 
82
82
  async function check(options: Options) {
83
- await mustSatisfyPeerDependencies.check(workspaceContext, options);
83
+ await mustSatisfyPeerDependencies({ options }).check(workspaceContext);
84
84
  }
85
85
 
86
86
  return { addErrorSpy, check, host };
@@ -72,7 +72,7 @@ describe("nestedWorkspaces", () => {
72
72
  async function checkAndSpy() {
73
73
  const addErrorSpy = jest.spyOn(workspaceContext, "addError");
74
74
 
75
- await nestedWorkspaces.check(workspaceContext, undefined);
75
+ await nestedWorkspaces({}).check(workspaceContext);
76
76
  return { addErrorSpy };
77
77
  }
78
78
 
@@ -76,12 +76,14 @@ describe.each(HOST_FACTORIES)("expectPackageEntries ($name)", (hostFactory) => {
76
76
  it("fixes missing entries", () => {
77
77
  workspace.writeFile("package.json", PACKAGE_MISSING_ENTRY);
78
78
 
79
- packageEntry.check(context, {
80
- entries: {
81
- license: "UNLICENSED",
79
+ packageEntry({
80
+ options: {
81
+ entries: {
82
+ license: "UNLICENSED",
83
+ },
84
+ entriesExist: undefined,
82
85
  },
83
- entriesExist: undefined,
84
- });
86
+ }).check(context);
85
87
 
86
88
  expect(spy).toHaveBeenCalledTimes(1);
87
89
 
@@ -100,15 +102,17 @@ describe.each(HOST_FACTORIES)("expectPackageEntries ($name)", (hostFactory) => {
100
102
  it("fixes missing nested entries", () => {
101
103
  workspace.writeFile("package.json", PACKAGE_MISSING_ENTRY);
102
104
 
103
- packageEntry.check(context, {
104
- entries: {
105
- repository: {
106
- type: "git",
107
- url: "https://github.com:foo/foo",
105
+ packageEntry({
106
+ options: {
107
+ entries: {
108
+ repository: {
109
+ type: "git",
110
+ url: "https://github.com:foo/foo",
111
+ },
108
112
  },
113
+ entriesExist: undefined,
109
114
  },
110
- entriesExist: undefined,
111
- });
115
+ }).check(context);
112
116
 
113
117
  expect(spy).toHaveBeenCalledTimes(1);
114
118
 
@@ -127,15 +131,17 @@ describe.each(HOST_FACTORIES)("expectPackageEntries ($name)", (hostFactory) => {
127
131
  it("doesn't error for nested entries that are defined", () => {
128
132
  workspace.writeFile("package.json", PACKAGE_REPOSITORY);
129
133
 
130
- packageEntry.check(context, {
131
- entries: {
132
- repository: {
133
- type: "git",
134
- url: "https://github.com:foo/foo",
134
+ packageEntry({
135
+ options: {
136
+ entries: {
137
+ repository: {
138
+ type: "git",
139
+ url: "https://github.com:foo/foo",
140
+ },
135
141
  },
142
+ entriesExist: undefined,
136
143
  },
137
- entriesExist: undefined,
138
- });
144
+ }).check(context);
139
145
 
140
146
  expect(spy).toHaveBeenCalledTimes(0);
141
147
  expect(workspace.readFile("package.json")).toEqual(PACKAGE_REPOSITORY);
@@ -144,10 +150,12 @@ describe.each(HOST_FACTORIES)("expectPackageEntries ($name)", (hostFactory) => {
144
150
  it("errors for keys that are missing", () => {
145
151
  workspace.writeFile("package.json", PACKAGE_REPOSITORY);
146
152
 
147
- packageEntry.check(context, {
148
- entries: undefined,
149
- entriesExist: ["bugs"],
150
- });
153
+ packageEntry({
154
+ options: {
155
+ entries: undefined,
156
+ entriesExist: ["bugs"],
157
+ },
158
+ }).check(context);
151
159
 
152
160
  expect(spy).toHaveBeenCalledTimes(1);
153
161
 
@@ -165,15 +173,17 @@ describe.each(HOST_FACTORIES)("expectPackageEntries ($name)", (hostFactory) => {
165
173
  it("handles both entries and entriesExist", () => {
166
174
  workspace.writeFile("package.json", PACKAGE_MISSING_ENTRY);
167
175
 
168
- packageEntry.check(context, {
169
- entries: {
170
- repository: {
171
- type: "git",
172
- url: "https://github.com:foo/foo",
176
+ packageEntry({
177
+ options: {
178
+ entries: {
179
+ repository: {
180
+ type: "git",
181
+ url: "https://github.com:foo/foo",
182
+ },
173
183
  },
184
+ entriesExist: ["bugs"],
174
185
  },
175
- entriesExist: ["bugs"],
176
- });
186
+ }).check(context);
177
187
 
178
188
  expect(spy).toHaveBeenCalledTimes(2);
179
189
 
@@ -101,9 +101,11 @@ describe.each(HOST_FACTORIES)("expectPackageOrder ($name)", (hostFactory) => {
101
101
  it("fixes order for expected keys", () => {
102
102
  workspace.writeFile("package.json", PACKAGE_UNORDERED);
103
103
 
104
- packageOrder.check(context, {
105
- order: orderArray,
106
- });
104
+ packageOrder({
105
+ options: {
106
+ order: orderArray,
107
+ },
108
+ }).check(context);
107
109
 
108
110
  expect(spy).toHaveBeenCalledTimes(1);
109
111
 
@@ -122,9 +124,11 @@ describe.each(HOST_FACTORIES)("expectPackageOrder ($name)", (hostFactory) => {
122
124
  it("fixes order for unexpected keys", () => {
123
125
  workspace.writeFile("package.json", PACKAGE_UNORDERED_UNKOWN_KEYS);
124
126
 
125
- packageOrder.check(context, {
126
- order: orderArray,
127
- });
127
+ packageOrder({
128
+ options: {
129
+ order: orderArray,
130
+ },
131
+ }).check(context);
128
132
 
129
133
  expect(spy).toHaveBeenCalledTimes(1);
130
134
 
@@ -143,9 +147,11 @@ describe.each(HOST_FACTORIES)("expectPackageOrder ($name)", (hostFactory) => {
143
147
  it("fixes order using function", () => {
144
148
  workspace.writeFile("package.json", PACKAGE_UNORDERED);
145
149
 
146
- packageOrder.check(context, {
147
- order: orderFunction,
148
- });
150
+ packageOrder({
151
+ options: {
152
+ order: orderFunction,
153
+ },
154
+ }).check(context);
149
155
 
150
156
  expect(spy).toHaveBeenCalledTimes(1);
151
157
 
@@ -164,9 +170,11 @@ describe.each(HOST_FACTORIES)("expectPackageOrder ($name)", (hostFactory) => {
164
170
  it("does nothing if already order", () => {
165
171
  workspace.writeFile("package.json", PACKAGE_ORDERED_UNKOWN_KEYS);
166
172
 
167
- packageOrder.check(context, {
168
- order: orderArray,
169
- });
173
+ packageOrder({
174
+ options: {
175
+ order: orderArray,
176
+ },
177
+ }).check(context);
170
178
 
171
179
  expect(spy).not.toHaveBeenCalled();
172
180
 
@@ -47,11 +47,13 @@ describe.each(HOST_FACTORIES)("expectPackageScript ($name)", (hostFactory) => {
47
47
  it("handles an empty script section", () => {
48
48
  workspace.writeFile("package.json", PACKAGE_WITHOUT_SCRIPTS);
49
49
 
50
- packageScript.check(workspace.context, {
51
- scripts: {
52
- foo: "bar",
50
+ packageScript({
51
+ options: {
52
+ scripts: {
53
+ foo: "bar",
54
+ },
53
55
  },
54
- });
56
+ }).check(workspace.context);
55
57
 
56
58
  expect(spy).toHaveBeenCalledTimes(1);
57
59
 
@@ -84,11 +86,13 @@ describe.each(HOST_FACTORIES)("expectPackageScript ($name)", (hostFactory) => {
84
86
  it("fixes an empty script section", () => {
85
87
  workspace.writeFile("package.json", PACKAGE_WITHOUT_SCRIPTS);
86
88
 
87
- packageScript.check(context, {
88
- scripts: {
89
- foo: "bar",
89
+ packageScript({
90
+ options: {
91
+ scripts: {
92
+ foo: "bar",
93
+ },
90
94
  },
91
- });
95
+ }).check(context);
92
96
 
93
97
  expect(spy).toHaveBeenCalledTimes(1);
94
98
 
@@ -107,11 +111,13 @@ describe.each(HOST_FACTORIES)("expectPackageScript ($name)", (hostFactory) => {
107
111
  it("adds a script", () => {
108
112
  workspace.writeFile("package.json", PACKAGE_WITH_SCRIPTS);
109
113
 
110
- packageScript.check(context, {
111
- scripts: {
112
- [MISSING_SCRIPT_NAME]: MISSING_SCRIPT_VALUE,
114
+ packageScript({
115
+ options: {
116
+ scripts: {
117
+ [MISSING_SCRIPT_NAME]: MISSING_SCRIPT_VALUE,
118
+ },
113
119
  },
114
- });
120
+ }).check(context);
115
121
 
116
122
  expect(spy).toHaveBeenCalledTimes(1);
117
123
 
@@ -134,11 +140,13 @@ describe.each(HOST_FACTORIES)("expectPackageScript ($name)", (hostFactory) => {
134
140
  it("does nothing if the value exists", () => {
135
141
  workspace.writeFile("package.json", PACKAGE_WITH_SCRIPTS);
136
142
 
137
- packageScript.check(context, {
138
- scripts: {
139
- [SCRIPT_NAME]: SCRIPT_VALUE,
143
+ packageScript({
144
+ options: {
145
+ scripts: {
146
+ [SCRIPT_NAME]: SCRIPT_VALUE,
147
+ },
140
148
  },
141
- });
149
+ }).check(context);
142
150
 
143
151
  expect(spy).not.toHaveBeenCalled();
144
152
 
@@ -150,13 +158,15 @@ describe.each(HOST_FACTORIES)("expectPackageScript ($name)", (hostFactory) => {
150
158
  it("errors if long form is used and no value matches and there is no fixValue", () => {
151
159
  workspace.writeFile("package.json", PACKAGE_WITH_SCRIPTS);
152
160
 
153
- packageScript.check(context, {
154
- scripts: {
155
- foo: {
156
- options: ["a", "b"],
161
+ packageScript({
162
+ options: {
163
+ scripts: {
164
+ foo: {
165
+ options: ["a", "b"],
166
+ },
157
167
  },
158
168
  },
159
- });
169
+ }).check(context);
160
170
 
161
171
  const errors = spy.mock.calls;
162
172
 
@@ -167,14 +177,16 @@ describe.each(HOST_FACTORIES)("expectPackageScript ($name)", (hostFactory) => {
167
177
  it("uses the fixValue for fixing if provided", () => {
168
178
  workspace.writeFile("package.json", PACKAGE_WITH_SCRIPTS);
169
179
 
170
- packageScript.check(context, {
171
- scripts: {
172
- foo: {
173
- options: ["a", "b"],
174
- fixValue: "a",
180
+ packageScript({
181
+ options: {
182
+ scripts: {
183
+ foo: {
184
+ options: ["a", "b"],
185
+ fixValue: "a",
186
+ },
175
187
  },
176
188
  },
177
- });
189
+ }).check(context);
178
190
 
179
191
  const errors = spy.mock.calls;
180
192
 
@@ -190,14 +202,16 @@ describe.each(HOST_FACTORIES)("expectPackageScript ($name)", (hostFactory) => {
190
202
  it("can fix to empty", () => {
191
203
  workspace.writeFile("package.json", PACKAGE_WITH_SCRIPTS);
192
204
 
193
- packageScript.check(context, {
194
- scripts: {
195
- [SCRIPT_NAME]: {
196
- options: ["a", undefined],
197
- fixValue: undefined,
205
+ packageScript({
206
+ options: {
207
+ scripts: {
208
+ [SCRIPT_NAME]: {
209
+ options: ["a", undefined],
210
+ fixValue: undefined,
211
+ },
198
212
  },
199
213
  },
200
- });
214
+ }).check(context);
201
215
 
202
216
  const errors = spy.mock.calls;
203
217
 
@@ -210,14 +224,16 @@ describe.each(HOST_FACTORIES)("expectPackageScript ($name)", (hostFactory) => {
210
224
  it("can allow only empty", () => {
211
225
  workspace.writeFile("package.json", PACKAGE_WITH_SCRIPTS);
212
226
 
213
- packageScript.check(context, {
214
- scripts: {
215
- [SCRIPT_NAME]: {
216
- options: [undefined],
217
- fixValue: undefined,
227
+ packageScript({
228
+ options: {
229
+ scripts: {
230
+ [SCRIPT_NAME]: {
231
+ options: [undefined],
232
+ fixValue: undefined,
233
+ },
218
234
  },
219
235
  },
220
- });
236
+ }).check(context);
221
237
 
222
238
  const errors = spy.mock.calls;
223
239
 
@@ -89,7 +89,7 @@ describe("requireDependency", () => {
89
89
  function checkAndSpy(q: string) {
90
90
  const context = workspaceContext.createChildContext(path.resolve(dir.name, q));
91
91
  const addErrorSpy = jest.spyOn(context, "addError");
92
- requireDependency.check(context, OPTIONS);
92
+ requireDependency({ options: OPTIONS }).check(context);
93
93
  return { context, addErrorSpy };
94
94
  }
95
95
 
@@ -116,7 +116,7 @@ describe("requireDependency", () => {
116
116
  addFile("./packages/wrong/package.json", PACKAGE_WITH_WRONG_ENTRIES);
117
117
  addFile("./packages/right/package.json", PACKAGE_WITH_RIGHT_ENTRIES);
118
118
 
119
- requireDependency.check(workspaceContext, OPTIONS);
119
+ requireDependency({ options: OPTIONS }).check(workspaceContext);
120
120
 
121
121
  const none = checkAndSpy("./packages/none");
122
122
  expect(none.addErrorSpy).toHaveBeenCalledTimes(2);
@@ -5,19 +5,17 @@
5
5
  *
6
6
  */
7
7
 
8
- import { Context, RuleModule } from "@monorepolint/config";
9
8
  import * as r from "runtypes";
10
9
  import { checkAlpha } from "./util/checkAlpha.js";
11
- import { createNewRuleConversion } from "./util/createNewRuleConversion.js";
10
+ import { makeRule } from "./util/makeRule.js";
12
11
  const Options = r.Undefined;
13
12
 
14
- export const alphabeticalDependencies: RuleModule<typeof Options> = {
15
- check: function expectAlphabeticalDependencies(context: Context) {
13
+ export const alphabeticalDependencies = makeRule({
14
+ name: "alphabeticalDependencies",
15
+ check: (context) => {
16
16
  checkAlpha(context, "dependencies");
17
17
  checkAlpha(context, "devDependencies");
18
18
  checkAlpha(context, "peerDependencies");
19
19
  },
20
20
  optionsRuntype: Options,
21
- };
22
-
23
- export const AlphabeticalDependencies = createNewRuleConversion("AlphabetialDependencies", alphabeticalDependencies);
21
+ });
@@ -5,17 +5,15 @@
5
5
  *
6
6
  */
7
7
 
8
- import { Context, RuleModule } from "@monorepolint/config";
9
8
  import * as r from "runtypes";
10
9
  import { checkAlpha } from "./util/checkAlpha.js";
11
- import { createNewRuleConversion } from "./util/createNewRuleConversion.js";
10
+ import { makeRule } from "./util/makeRule.js";
12
11
  const Options = r.Undefined;
13
12
 
14
- export const alphabeticalScripts: RuleModule<typeof Options> = {
15
- check: function expectAlphabeticalScripts(context: Context) {
13
+ export const alphabeticalScripts = makeRule({
14
+ name: "alphabeticalScripts",
15
+ check: (context) => {
16
16
  checkAlpha(context, "scripts");
17
17
  },
18
18
  optionsRuntype: Options,
19
- };
20
-
21
- export const AlphabeticalScripts = createNewRuleConversion("AlphabeticalScripts", alphabeticalScripts);
19
+ });
@@ -5,12 +5,12 @@
5
5
  *
6
6
  */
7
7
 
8
- import { Context, RuleModule } from "@monorepolint/config";
8
+ import { Context } from "@monorepolint/config";
9
9
  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 { createNewRuleConversion } from "./util/createNewRuleConversion.js";
13
+ import { makeRule } from "./util/makeRule.js";
14
14
  import { IPackageDependencyGraphNode, PackageDependencyGraphService } from "./util/packageDependencyGraphService.js";
15
15
  // FIXME: This rule is messed. bannedTransitiveDependencies doesnt glob
16
16
 
@@ -49,10 +49,9 @@ const setCache = new Map<ReadonlyArray<string>, Set<string>>();
49
49
 
50
50
  const aggregateTiming = new AggregateTiming(":bannedDependencies stats");
51
51
 
52
- export const bannedDependencies: RuleModule<typeof Options> & {
53
- printStats: () => void;
54
- } = {
55
- check: function expectAllowedDependencies(context, opts, extra) {
52
+ export const bannedDependencies = makeRule({
53
+ name: "bannedDependencies",
54
+ check: (context, opts, extra) => {
56
55
  aggregateTiming.start(extra?.id ?? "unknown id");
57
56
 
58
57
  const packageJson = context.getPackageJson();
@@ -112,8 +111,7 @@ export const bannedDependencies: RuleModule<typeof Options> & {
112
111
  printStats: () => {
113
112
  aggregateTiming.printResults();
114
113
  },
115
- };
116
- export const BannedDependencies = createNewRuleConversion("BannedDependencies", bannedDependencies);
114
+ });
117
115
 
118
116
  function populateProblemsExact(banned: Set<string>, dependencies: ReadonlyArray<string>, violations: Set<string>) {
119
117
  for (const dependency of dependencies) {
@@ -5,10 +5,10 @@
5
5
  *
6
6
  */
7
7
 
8
- import { Context, RuleModule } from "@monorepolint/config";
8
+ import { Context } from "@monorepolint/config";
9
9
  import { diff } from "jest-diff";
10
10
  import * as r from "runtypes";
11
- import { createNewRuleConversion } from "./util/createNewRuleConversion.js";
11
+ import { makeRule } from "./util/makeRule.js";
12
12
  const Options = r
13
13
  .Record({
14
14
  ignoredDependencies: r.Array(r.String).Or(r.Undefined),
@@ -18,16 +18,15 @@ export type Options = r.Static<typeof Options>;
18
18
 
19
19
  const skippedVersions = ["*", "latest"];
20
20
 
21
- export const consistentDependencies = {
22
- check: function expectConsistentDependencies(context: Context, args: Options) {
21
+ export const consistentDependencies = makeRule({
22
+ name: "consistentDependencies",
23
+ check: (context, args) => {
23
24
  checkDeps(context, args, "dependencies");
24
25
  checkDeps(context, args, "devDependencies");
25
26
  // we don't check peer deps since they can be more lenient
26
27
  },
27
28
  optionsRuntype: Options,
28
- } as RuleModule<typeof Options>;
29
-
30
- export const ConsistentDependencies = createNewRuleConversion("ConsistentDependencies", consistentDependencies);
29
+ });
31
30
 
32
31
  function checkDeps(context: Context, args: Options, block: "dependencies" | "devDependencies" | "peerDependencies") {
33
32
  const packageJson = context.getPackageJson();
@@ -5,21 +5,22 @@
5
5
  *
6
6
  */
7
7
 
8
- import { Context, RuleModule } from "@monorepolint/config";
8
+ 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 { createNewRuleConversion } from "./util/createNewRuleConversion.js";
12
+ import { makeRule } from "./util/makeRule.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: RuleModule<typeof Options> = {
19
+ export const consistentVersions = makeRule({
20
+ name: "consistentVersions",
20
21
  check: checkConsistentVersions,
21
22
  optionsRuntype: Options,
22
- };
23
+ });
23
24
 
24
25
  function checkConsistentVersions(context: Context, options: Options) {
25
26
  for (const [dependencyPackageName, expectedPackageDependencyValue] of Object.entries(
@@ -138,5 +139,3 @@ const ensurePackageMatchesSomeVersion = (
138
139
  });
139
140
  }
140
141
  };
141
-
142
- export const ConsistentVersions = createNewRuleConversion("ConsistentVersions", consistentVersions);