@code-pushup/eslint-plugin 0.8.0 → 0.8.1

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/bin.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { mkdir as mkdir2, writeFile } from "fs/promises";
3
3
  import { dirname, join as join2 } from "path";
4
4
 
5
- // packages/models/src/lib/category-config.ts
5
+ // packages/models/src/lib/audit.ts
6
6
  import { z as z2 } from "zod";
7
7
 
8
8
  // packages/models/src/lib/implementation/schemas.ts
@@ -142,13 +142,107 @@ function hasWeightedRefsInCategories(categoryRefs) {
142
142
  return categoryRefs.reduce((acc, { weight }) => weight + acc, 0) !== 0;
143
143
  }
144
144
 
145
+ // packages/models/src/lib/audit.ts
146
+ var auditSchema = z2.object({
147
+ slug: slugSchema("ID (unique within plugin)")
148
+ }).merge(
149
+ metaSchema({
150
+ titleDescription: "Descriptive name",
151
+ descriptionDescription: "Description (markdown)",
152
+ docsUrlDescription: "Link to documentation (rationale)",
153
+ description: "List of scorable metrics for the given plugin"
154
+ })
155
+ );
156
+ var pluginAuditsSchema = z2.array(auditSchema, {
157
+ description: "List of audits maintained in a plugin"
158
+ }).refine(
159
+ (auditMetadata) => !getDuplicateSlugsInAudits(auditMetadata),
160
+ (auditMetadata) => ({
161
+ message: duplicateSlugsInAuditsErrorMsg(auditMetadata)
162
+ })
163
+ );
164
+ function duplicateSlugsInAuditsErrorMsg(audits) {
165
+ const duplicateRefs = getDuplicateSlugsInAudits(audits);
166
+ return `In plugin audits the slugs are not unique: ${errorItems(
167
+ duplicateRefs
168
+ )}`;
169
+ }
170
+ function getDuplicateSlugsInAudits(audits) {
171
+ return hasDuplicateStrings(audits.map(({ slug }) => slug));
172
+ }
173
+
174
+ // packages/models/src/lib/audit-issue.ts
175
+ import { z as z3 } from "zod";
176
+ var sourceFileLocationSchema = z3.object(
177
+ {
178
+ file: filePathSchema("Relative path to source file in Git repo"),
179
+ position: z3.object(
180
+ {
181
+ startLine: positiveIntSchema("Start line"),
182
+ startColumn: positiveIntSchema("Start column").optional(),
183
+ endLine: positiveIntSchema("End line").optional(),
184
+ endColumn: positiveIntSchema("End column").optional()
185
+ },
186
+ { description: "Location in file" }
187
+ ).optional()
188
+ },
189
+ { description: "Source file location" }
190
+ );
191
+ var issueSeveritySchema = z3.enum(["info", "warning", "error"], {
192
+ description: "Severity level"
193
+ });
194
+ var issueSchema = z3.object(
195
+ {
196
+ message: z3.string({ description: "Descriptive error message" }).max(512),
197
+ severity: issueSeveritySchema,
198
+ source: sourceFileLocationSchema.optional()
199
+ },
200
+ { description: "Issue information" }
201
+ );
202
+
203
+ // packages/models/src/lib/audit-output.ts
204
+ import { z as z4 } from "zod";
205
+ var auditOutputSchema = z4.object(
206
+ {
207
+ slug: slugSchema("Reference to audit"),
208
+ displayValue: z4.string({ description: "Formatted value (e.g. '0.9 s', '2.1 MB')" }).optional(),
209
+ value: positiveIntSchema("Raw numeric value"),
210
+ score: z4.number({
211
+ description: "Value between 0 and 1"
212
+ }).min(0).max(1),
213
+ details: z4.object(
214
+ {
215
+ issues: z4.array(issueSchema, { description: "List of findings" })
216
+ },
217
+ { description: "Detailed information" }
218
+ ).optional()
219
+ },
220
+ { description: "Audit information" }
221
+ );
222
+ var auditOutputsSchema = z4.array(auditOutputSchema, {
223
+ description: "List of JSON formatted audit output emitted by the runner process of a plugin"
224
+ }).refine(
225
+ (audits) => !getDuplicateSlugsInAudits2(audits),
226
+ (audits) => ({ message: duplicateSlugsInAuditsErrorMsg2(audits) })
227
+ );
228
+ function duplicateSlugsInAuditsErrorMsg2(audits) {
229
+ const duplicateRefs = getDuplicateSlugsInAudits2(audits);
230
+ return `In plugin audits the slugs are not unique: ${errorItems(
231
+ duplicateRefs
232
+ )}`;
233
+ }
234
+ function getDuplicateSlugsInAudits2(audits) {
235
+ return hasDuplicateStrings(audits.map(({ slug }) => slug));
236
+ }
237
+
145
238
  // packages/models/src/lib/category-config.ts
239
+ import { z as z5 } from "zod";
146
240
  var categoryRefSchema = weightedRefSchema(
147
241
  "Weighted references to audits and/or groups for the category",
148
242
  "Slug of an audit or group (depending on `type`)"
149
243
  ).merge(
150
- z2.object({
151
- type: z2.enum(["audit", "group"], {
244
+ z5.object({
245
+ type: z5.enum(["audit", "group"], {
152
246
  description: "Discriminant for reference kind, affects where `slug` is looked up"
153
247
  }),
154
248
  plugin: slugSchema(
@@ -169,8 +263,8 @@ var categoryConfigSchema = scorableSchema(
169
263
  description: "Meta info for category"
170
264
  })
171
265
  ).merge(
172
- z2.object({
173
- isBinary: z2.boolean({
266
+ z5.object({
267
+ isBinary: z5.boolean({
174
268
  description: 'Is this a binary category (i.e. only a perfect score considered a "pass")?'
175
269
  }).optional()
176
270
  })
@@ -186,7 +280,7 @@ function getDuplicateRefsInCategoryMetrics(metrics) {
186
280
  metrics.map(({ slug, type, plugin }) => `${type} :: ${plugin} / ${slug}`)
187
281
  );
188
282
  }
189
- var categoriesSchema = z2.array(categoryConfigSchema, {
283
+ var categoriesSchema = z5.array(categoryConfigSchema, {
190
284
  description: "Categorization of individual audits"
191
285
  }).min(1).refine(
192
286
  (categoryCfg) => !getDuplicateSlugCategories(categoryCfg),
@@ -208,68 +302,38 @@ function getDuplicateSlugCategories(categories) {
208
302
  import { z as z11 } from "zod";
209
303
 
210
304
  // packages/models/src/lib/persist-config.ts
211
- import { z as z3 } from "zod";
212
- var formatSchema = z3.enum(["json", "md"]);
213
- var persistConfigSchema = z3.object({
305
+ import { z as z6 } from "zod";
306
+ var formatSchema = z6.enum(["json", "md"]);
307
+ var persistConfigSchema = z6.object({
214
308
  outputDir: filePathSchema("Artifacts folder").optional(),
215
309
  filename: fileNameSchema(
216
310
  "Artifacts file name (without extension)"
217
311
  ).optional(),
218
- format: z3.array(formatSchema).optional()
312
+ format: z6.array(formatSchema).optional()
219
313
  });
220
314
 
221
315
  // packages/models/src/lib/plugin-config.ts
222
316
  import { z as z9 } from "zod";
223
317
 
224
- // packages/models/src/lib/plugin-config-audits.ts
225
- import { z as z4 } from "zod";
226
- var auditSchema = z4.object({
227
- slug: slugSchema("ID (unique within plugin)")
228
- }).merge(
229
- metaSchema({
230
- titleDescription: "Descriptive name",
231
- descriptionDescription: "Description (markdown)",
232
- docsUrlDescription: "Link to documentation (rationale)",
233
- description: "List of scorable metrics for the given plugin"
234
- })
235
- );
236
- var pluginAuditsSchema = z4.array(auditSchema, {
237
- description: "List of audits maintained in a plugin"
238
- }).refine(
239
- (auditMetadata) => !getDuplicateSlugsInAudits(auditMetadata),
240
- (auditMetadata) => ({
241
- message: duplicateSlugsInAuditsErrorMsg(auditMetadata)
242
- })
243
- );
244
- function duplicateSlugsInAuditsErrorMsg(audits) {
245
- const duplicateRefs = getDuplicateSlugsInAudits(audits);
246
- return `In plugin audits the slugs are not unique: ${errorItems(
247
- duplicateRefs
248
- )}`;
249
- }
250
- function getDuplicateSlugsInAudits(audits) {
251
- return hasDuplicateStrings(audits.map(({ slug }) => slug));
252
- }
253
-
254
- // packages/models/src/lib/plugin-config-groups.ts
255
- import { z as z5 } from "zod";
256
- var auditGroupRefSchema = weightedRefSchema(
257
- "Weighted references to audits",
258
- "Reference slug to an audit within this plugin (e.g. 'max-lines')"
318
+ // packages/models/src/lib/group.ts
319
+ import { z as z7 } from "zod";
320
+ var groupRefSchema = weightedRefSchema(
321
+ "Weighted reference to a group",
322
+ "Reference slug to a group within this plugin (e.g. 'max-lines')"
259
323
  );
260
- var auditGroupMetaSchema = metaSchema({
324
+ var groupMetaSchema = metaSchema({
261
325
  titleDescription: "Descriptive name for the group",
262
326
  descriptionDescription: "Description of the group (markdown)",
263
327
  docsUrlDescription: "Group documentation site",
264
328
  description: "Group metadata"
265
329
  });
266
- var auditGroupSchema = scorableSchema(
267
- 'An audit group aggregates a set of audits into a single score which can be referenced from a category. E.g. the group slug "performance" groups audits and can be referenced in a category',
268
- auditGroupRefSchema,
330
+ var groupSchema = scorableSchema(
331
+ 'A group aggregates a set of audits into a single score which can be referenced from a category. E.g. the group slug "performance" groups audits and can be referenced in a category',
332
+ groupRefSchema,
269
333
  getDuplicateRefsInGroups,
270
334
  duplicateRefsInGroupsErrorMsg
271
- ).merge(auditGroupMetaSchema);
272
- var auditGroupsSchema = z5.array(auditGroupSchema, {
335
+ ).merge(groupMetaSchema);
336
+ var groupsSchema = z7.array(groupSchema, {
273
337
  description: "List of groups"
274
338
  }).optional().refine(
275
339
  (groups) => !getDuplicateSlugsInGroups(groups),
@@ -277,16 +341,14 @@ var auditGroupsSchema = z5.array(auditGroupSchema, {
277
341
  message: duplicateSlugsInGroupsErrorMsg(groups)
278
342
  })
279
343
  );
280
- function duplicateRefsInGroupsErrorMsg(groupAudits) {
281
- const duplicateRefs = getDuplicateRefsInGroups(groupAudits);
282
- return `In plugin groups the audit refs are not unique: ${errorItems(
344
+ function duplicateRefsInGroupsErrorMsg(groups) {
345
+ const duplicateRefs = getDuplicateRefsInGroups(groups);
346
+ return `In plugin groups the following references are not unique: ${errorItems(
283
347
  duplicateRefs
284
348
  )}`;
285
349
  }
286
- function getDuplicateRefsInGroups(groupAudits) {
287
- return hasDuplicateStrings(
288
- groupAudits.map(({ slug: ref }) => ref).filter(exists)
289
- );
350
+ function getDuplicateRefsInGroups(groups) {
351
+ return hasDuplicateStrings(groups.map(({ slug: ref }) => ref).filter(exists));
290
352
  }
291
353
  function duplicateSlugsInGroupsErrorMsg(groups) {
292
354
  const duplicateRefs = getDuplicateSlugsInGroups(groups);
@@ -296,76 +358,8 @@ function getDuplicateSlugsInGroups(groups) {
296
358
  return Array.isArray(groups) ? hasDuplicateStrings(groups.map(({ slug }) => slug)) : false;
297
359
  }
298
360
 
299
- // packages/models/src/lib/plugin-config-runner.ts
361
+ // packages/models/src/lib/runner-config.ts
300
362
  import { z as z8 } from "zod";
301
-
302
- // packages/models/src/lib/plugin-process-output.ts
303
- import { z as z7 } from "zod";
304
-
305
- // packages/models/src/lib/plugin-process-output-audit-issue.ts
306
- import { z as z6 } from "zod";
307
- var sourceFileLocationSchema = z6.object(
308
- {
309
- file: filePathSchema("Relative path to source file in Git repo"),
310
- position: z6.object(
311
- {
312
- startLine: positiveIntSchema("Start line"),
313
- startColumn: positiveIntSchema("Start column").optional(),
314
- endLine: positiveIntSchema("End line").optional(),
315
- endColumn: positiveIntSchema("End column").optional()
316
- },
317
- { description: "Location in file" }
318
- ).optional()
319
- },
320
- { description: "Source file location" }
321
- );
322
- var issueSeveritySchema = z6.enum(["info", "warning", "error"], {
323
- description: "Severity level"
324
- });
325
- var issueSchema = z6.object(
326
- {
327
- message: z6.string({ description: "Descriptive error message" }).max(512),
328
- severity: issueSeveritySchema,
329
- source: sourceFileLocationSchema.optional()
330
- },
331
- { description: "Issue information" }
332
- );
333
-
334
- // packages/models/src/lib/plugin-process-output.ts
335
- var auditOutputSchema = z7.object(
336
- {
337
- slug: slugSchema("Reference to audit"),
338
- displayValue: z7.string({ description: "Formatted value (e.g. '0.9 s', '2.1 MB')" }).optional(),
339
- value: positiveIntSchema("Raw numeric value"),
340
- score: z7.number({
341
- description: "Value between 0 and 1"
342
- }).min(0).max(1),
343
- details: z7.object(
344
- {
345
- issues: z7.array(issueSchema, { description: "List of findings" })
346
- },
347
- { description: "Detailed information" }
348
- ).optional()
349
- },
350
- { description: "Audit information" }
351
- );
352
- var auditOutputsSchema = z7.array(auditOutputSchema, {
353
- description: "List of JSON formatted audit output emitted by the runner process of a plugin"
354
- }).refine(
355
- (audits) => !getDuplicateSlugsInAudits2(audits),
356
- (audits) => ({ message: duplicateSlugsInAuditsErrorMsg2(audits) })
357
- );
358
- function duplicateSlugsInAuditsErrorMsg2(audits) {
359
- const duplicateRefs = getDuplicateSlugsInAudits2(audits);
360
- return `In plugin audits the slugs are not unique: ${errorItems(
361
- duplicateRefs
362
- )}`;
363
- }
364
- function getDuplicateSlugsInAudits2(audits) {
365
- return hasDuplicateStrings(audits.map(({ slug }) => slug));
366
- }
367
-
368
- // packages/models/src/lib/plugin-config-runner.ts
369
363
  var outputTransformSchema = z8.function().args(z8.unknown()).returns(z8.union([auditOutputsSchema, z8.promise(auditOutputsSchema)]));
370
364
  var runnerConfigSchema = z8.object(
371
365
  {
@@ -402,7 +396,7 @@ var pluginMetaSchema = packageVersionSchema({
402
396
  var pluginDataSchema = z9.object({
403
397
  runner: z9.union([runnerConfigSchema, runnerFunctionSchema]),
404
398
  audits: pluginAuditsSchema,
405
- groups: auditGroupsSchema
399
+ groups: groupsSchema
406
400
  });
407
401
  var pluginConfigSchema = pluginMetaSchema.merge(pluginDataSchema).refine(
408
402
  (pluginCfg) => !getMissingRefsFromGroups(pluginCfg),
@@ -515,7 +509,7 @@ var pluginReportSchema = pluginMetaSchema.merge(
515
509
  ).merge(
516
510
  z12.object({
517
511
  audits: z12.array(auditReportSchema),
518
- groups: z12.array(auditGroupSchema).optional()
512
+ groups: z12.array(groupSchema).optional()
519
513
  })
520
514
  );
521
515
  var reportSchema = packageVersionSchema({
package/index.js CHANGED
@@ -5,7 +5,7 @@ import { fileURLToPath } from "url";
5
5
 
6
6
  // packages/plugin-eslint/package.json
7
7
  var name = "@code-pushup/eslint-plugin";
8
- var version = "0.8.0";
8
+ var version = "0.8.1";
9
9
 
10
10
  // packages/plugin-eslint/src/lib/config.ts
11
11
  import { z } from "zod";
@@ -24,7 +24,7 @@ var eslintPluginConfigSchema = z.object({
24
24
  })
25
25
  });
26
26
 
27
- // packages/models/src/lib/category-config.ts
27
+ // packages/models/src/lib/audit.ts
28
28
  import { z as z3 } from "zod";
29
29
 
30
30
  // packages/models/src/lib/implementation/schemas.ts
@@ -164,13 +164,107 @@ function hasWeightedRefsInCategories(categoryRefs) {
164
164
  return categoryRefs.reduce((acc, { weight }) => weight + acc, 0) !== 0;
165
165
  }
166
166
 
167
+ // packages/models/src/lib/audit.ts
168
+ var auditSchema = z3.object({
169
+ slug: slugSchema("ID (unique within plugin)")
170
+ }).merge(
171
+ metaSchema({
172
+ titleDescription: "Descriptive name",
173
+ descriptionDescription: "Description (markdown)",
174
+ docsUrlDescription: "Link to documentation (rationale)",
175
+ description: "List of scorable metrics for the given plugin"
176
+ })
177
+ );
178
+ var pluginAuditsSchema = z3.array(auditSchema, {
179
+ description: "List of audits maintained in a plugin"
180
+ }).refine(
181
+ (auditMetadata) => !getDuplicateSlugsInAudits(auditMetadata),
182
+ (auditMetadata) => ({
183
+ message: duplicateSlugsInAuditsErrorMsg(auditMetadata)
184
+ })
185
+ );
186
+ function duplicateSlugsInAuditsErrorMsg(audits) {
187
+ const duplicateRefs = getDuplicateSlugsInAudits(audits);
188
+ return `In plugin audits the slugs are not unique: ${errorItems(
189
+ duplicateRefs
190
+ )}`;
191
+ }
192
+ function getDuplicateSlugsInAudits(audits) {
193
+ return hasDuplicateStrings(audits.map(({ slug }) => slug));
194
+ }
195
+
196
+ // packages/models/src/lib/audit-issue.ts
197
+ import { z as z4 } from "zod";
198
+ var sourceFileLocationSchema = z4.object(
199
+ {
200
+ file: filePathSchema("Relative path to source file in Git repo"),
201
+ position: z4.object(
202
+ {
203
+ startLine: positiveIntSchema("Start line"),
204
+ startColumn: positiveIntSchema("Start column").optional(),
205
+ endLine: positiveIntSchema("End line").optional(),
206
+ endColumn: positiveIntSchema("End column").optional()
207
+ },
208
+ { description: "Location in file" }
209
+ ).optional()
210
+ },
211
+ { description: "Source file location" }
212
+ );
213
+ var issueSeveritySchema = z4.enum(["info", "warning", "error"], {
214
+ description: "Severity level"
215
+ });
216
+ var issueSchema = z4.object(
217
+ {
218
+ message: z4.string({ description: "Descriptive error message" }).max(512),
219
+ severity: issueSeveritySchema,
220
+ source: sourceFileLocationSchema.optional()
221
+ },
222
+ { description: "Issue information" }
223
+ );
224
+
225
+ // packages/models/src/lib/audit-output.ts
226
+ import { z as z5 } from "zod";
227
+ var auditOutputSchema = z5.object(
228
+ {
229
+ slug: slugSchema("Reference to audit"),
230
+ displayValue: z5.string({ description: "Formatted value (e.g. '0.9 s', '2.1 MB')" }).optional(),
231
+ value: positiveIntSchema("Raw numeric value"),
232
+ score: z5.number({
233
+ description: "Value between 0 and 1"
234
+ }).min(0).max(1),
235
+ details: z5.object(
236
+ {
237
+ issues: z5.array(issueSchema, { description: "List of findings" })
238
+ },
239
+ { description: "Detailed information" }
240
+ ).optional()
241
+ },
242
+ { description: "Audit information" }
243
+ );
244
+ var auditOutputsSchema = z5.array(auditOutputSchema, {
245
+ description: "List of JSON formatted audit output emitted by the runner process of a plugin"
246
+ }).refine(
247
+ (audits) => !getDuplicateSlugsInAudits2(audits),
248
+ (audits) => ({ message: duplicateSlugsInAuditsErrorMsg2(audits) })
249
+ );
250
+ function duplicateSlugsInAuditsErrorMsg2(audits) {
251
+ const duplicateRefs = getDuplicateSlugsInAudits2(audits);
252
+ return `In plugin audits the slugs are not unique: ${errorItems(
253
+ duplicateRefs
254
+ )}`;
255
+ }
256
+ function getDuplicateSlugsInAudits2(audits) {
257
+ return hasDuplicateStrings(audits.map(({ slug }) => slug));
258
+ }
259
+
167
260
  // packages/models/src/lib/category-config.ts
261
+ import { z as z6 } from "zod";
168
262
  var categoryRefSchema = weightedRefSchema(
169
263
  "Weighted references to audits and/or groups for the category",
170
264
  "Slug of an audit or group (depending on `type`)"
171
265
  ).merge(
172
- z3.object({
173
- type: z3.enum(["audit", "group"], {
266
+ z6.object({
267
+ type: z6.enum(["audit", "group"], {
174
268
  description: "Discriminant for reference kind, affects where `slug` is looked up"
175
269
  }),
176
270
  plugin: slugSchema(
@@ -191,8 +285,8 @@ var categoryConfigSchema = scorableSchema(
191
285
  description: "Meta info for category"
192
286
  })
193
287
  ).merge(
194
- z3.object({
195
- isBinary: z3.boolean({
288
+ z6.object({
289
+ isBinary: z6.boolean({
196
290
  description: 'Is this a binary category (i.e. only a perfect score considered a "pass")?'
197
291
  }).optional()
198
292
  })
@@ -208,7 +302,7 @@ function getDuplicateRefsInCategoryMetrics(metrics) {
208
302
  metrics.map(({ slug, type, plugin }) => `${type} :: ${plugin} / ${slug}`)
209
303
  );
210
304
  }
211
- var categoriesSchema = z3.array(categoryConfigSchema, {
305
+ var categoriesSchema = z6.array(categoryConfigSchema, {
212
306
  description: "Categorization of individual audits"
213
307
  }).min(1).refine(
214
308
  (categoryCfg) => !getDuplicateSlugCategories(categoryCfg),
@@ -230,68 +324,38 @@ function getDuplicateSlugCategories(categories) {
230
324
  import { z as z12 } from "zod";
231
325
 
232
326
  // packages/models/src/lib/persist-config.ts
233
- import { z as z4 } from "zod";
234
- var formatSchema = z4.enum(["json", "md"]);
235
- var persistConfigSchema = z4.object({
327
+ import { z as z7 } from "zod";
328
+ var formatSchema = z7.enum(["json", "md"]);
329
+ var persistConfigSchema = z7.object({
236
330
  outputDir: filePathSchema("Artifacts folder").optional(),
237
331
  filename: fileNameSchema(
238
332
  "Artifacts file name (without extension)"
239
333
  ).optional(),
240
- format: z4.array(formatSchema).optional()
334
+ format: z7.array(formatSchema).optional()
241
335
  });
242
336
 
243
337
  // packages/models/src/lib/plugin-config.ts
244
338
  import { z as z10 } from "zod";
245
339
 
246
- // packages/models/src/lib/plugin-config-audits.ts
247
- import { z as z5 } from "zod";
248
- var auditSchema = z5.object({
249
- slug: slugSchema("ID (unique within plugin)")
250
- }).merge(
251
- metaSchema({
252
- titleDescription: "Descriptive name",
253
- descriptionDescription: "Description (markdown)",
254
- docsUrlDescription: "Link to documentation (rationale)",
255
- description: "List of scorable metrics for the given plugin"
256
- })
257
- );
258
- var pluginAuditsSchema = z5.array(auditSchema, {
259
- description: "List of audits maintained in a plugin"
260
- }).refine(
261
- (auditMetadata) => !getDuplicateSlugsInAudits(auditMetadata),
262
- (auditMetadata) => ({
263
- message: duplicateSlugsInAuditsErrorMsg(auditMetadata)
264
- })
265
- );
266
- function duplicateSlugsInAuditsErrorMsg(audits) {
267
- const duplicateRefs = getDuplicateSlugsInAudits(audits);
268
- return `In plugin audits the slugs are not unique: ${errorItems(
269
- duplicateRefs
270
- )}`;
271
- }
272
- function getDuplicateSlugsInAudits(audits) {
273
- return hasDuplicateStrings(audits.map(({ slug }) => slug));
274
- }
275
-
276
- // packages/models/src/lib/plugin-config-groups.ts
277
- import { z as z6 } from "zod";
278
- var auditGroupRefSchema = weightedRefSchema(
279
- "Weighted references to audits",
280
- "Reference slug to an audit within this plugin (e.g. 'max-lines')"
340
+ // packages/models/src/lib/group.ts
341
+ import { z as z8 } from "zod";
342
+ var groupRefSchema = weightedRefSchema(
343
+ "Weighted reference to a group",
344
+ "Reference slug to a group within this plugin (e.g. 'max-lines')"
281
345
  );
282
- var auditGroupMetaSchema = metaSchema({
346
+ var groupMetaSchema = metaSchema({
283
347
  titleDescription: "Descriptive name for the group",
284
348
  descriptionDescription: "Description of the group (markdown)",
285
349
  docsUrlDescription: "Group documentation site",
286
350
  description: "Group metadata"
287
351
  });
288
- var auditGroupSchema = scorableSchema(
289
- 'An audit group aggregates a set of audits into a single score which can be referenced from a category. E.g. the group slug "performance" groups audits and can be referenced in a category',
290
- auditGroupRefSchema,
352
+ var groupSchema = scorableSchema(
353
+ 'A group aggregates a set of audits into a single score which can be referenced from a category. E.g. the group slug "performance" groups audits and can be referenced in a category',
354
+ groupRefSchema,
291
355
  getDuplicateRefsInGroups,
292
356
  duplicateRefsInGroupsErrorMsg
293
- ).merge(auditGroupMetaSchema);
294
- var auditGroupsSchema = z6.array(auditGroupSchema, {
357
+ ).merge(groupMetaSchema);
358
+ var groupsSchema = z8.array(groupSchema, {
295
359
  description: "List of groups"
296
360
  }).optional().refine(
297
361
  (groups) => !getDuplicateSlugsInGroups(groups),
@@ -299,16 +363,14 @@ var auditGroupsSchema = z6.array(auditGroupSchema, {
299
363
  message: duplicateSlugsInGroupsErrorMsg(groups)
300
364
  })
301
365
  );
302
- function duplicateRefsInGroupsErrorMsg(groupAudits) {
303
- const duplicateRefs = getDuplicateRefsInGroups(groupAudits);
304
- return `In plugin groups the audit refs are not unique: ${errorItems(
366
+ function duplicateRefsInGroupsErrorMsg(groups) {
367
+ const duplicateRefs = getDuplicateRefsInGroups(groups);
368
+ return `In plugin groups the following references are not unique: ${errorItems(
305
369
  duplicateRefs
306
370
  )}`;
307
371
  }
308
- function getDuplicateRefsInGroups(groupAudits) {
309
- return hasDuplicateStrings(
310
- groupAudits.map(({ slug: ref }) => ref).filter(exists)
311
- );
372
+ function getDuplicateRefsInGroups(groups) {
373
+ return hasDuplicateStrings(groups.map(({ slug: ref }) => ref).filter(exists));
312
374
  }
313
375
  function duplicateSlugsInGroupsErrorMsg(groups) {
314
376
  const duplicateRefs = getDuplicateSlugsInGroups(groups);
@@ -318,76 +380,8 @@ function getDuplicateSlugsInGroups(groups) {
318
380
  return Array.isArray(groups) ? hasDuplicateStrings(groups.map(({ slug }) => slug)) : false;
319
381
  }
320
382
 
321
- // packages/models/src/lib/plugin-config-runner.ts
383
+ // packages/models/src/lib/runner-config.ts
322
384
  import { z as z9 } from "zod";
323
-
324
- // packages/models/src/lib/plugin-process-output.ts
325
- import { z as z8 } from "zod";
326
-
327
- // packages/models/src/lib/plugin-process-output-audit-issue.ts
328
- import { z as z7 } from "zod";
329
- var sourceFileLocationSchema = z7.object(
330
- {
331
- file: filePathSchema("Relative path to source file in Git repo"),
332
- position: z7.object(
333
- {
334
- startLine: positiveIntSchema("Start line"),
335
- startColumn: positiveIntSchema("Start column").optional(),
336
- endLine: positiveIntSchema("End line").optional(),
337
- endColumn: positiveIntSchema("End column").optional()
338
- },
339
- { description: "Location in file" }
340
- ).optional()
341
- },
342
- { description: "Source file location" }
343
- );
344
- var issueSeveritySchema = z7.enum(["info", "warning", "error"], {
345
- description: "Severity level"
346
- });
347
- var issueSchema = z7.object(
348
- {
349
- message: z7.string({ description: "Descriptive error message" }).max(512),
350
- severity: issueSeveritySchema,
351
- source: sourceFileLocationSchema.optional()
352
- },
353
- { description: "Issue information" }
354
- );
355
-
356
- // packages/models/src/lib/plugin-process-output.ts
357
- var auditOutputSchema = z8.object(
358
- {
359
- slug: slugSchema("Reference to audit"),
360
- displayValue: z8.string({ description: "Formatted value (e.g. '0.9 s', '2.1 MB')" }).optional(),
361
- value: positiveIntSchema("Raw numeric value"),
362
- score: z8.number({
363
- description: "Value between 0 and 1"
364
- }).min(0).max(1),
365
- details: z8.object(
366
- {
367
- issues: z8.array(issueSchema, { description: "List of findings" })
368
- },
369
- { description: "Detailed information" }
370
- ).optional()
371
- },
372
- { description: "Audit information" }
373
- );
374
- var auditOutputsSchema = z8.array(auditOutputSchema, {
375
- description: "List of JSON formatted audit output emitted by the runner process of a plugin"
376
- }).refine(
377
- (audits) => !getDuplicateSlugsInAudits2(audits),
378
- (audits) => ({ message: duplicateSlugsInAuditsErrorMsg2(audits) })
379
- );
380
- function duplicateSlugsInAuditsErrorMsg2(audits) {
381
- const duplicateRefs = getDuplicateSlugsInAudits2(audits);
382
- return `In plugin audits the slugs are not unique: ${errorItems(
383
- duplicateRefs
384
- )}`;
385
- }
386
- function getDuplicateSlugsInAudits2(audits) {
387
- return hasDuplicateStrings(audits.map(({ slug }) => slug));
388
- }
389
-
390
- // packages/models/src/lib/plugin-config-runner.ts
391
385
  var outputTransformSchema = z9.function().args(z9.unknown()).returns(z9.union([auditOutputsSchema, z9.promise(auditOutputsSchema)]));
392
386
  var runnerConfigSchema = z9.object(
393
387
  {
@@ -424,7 +418,7 @@ var pluginMetaSchema = packageVersionSchema({
424
418
  var pluginDataSchema = z10.object({
425
419
  runner: z10.union([runnerConfigSchema, runnerFunctionSchema]),
426
420
  audits: pluginAuditsSchema,
427
- groups: auditGroupsSchema
421
+ groups: groupsSchema
428
422
  });
429
423
  var pluginConfigSchema = pluginMetaSchema.merge(pluginDataSchema).refine(
430
424
  (pluginCfg) => !getMissingRefsFromGroups(pluginCfg),
@@ -537,7 +531,7 @@ var pluginReportSchema = pluginMetaSchema.merge(
537
531
  ).merge(
538
532
  z13.object({
539
533
  audits: z13.array(auditReportSchema),
540
- groups: z13.array(auditGroupSchema).optional()
534
+ groups: z13.array(groupSchema).optional()
541
535
  })
542
536
  );
543
537
  var reportSchema = packageVersionSchema({
@@ -728,9 +722,7 @@ function groupsFromRuleTypes(rules) {
728
722
  );
729
723
  return allTypes.map((type) => ({
730
724
  ...typeGroups[type],
731
- refs: auditSlugsMap[type]?.map(
732
- (slug) => ({ slug, weight: 1 })
733
- ) ?? []
725
+ refs: auditSlugsMap[type]?.map((slug) => ({ slug, weight: 1 })) ?? []
734
726
  })).filter((group) => group.refs.length);
735
727
  }
736
728
  function groupsFromRuleCategories(rules) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code-pushup/eslint-plugin",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "dependencies": {
5
5
  "@code-pushup/utils": "*",
6
6
  "@code-pushup/models": "*",
@@ -1,4 +1,4 @@
1
- import type { AuditGroup } from '@code-pushup/models';
1
+ import type { Group } from '@code-pushup/models';
2
2
  import { type RuleData } from './rules';
3
- export declare function groupsFromRuleTypes(rules: RuleData[]): AuditGroup[];
4
- export declare function groupsFromRuleCategories(rules: RuleData[]): AuditGroup[];
3
+ export declare function groupsFromRuleTypes(rules: RuleData[]): Group[];
4
+ export declare function groupsFromRuleCategories(rules: RuleData[]): Group[];
@@ -1,6 +1,6 @@
1
1
  import type { ESLint } from 'eslint';
2
- import type { Audit, AuditGroup } from '@code-pushup/models';
2
+ import type { Audit, Group } from '@code-pushup/models';
3
3
  export declare function listAuditsAndGroups(eslint: ESLint, patterns: string | string[]): Promise<{
4
4
  audits: Audit[];
5
- groups: AuditGroup[];
5
+ groups: Group[];
6
6
  }>;