@code-pushup/eslint-plugin 0.55.0 → 0.57.0

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 (81) hide show
  1. package/package.json +8 -7
  2. package/src/bin.js +3 -0
  3. package/src/bin.js.map +1 -0
  4. package/src/index.d.ts +3 -3
  5. package/src/index.js +4 -0
  6. package/src/index.js.map +1 -0
  7. package/src/lib/config.js +19 -0
  8. package/src/lib/config.js.map +1 -0
  9. package/src/lib/eslint-plugin.d.ts +1 -1
  10. package/src/lib/eslint-plugin.js +45 -0
  11. package/src/lib/eslint-plugin.js.map +1 -0
  12. package/src/lib/meta/groups.d.ts +1 -1
  13. package/src/lib/meta/groups.js +64 -0
  14. package/src/lib/meta/groups.js.map +1 -0
  15. package/src/lib/meta/hash.d.ts +2 -0
  16. package/src/lib/meta/hash.js +19 -0
  17. package/src/lib/meta/hash.js.map +1 -0
  18. package/src/lib/meta/index.d.ts +3 -1
  19. package/src/lib/meta/index.js +15 -0
  20. package/src/lib/meta/index.js.map +1 -0
  21. package/src/lib/meta/parse.d.ts +2 -1
  22. package/src/lib/meta/parse.js +36 -0
  23. package/src/lib/meta/parse.js.map +1 -0
  24. package/src/lib/meta/rules.d.ts +2 -2
  25. package/src/lib/meta/rules.js +22 -0
  26. package/src/lib/meta/rules.js.map +1 -0
  27. package/src/lib/meta/transform.d.ts +2 -2
  28. package/src/lib/meta/transform.js +21 -0
  29. package/src/lib/meta/transform.js.map +1 -0
  30. package/src/lib/meta/versions/detect.d.ts +1 -1
  31. package/src/lib/meta/versions/detect.js +22 -0
  32. package/src/lib/meta/versions/detect.js.map +1 -0
  33. package/src/lib/meta/versions/flat.d.ts +2 -2
  34. package/src/lib/meta/versions/flat.js +81 -0
  35. package/src/lib/meta/versions/flat.js.map +1 -0
  36. package/src/lib/meta/versions/formats.js +2 -0
  37. package/src/lib/meta/versions/formats.js.map +1 -0
  38. package/src/lib/meta/versions/index.d.ts +5 -5
  39. package/src/lib/meta/versions/index.js +12 -0
  40. package/src/lib/meta/versions/index.js.map +1 -0
  41. package/src/lib/meta/versions/legacy.d.ts +2 -2
  42. package/src/lib/meta/versions/legacy.js +36 -0
  43. package/src/lib/meta/versions/legacy.js.map +1 -0
  44. package/src/lib/nx/filter-project-graph.js +12 -0
  45. package/src/lib/nx/filter-project-graph.js.map +1 -0
  46. package/src/lib/nx/find-all-projects.d.ts +1 -1
  47. package/src/lib/nx/find-all-projects.js +40 -0
  48. package/src/lib/nx/find-all-projects.js.map +1 -0
  49. package/src/lib/nx/find-project-with-deps.d.ts +1 -1
  50. package/src/lib/nx/find-project-with-deps.js +35 -0
  51. package/src/lib/nx/find-project-with-deps.js.map +1 -0
  52. package/src/lib/nx/find-project-without-deps.d.ts +1 -1
  53. package/src/lib/nx/find-project-without-deps.js +36 -0
  54. package/src/lib/nx/find-project-without-deps.js.map +1 -0
  55. package/src/lib/nx/index.d.ts +3 -3
  56. package/src/lib/nx/index.js +4 -0
  57. package/src/lib/nx/index.js.map +1 -0
  58. package/src/lib/nx/projects-to-config.d.ts +1 -1
  59. package/src/lib/nx/projects-to-config.js +18 -0
  60. package/src/lib/nx/projects-to-config.js.map +1 -0
  61. package/src/lib/nx/traverse-graph.js +21 -0
  62. package/src/lib/nx/traverse-graph.js.map +1 -0
  63. package/src/lib/nx/utils.d.ts +4 -3
  64. package/src/lib/nx/utils.js +75 -0
  65. package/src/lib/nx/utils.js.map +1 -0
  66. package/src/lib/runner/index.d.ts +1 -1
  67. package/src/lib/runner/index.js +37 -0
  68. package/src/lib/runner/index.js.map +1 -0
  69. package/src/lib/runner/lint.d.ts +2 -2
  70. package/src/lib/runner/lint.js +49 -0
  71. package/src/lib/runner/lint.js.map +1 -0
  72. package/src/lib/runner/transform.d.ts +1 -1
  73. package/src/lib/runner/transform.js +74 -0
  74. package/src/lib/runner/transform.js.map +1 -0
  75. package/src/lib/runner/types.js +2 -0
  76. package/src/lib/runner/types.js.map +1 -0
  77. package/src/lib/setup.d.ts +1 -1
  78. package/src/lib/setup.js +17 -0
  79. package/src/lib/setup.js.map +1 -0
  80. package/bin.js +0 -1129
  81. package/index.js +0 -1376
package/bin.js DELETED
@@ -1,1129 +0,0 @@
1
- // packages/plugin-eslint/src/lib/runner/index.ts
2
- import { writeFile } from "node:fs/promises";
3
- import { dirname as dirname2, join as join2 } from "node:path";
4
-
5
- // packages/models/src/lib/implementation/schemas.ts
6
- import { MATERIAL_ICONS } from "vscode-material-icons";
7
- import { z } from "zod";
8
-
9
- // packages/models/src/lib/implementation/limits.ts
10
- var MAX_SLUG_LENGTH = 128;
11
- var MAX_TITLE_LENGTH = 256;
12
- var MAX_DESCRIPTION_LENGTH = 65536;
13
- var MAX_ISSUE_MESSAGE_LENGTH = 1024;
14
-
15
- // packages/models/src/lib/implementation/utils.ts
16
- var slugRegex = /^[a-z\d]+(?:-[a-z\d]+)*$/;
17
- var filenameRegex = /^(?!.*[ \\/:*?"<>|]).+$/;
18
- function hasDuplicateStrings(strings) {
19
- const sortedStrings = strings.toSorted();
20
- const duplStrings = sortedStrings.filter(
21
- (item, index) => index !== 0 && item === sortedStrings[index - 1]
22
- );
23
- return duplStrings.length === 0 ? false : [...new Set(duplStrings)];
24
- }
25
- function hasMissingStrings(toCheck, existing) {
26
- const nonExisting = toCheck.filter((s) => !existing.includes(s));
27
- return nonExisting.length === 0 ? false : nonExisting;
28
- }
29
- function errorItems(items, transform = (itemArr) => itemArr.join(", ")) {
30
- return transform(items || []);
31
- }
32
- function exists(value) {
33
- return value != null;
34
- }
35
- function getMissingRefsForCategories(categories, plugins) {
36
- if (!categories || categories.length === 0) {
37
- return false;
38
- }
39
- const auditRefsFromCategory = categories.flatMap(
40
- ({ refs }) => refs.filter(({ type }) => type === "audit").map(({ plugin, slug }) => `${plugin}/${slug}`)
41
- );
42
- const auditRefsFromPlugins = plugins.flatMap(
43
- ({ audits, slug: pluginSlug }) => audits.map(({ slug }) => `${pluginSlug}/${slug}`)
44
- );
45
- const missingAuditRefs = hasMissingStrings(
46
- auditRefsFromCategory,
47
- auditRefsFromPlugins
48
- );
49
- const groupRefsFromCategory = categories.flatMap(
50
- ({ refs }) => refs.filter(({ type }) => type === "group").map(({ plugin, slug }) => `${plugin}#${slug} (group)`)
51
- );
52
- const groupRefsFromPlugins = plugins.flatMap(
53
- ({ groups, slug: pluginSlug }) => Array.isArray(groups) ? groups.map(({ slug }) => `${pluginSlug}#${slug} (group)`) : []
54
- );
55
- const missingGroupRefs = hasMissingStrings(
56
- groupRefsFromCategory,
57
- groupRefsFromPlugins
58
- );
59
- const missingRefs = [missingAuditRefs, missingGroupRefs].filter((refs) => Array.isArray(refs) && refs.length > 0).flat();
60
- return missingRefs.length > 0 ? missingRefs : false;
61
- }
62
- function missingRefsForCategoriesErrorMsg(categories, plugins) {
63
- const missingRefs = getMissingRefsForCategories(categories, plugins);
64
- return `The following category references need to point to an audit or group: ${errorItems(
65
- missingRefs
66
- )}`;
67
- }
68
-
69
- // packages/models/src/lib/implementation/schemas.ts
70
- var tableCellValueSchema = z.union([z.string(), z.number(), z.boolean(), z.null()]).default(null);
71
- function executionMetaSchema(options = {
72
- descriptionDate: "Execution start date and time",
73
- descriptionDuration: "Execution duration in ms"
74
- }) {
75
- return z.object({
76
- date: z.string({ description: options.descriptionDate }),
77
- duration: z.number({ description: options.descriptionDuration })
78
- });
79
- }
80
- var slugSchema = z.string({ description: "Unique ID (human-readable, URL-safe)" }).regex(slugRegex, {
81
- message: "The slug has to follow the pattern [0-9a-z] followed by multiple optional groups of -[0-9a-z]. e.g. my-slug"
82
- }).max(MAX_SLUG_LENGTH, {
83
- message: `slug can be max ${MAX_SLUG_LENGTH} characters long`
84
- });
85
- var descriptionSchema = z.string({ description: "Description (markdown)" }).max(MAX_DESCRIPTION_LENGTH).optional();
86
- var urlSchema = z.string().url();
87
- var docsUrlSchema = urlSchema.optional().or(z.literal("")).describe("Documentation site");
88
- var titleSchema = z.string({ description: "Descriptive name" }).max(MAX_TITLE_LENGTH);
89
- var scoreSchema = z.number({
90
- description: "Value between 0 and 1"
91
- }).min(0).max(1);
92
- function metaSchema(options) {
93
- const {
94
- descriptionDescription,
95
- titleDescription,
96
- docsUrlDescription,
97
- description
98
- } = options ?? {};
99
- return z.object(
100
- {
101
- title: titleDescription ? titleSchema.describe(titleDescription) : titleSchema,
102
- description: descriptionDescription ? descriptionSchema.describe(descriptionDescription) : descriptionSchema,
103
- docsUrl: docsUrlDescription ? docsUrlSchema.describe(docsUrlDescription) : docsUrlSchema
104
- },
105
- { description }
106
- );
107
- }
108
- var filePathSchema = z.string().trim().min(1, { message: "path is invalid" });
109
- var fileNameSchema = z.string().trim().regex(filenameRegex, {
110
- message: `The filename has to be valid`
111
- }).min(1, { message: "file name is invalid" });
112
- var positiveIntSchema = z.number().int().positive();
113
- var nonnegativeNumberSchema = z.number().nonnegative();
114
- function packageVersionSchema(options) {
115
- const { versionDescription = "NPM version of the package", required } = options ?? {};
116
- const packageSchema = z.string({ description: "NPM package name" });
117
- const versionSchema = z.string({ description: versionDescription });
118
- return z.object(
119
- {
120
- packageName: required ? packageSchema : packageSchema.optional(),
121
- version: required ? versionSchema : versionSchema.optional()
122
- },
123
- { description: "NPM package name and version of a published package" }
124
- );
125
- }
126
- var weightSchema = nonnegativeNumberSchema.describe(
127
- "Coefficient for the given score (use weight 0 if only for display)"
128
- );
129
- function weightedRefSchema(description, slugDescription) {
130
- return z.object(
131
- {
132
- slug: slugSchema.describe(slugDescription),
133
- weight: weightSchema.describe("Weight used to calculate score")
134
- },
135
- { description }
136
- );
137
- }
138
- function scorableSchema(description, refSchema, duplicateCheckFn, duplicateMessageFn) {
139
- return z.object(
140
- {
141
- slug: slugSchema.describe('Human-readable unique ID, e.g. "performance"'),
142
- refs: z.array(refSchema).min(1).refine(
143
- (refs) => !duplicateCheckFn(refs),
144
- (refs) => ({
145
- message: duplicateMessageFn(refs)
146
- })
147
- ).refine(hasNonZeroWeightedRef, () => ({
148
- message: "In a category there has to be at least one ref with weight > 0"
149
- }))
150
- },
151
- { description }
152
- );
153
- }
154
- var materialIconSchema = z.enum(MATERIAL_ICONS, {
155
- description: "Icon from VSCode Material Icons extension"
156
- });
157
- function hasNonZeroWeightedRef(refs) {
158
- return refs.reduce((acc, { weight }) => weight + acc, 0) !== 0;
159
- }
160
-
161
- // packages/models/src/lib/source.ts
162
- import { z as z2 } from "zod";
163
- var sourceFileLocationSchema = z2.object(
164
- {
165
- file: filePathSchema.describe("Relative path to source file in Git repo"),
166
- position: z2.object(
167
- {
168
- startLine: positiveIntSchema.describe("Start line"),
169
- startColumn: positiveIntSchema.describe("Start column").optional(),
170
- endLine: positiveIntSchema.describe("End line").optional(),
171
- endColumn: positiveIntSchema.describe("End column").optional()
172
- },
173
- { description: "Location in file" }
174
- ).optional()
175
- },
176
- { description: "Source file location" }
177
- );
178
-
179
- // packages/models/src/lib/audit.ts
180
- import { z as z3 } from "zod";
181
- var auditSchema = z3.object({
182
- slug: slugSchema.describe("ID (unique within plugin)")
183
- }).merge(
184
- metaSchema({
185
- titleDescription: "Descriptive name",
186
- descriptionDescription: "Description (markdown)",
187
- docsUrlDescription: "Link to documentation (rationale)",
188
- description: "List of scorable metrics for the given plugin"
189
- })
190
- );
191
- var pluginAuditsSchema = z3.array(auditSchema, {
192
- description: "List of audits maintained in a plugin"
193
- }).min(1).refine(
194
- (auditMetadata) => !getDuplicateSlugsInAudits(auditMetadata),
195
- (auditMetadata) => ({
196
- message: duplicateSlugsInAuditsErrorMsg(auditMetadata)
197
- })
198
- );
199
- function duplicateSlugsInAuditsErrorMsg(audits) {
200
- const duplicateRefs = getDuplicateSlugsInAudits(audits);
201
- return `In plugin audits the following slugs are not unique: ${errorItems(
202
- duplicateRefs
203
- )}`;
204
- }
205
- function getDuplicateSlugsInAudits(audits) {
206
- return hasDuplicateStrings(audits.map(({ slug }) => slug));
207
- }
208
-
209
- // packages/models/src/lib/audit-output.ts
210
- import { z as z6 } from "zod";
211
-
212
- // packages/models/src/lib/issue.ts
213
- import { z as z4 } from "zod";
214
- var issueSeveritySchema = z4.enum(["info", "warning", "error"], {
215
- description: "Severity level"
216
- });
217
- var issueSchema = z4.object(
218
- {
219
- message: z4.string({ description: "Descriptive error message" }).max(MAX_ISSUE_MESSAGE_LENGTH),
220
- severity: issueSeveritySchema,
221
- source: sourceFileLocationSchema.optional()
222
- },
223
- { description: "Issue information" }
224
- );
225
-
226
- // packages/models/src/lib/table.ts
227
- import { z as z5 } from "zod";
228
- var tableAlignmentSchema = z5.enum(["left", "center", "right"], {
229
- description: "Cell alignment"
230
- });
231
- var tableColumnObjectSchema = z5.object({
232
- key: z5.string(),
233
- label: z5.string().optional(),
234
- align: tableAlignmentSchema.optional()
235
- });
236
- var tableRowObjectSchema = z5.record(tableCellValueSchema, {
237
- description: "Object row"
238
- });
239
- var tableRowPrimitiveSchema = z5.array(tableCellValueSchema, {
240
- description: "Primitive row"
241
- });
242
- var tableSharedSchema = z5.object({
243
- title: z5.string().optional().describe("Display title for table")
244
- });
245
- var tablePrimitiveSchema = tableSharedSchema.merge(
246
- z5.object(
247
- {
248
- columns: z5.array(tableAlignmentSchema).optional(),
249
- rows: z5.array(tableRowPrimitiveSchema)
250
- },
251
- { description: "Table with primitive rows and optional alignment columns" }
252
- )
253
- );
254
- var tableObjectSchema = tableSharedSchema.merge(
255
- z5.object(
256
- {
257
- columns: z5.union([
258
- z5.array(tableAlignmentSchema),
259
- z5.array(tableColumnObjectSchema)
260
- ]).optional(),
261
- rows: z5.array(tableRowObjectSchema)
262
- },
263
- {
264
- description: "Table with object rows and optional alignment or object columns"
265
- }
266
- )
267
- );
268
- var tableSchema = (description = "Table information") => z5.union([tablePrimitiveSchema, tableObjectSchema], { description });
269
-
270
- // packages/models/src/lib/audit-output.ts
271
- var auditValueSchema = nonnegativeNumberSchema.describe("Raw numeric value");
272
- var auditDisplayValueSchema = z6.string({ description: "Formatted value (e.g. '0.9 s', '2.1 MB')" }).optional();
273
- var auditDetailsSchema = z6.object(
274
- {
275
- issues: z6.array(issueSchema, { description: "List of findings" }).optional(),
276
- table: tableSchema("Table of related findings").optional()
277
- },
278
- { description: "Detailed information" }
279
- );
280
- var auditOutputSchema = z6.object(
281
- {
282
- slug: slugSchema.describe("Reference to audit"),
283
- displayValue: auditDisplayValueSchema,
284
- value: auditValueSchema,
285
- score: scoreSchema,
286
- details: auditDetailsSchema.optional()
287
- },
288
- { description: "Audit information" }
289
- );
290
- var auditOutputsSchema = z6.array(auditOutputSchema, {
291
- description: "List of JSON formatted audit output emitted by the runner process of a plugin"
292
- }).refine(
293
- (audits) => !getDuplicateSlugsInAudits2(audits),
294
- (audits) => ({ message: duplicateSlugsInAuditsErrorMsg2(audits) })
295
- );
296
- function duplicateSlugsInAuditsErrorMsg2(audits) {
297
- const duplicateRefs = getDuplicateSlugsInAudits2(audits);
298
- return `In plugin audits the slugs are not unique: ${errorItems(
299
- duplicateRefs
300
- )}`;
301
- }
302
- function getDuplicateSlugsInAudits2(audits) {
303
- return hasDuplicateStrings(audits.map(({ slug }) => slug));
304
- }
305
-
306
- // packages/models/src/lib/category-config.ts
307
- import { z as z7 } from "zod";
308
- var categoryRefSchema = weightedRefSchema(
309
- "Weighted references to audits and/or groups for the category",
310
- "Slug of an audit or group (depending on `type`)"
311
- ).merge(
312
- z7.object({
313
- type: z7.enum(["audit", "group"], {
314
- description: "Discriminant for reference kind, affects where `slug` is looked up"
315
- }),
316
- plugin: slugSchema.describe(
317
- "Plugin slug (plugin should contain referenced audit or group)"
318
- )
319
- })
320
- );
321
- var categoryConfigSchema = scorableSchema(
322
- "Category with a score calculated from audits and groups from various plugins",
323
- categoryRefSchema,
324
- getDuplicateRefsInCategoryMetrics,
325
- duplicateRefsInCategoryMetricsErrorMsg
326
- ).merge(
327
- metaSchema({
328
- titleDescription: "Category Title",
329
- docsUrlDescription: "Category docs URL",
330
- descriptionDescription: "Category description",
331
- description: "Meta info for category"
332
- })
333
- ).merge(
334
- z7.object({
335
- isBinary: z7.boolean({
336
- description: 'Is this a binary category (i.e. only a perfect score considered a "pass")?'
337
- }).optional()
338
- })
339
- );
340
- function duplicateRefsInCategoryMetricsErrorMsg(metrics) {
341
- const duplicateRefs = getDuplicateRefsInCategoryMetrics(metrics);
342
- return `In the categories, the following audit or group refs are duplicates: ${errorItems(
343
- duplicateRefs
344
- )}`;
345
- }
346
- function getDuplicateRefsInCategoryMetrics(metrics) {
347
- return hasDuplicateStrings(
348
- metrics.map(({ slug, type, plugin }) => `${type} :: ${plugin} / ${slug}`)
349
- );
350
- }
351
- var categoriesSchema = z7.array(categoryConfigSchema, {
352
- description: "Categorization of individual audits"
353
- }).refine(
354
- (categoryCfg) => !getDuplicateSlugCategories(categoryCfg),
355
- (categoryCfg) => ({
356
- message: duplicateSlugCategoriesErrorMsg(categoryCfg)
357
- })
358
- );
359
- function duplicateSlugCategoriesErrorMsg(categories) {
360
- const duplicateStringSlugs = getDuplicateSlugCategories(categories);
361
- return `In the categories, the following slugs are duplicated: ${errorItems(
362
- duplicateStringSlugs
363
- )}`;
364
- }
365
- function getDuplicateSlugCategories(categories) {
366
- return hasDuplicateStrings(categories.map(({ slug }) => slug));
367
- }
368
-
369
- // packages/models/src/lib/commit.ts
370
- import { z as z8 } from "zod";
371
- var commitSchema = z8.object(
372
- {
373
- hash: z8.string({ description: "Commit SHA (full)" }).regex(
374
- /^[\da-f]{40}$/,
375
- "Commit SHA should be a 40-character hexadecimal string"
376
- ),
377
- message: z8.string({ description: "Commit message" }),
378
- date: z8.coerce.date({
379
- description: "Date and time when commit was authored"
380
- }),
381
- author: z8.string({
382
- description: "Commit author name"
383
- }).trim()
384
- },
385
- { description: "Git commit" }
386
- );
387
-
388
- // packages/models/src/lib/core-config.ts
389
- import { z as z14 } from "zod";
390
-
391
- // packages/models/src/lib/persist-config.ts
392
- import { z as z9 } from "zod";
393
- var formatSchema = z9.enum(["json", "md"]);
394
- var persistConfigSchema = z9.object({
395
- outputDir: filePathSchema.describe("Artifacts folder").optional(),
396
- filename: fileNameSchema.describe("Artifacts file name (without extension)").optional(),
397
- format: z9.array(formatSchema).optional()
398
- });
399
-
400
- // packages/models/src/lib/plugin-config.ts
401
- import { z as z12 } from "zod";
402
-
403
- // packages/models/src/lib/group.ts
404
- import { z as z10 } from "zod";
405
- var groupRefSchema = weightedRefSchema(
406
- "Weighted reference to a group",
407
- "Reference slug to a group within this plugin (e.g. 'max-lines')"
408
- );
409
- var groupMetaSchema = metaSchema({
410
- titleDescription: "Descriptive name for the group",
411
- descriptionDescription: "Description of the group (markdown)",
412
- docsUrlDescription: "Group documentation site",
413
- description: "Group metadata"
414
- });
415
- var groupSchema = scorableSchema(
416
- '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',
417
- groupRefSchema,
418
- getDuplicateRefsInGroups,
419
- duplicateRefsInGroupsErrorMsg
420
- ).merge(groupMetaSchema);
421
- var groupsSchema = z10.array(groupSchema, {
422
- description: "List of groups"
423
- }).optional().refine(
424
- (groups) => !getDuplicateSlugsInGroups(groups),
425
- (groups) => ({
426
- message: duplicateSlugsInGroupsErrorMsg(groups)
427
- })
428
- );
429
- function duplicateRefsInGroupsErrorMsg(groups) {
430
- const duplicateRefs = getDuplicateRefsInGroups(groups);
431
- return `In plugin groups the following references are not unique: ${errorItems(
432
- duplicateRefs
433
- )}`;
434
- }
435
- function getDuplicateRefsInGroups(groups) {
436
- return hasDuplicateStrings(groups.map(({ slug: ref }) => ref).filter(exists));
437
- }
438
- function duplicateSlugsInGroupsErrorMsg(groups) {
439
- const duplicateRefs = getDuplicateSlugsInGroups(groups);
440
- return `In groups the following slugs are not unique: ${errorItems(
441
- duplicateRefs
442
- )}`;
443
- }
444
- function getDuplicateSlugsInGroups(groups) {
445
- return Array.isArray(groups) ? hasDuplicateStrings(groups.map(({ slug }) => slug)) : false;
446
- }
447
-
448
- // packages/models/src/lib/runner-config.ts
449
- import { z as z11 } from "zod";
450
- var outputTransformSchema = z11.function().args(z11.unknown()).returns(z11.union([auditOutputsSchema, z11.promise(auditOutputsSchema)]));
451
- var runnerConfigSchema = z11.object(
452
- {
453
- command: z11.string({
454
- description: "Shell command to execute"
455
- }),
456
- args: z11.array(z11.string({ description: "Command arguments" })).optional(),
457
- outputFile: filePathSchema.describe("Output path"),
458
- outputTransform: outputTransformSchema.optional()
459
- },
460
- {
461
- description: "How to execute runner"
462
- }
463
- );
464
- var onProgressSchema = z11.function().args(z11.unknown()).returns(z11.void());
465
- var runnerFunctionSchema = z11.function().args(onProgressSchema.optional()).returns(z11.union([auditOutputsSchema, z11.promise(auditOutputsSchema)]));
466
-
467
- // packages/models/src/lib/plugin-config.ts
468
- var pluginMetaSchema = packageVersionSchema().merge(
469
- metaSchema({
470
- titleDescription: "Descriptive name",
471
- descriptionDescription: "Description (markdown)",
472
- docsUrlDescription: "Plugin documentation site",
473
- description: "Plugin metadata"
474
- })
475
- ).merge(
476
- z12.object({
477
- slug: slugSchema.describe("Unique plugin slug within core config"),
478
- icon: materialIconSchema
479
- })
480
- );
481
- var pluginDataSchema = z12.object({
482
- runner: z12.union([runnerConfigSchema, runnerFunctionSchema]),
483
- audits: pluginAuditsSchema,
484
- groups: groupsSchema
485
- });
486
- var pluginConfigSchema = pluginMetaSchema.merge(pluginDataSchema).refine(
487
- (pluginCfg) => !getMissingRefsFromGroups(pluginCfg),
488
- (pluginCfg) => ({
489
- message: missingRefsFromGroupsErrorMsg(pluginCfg)
490
- })
491
- );
492
- function missingRefsFromGroupsErrorMsg(pluginCfg) {
493
- const missingRefs = getMissingRefsFromGroups(pluginCfg);
494
- return `The following group references need to point to an existing audit in this plugin config: ${errorItems(
495
- missingRefs
496
- )}`;
497
- }
498
- function getMissingRefsFromGroups(pluginCfg) {
499
- return hasMissingStrings(
500
- pluginCfg.groups?.flatMap(
501
- ({ refs: audits }) => audits.map(({ slug: ref }) => ref)
502
- ) ?? [],
503
- pluginCfg.audits.map(({ slug }) => slug)
504
- );
505
- }
506
-
507
- // packages/models/src/lib/upload-config.ts
508
- import { z as z13 } from "zod";
509
- var uploadConfigSchema = z13.object({
510
- server: urlSchema.describe("URL of deployed portal API"),
511
- apiKey: z13.string({
512
- description: "API key with write access to portal (use `process.env` for security)"
513
- }),
514
- organization: slugSchema.describe(
515
- "Organization slug from Code PushUp portal"
516
- ),
517
- project: slugSchema.describe("Project slug from Code PushUp portal"),
518
- timeout: z13.number({ description: "Request timeout in minutes (default is 5)" }).positive().int().optional()
519
- });
520
-
521
- // packages/models/src/lib/core-config.ts
522
- var unrefinedCoreConfigSchema = z14.object({
523
- plugins: z14.array(pluginConfigSchema, {
524
- description: "List of plugins to be used (official, community-provided, or custom)"
525
- }).min(1),
526
- /** portal configuration for persisting results */
527
- persist: persistConfigSchema.optional(),
528
- /** portal configuration for uploading results */
529
- upload: uploadConfigSchema.optional(),
530
- categories: categoriesSchema.optional()
531
- });
532
- var coreConfigSchema = refineCoreConfig(unrefinedCoreConfigSchema);
533
- function refineCoreConfig(schema) {
534
- return schema.refine(
535
- ({ categories, plugins }) => !getMissingRefsForCategories(categories, plugins),
536
- ({ categories, plugins }) => ({
537
- message: missingRefsForCategoriesErrorMsg(categories, plugins)
538
- })
539
- );
540
- }
541
-
542
- // packages/models/src/lib/report.ts
543
- import { z as z15 } from "zod";
544
- var auditReportSchema = auditSchema.merge(auditOutputSchema);
545
- var pluginReportSchema = pluginMetaSchema.merge(
546
- executionMetaSchema({
547
- descriptionDate: "Start date and time of plugin run",
548
- descriptionDuration: "Duration of the plugin run in ms"
549
- })
550
- ).merge(
551
- z15.object({
552
- audits: z15.array(auditReportSchema).min(1),
553
- groups: z15.array(groupSchema).optional()
554
- })
555
- ).refine(
556
- (pluginReport) => !getMissingRefsFromGroups2(pluginReport.audits, pluginReport.groups ?? []),
557
- (pluginReport) => ({
558
- message: missingRefsFromGroupsErrorMsg2(
559
- pluginReport.audits,
560
- pluginReport.groups ?? []
561
- )
562
- })
563
- );
564
- function missingRefsFromGroupsErrorMsg2(audits, groups) {
565
- const missingRefs = getMissingRefsFromGroups2(audits, groups);
566
- return `group references need to point to an existing audit in this plugin report: ${errorItems(
567
- missingRefs
568
- )}`;
569
- }
570
- function getMissingRefsFromGroups2(audits, groups) {
571
- return hasMissingStrings(
572
- groups.flatMap(
573
- ({ refs: auditRefs }) => auditRefs.map(({ slug: ref }) => ref)
574
- ),
575
- audits.map(({ slug }) => slug)
576
- );
577
- }
578
- var reportSchema = packageVersionSchema({
579
- versionDescription: "NPM version of the CLI",
580
- required: true
581
- }).merge(
582
- executionMetaSchema({
583
- descriptionDate: "Start date and time of the collect run",
584
- descriptionDuration: "Duration of the collect run in ms"
585
- })
586
- ).merge(
587
- z15.object(
588
- {
589
- plugins: z15.array(pluginReportSchema).min(1),
590
- categories: z15.array(categoryConfigSchema).optional(),
591
- commit: commitSchema.describe("Git commit for which report was collected").nullable()
592
- },
593
- { description: "Collect output data" }
594
- )
595
- ).refine(
596
- ({ categories, plugins }) => !getMissingRefsForCategories(categories, plugins),
597
- ({ categories, plugins }) => ({
598
- message: missingRefsForCategoriesErrorMsg(categories, plugins)
599
- })
600
- );
601
-
602
- // packages/models/src/lib/reports-diff.ts
603
- import { z as z16 } from "zod";
604
- function makeComparisonSchema(schema) {
605
- const sharedDescription = schema.description || "Result";
606
- return z16.object({
607
- before: schema.describe(`${sharedDescription} (source commit)`),
608
- after: schema.describe(`${sharedDescription} (target commit)`)
609
- });
610
- }
611
- function makeArraysComparisonSchema(diffSchema, resultSchema, description) {
612
- return z16.object(
613
- {
614
- changed: z16.array(diffSchema),
615
- unchanged: z16.array(resultSchema),
616
- added: z16.array(resultSchema),
617
- removed: z16.array(resultSchema)
618
- },
619
- { description }
620
- );
621
- }
622
- var scorableMetaSchema = z16.object({
623
- slug: slugSchema,
624
- title: titleSchema,
625
- docsUrl: docsUrlSchema
626
- });
627
- var scorableWithPluginMetaSchema = scorableMetaSchema.merge(
628
- z16.object({
629
- plugin: pluginMetaSchema.pick({ slug: true, title: true, docsUrl: true }).describe("Plugin which defines it")
630
- })
631
- );
632
- var scorableDiffSchema = scorableMetaSchema.merge(
633
- z16.object({
634
- scores: makeComparisonSchema(scoreSchema).merge(
635
- z16.object({
636
- diff: z16.number().min(-1).max(1).describe("Score change (`scores.after - scores.before`)")
637
- })
638
- ).describe("Score comparison")
639
- })
640
- );
641
- var scorableWithPluginDiffSchema = scorableDiffSchema.merge(
642
- scorableWithPluginMetaSchema
643
- );
644
- var categoryDiffSchema = scorableDiffSchema;
645
- var groupDiffSchema = scorableWithPluginDiffSchema;
646
- var auditDiffSchema = scorableWithPluginDiffSchema.merge(
647
- z16.object({
648
- values: makeComparisonSchema(auditValueSchema).merge(
649
- z16.object({
650
- diff: z16.number().describe("Value change (`values.after - values.before`)")
651
- })
652
- ).describe("Audit `value` comparison"),
653
- displayValues: makeComparisonSchema(auditDisplayValueSchema).describe(
654
- "Audit `displayValue` comparison"
655
- )
656
- })
657
- );
658
- var categoryResultSchema = scorableMetaSchema.merge(
659
- z16.object({ score: scoreSchema })
660
- );
661
- var groupResultSchema = scorableWithPluginMetaSchema.merge(
662
- z16.object({ score: scoreSchema })
663
- );
664
- var auditResultSchema = scorableWithPluginMetaSchema.merge(
665
- auditOutputSchema.pick({ score: true, value: true, displayValue: true })
666
- );
667
- var reportsDiffSchema = z16.object({
668
- commits: makeComparisonSchema(commitSchema).nullable().describe("Commits identifying compared reports"),
669
- portalUrl: urlSchema.optional().describe("Link to comparison page in Code PushUp portal"),
670
- label: z16.string().optional().describe("Label (e.g. project name)"),
671
- categories: makeArraysComparisonSchema(
672
- categoryDiffSchema,
673
- categoryResultSchema,
674
- "Changes affecting categories"
675
- ),
676
- groups: makeArraysComparisonSchema(
677
- groupDiffSchema,
678
- groupResultSchema,
679
- "Changes affecting groups"
680
- ),
681
- audits: makeArraysComparisonSchema(
682
- auditDiffSchema,
683
- auditResultSchema,
684
- "Changes affecting audits"
685
- )
686
- }).merge(
687
- packageVersionSchema({
688
- versionDescription: "NPM version of the CLI (when `compare` was run)",
689
- required: true
690
- })
691
- ).merge(
692
- executionMetaSchema({
693
- descriptionDate: "Start date and time of the compare run",
694
- descriptionDuration: "Duration of the compare run in ms"
695
- })
696
- );
697
-
698
- // packages/utils/src/lib/execute-process.ts
699
- import {
700
- spawn
701
- } from "node:child_process";
702
-
703
- // packages/utils/src/lib/reports/utils.ts
704
- import ansis from "ansis";
705
- import { md } from "build-md";
706
-
707
- // packages/utils/src/lib/reports/constants.ts
708
- var TERMINAL_WIDTH = 80;
709
-
710
- // packages/utils/src/lib/reports/utils.ts
711
- function calcDuration(start, stop) {
712
- return Math.round((stop ?? performance.now()) - start);
713
- }
714
- function compareIssueSeverity(severity1, severity2) {
715
- const levels = {
716
- info: 0,
717
- warning: 1,
718
- error: 2
719
- };
720
- return levels[severity1] - levels[severity2];
721
- }
722
-
723
- // packages/utils/src/lib/execute-process.ts
724
- var ProcessError = class extends Error {
725
- code;
726
- stderr;
727
- stdout;
728
- constructor(result) {
729
- super(result.stderr);
730
- this.code = result.code;
731
- this.stderr = result.stderr;
732
- this.stdout = result.stdout;
733
- }
734
- };
735
- function executeProcess(cfg) {
736
- const { command, args, observer, ignoreExitCode = false, ...options } = cfg;
737
- const { onStdout, onStderr, onError, onComplete } = observer ?? {};
738
- const date = (/* @__PURE__ */ new Date()).toISOString();
739
- const start = performance.now();
740
- return new Promise((resolve, reject) => {
741
- const spawnedProcess = spawn(command, args ?? [], {
742
- shell: true,
743
- windowsHide: true,
744
- ...options
745
- });
746
- let stdout = "";
747
- let stderr = "";
748
- spawnedProcess.stdout.on("data", (data) => {
749
- stdout += String(data);
750
- onStdout?.(String(data), spawnedProcess);
751
- });
752
- spawnedProcess.stderr.on("data", (data) => {
753
- stderr += String(data);
754
- onStderr?.(String(data), spawnedProcess);
755
- });
756
- spawnedProcess.on("error", (err) => {
757
- stderr += err.toString();
758
- });
759
- spawnedProcess.on("close", (code2) => {
760
- const timings = { date, duration: calcDuration(start) };
761
- if (code2 === 0 || ignoreExitCode) {
762
- onComplete?.();
763
- resolve({ code: code2, stdout, stderr, ...timings });
764
- } else {
765
- const errorMsg = new ProcessError({ code: code2, stdout, stderr, ...timings });
766
- onError?.(errorMsg);
767
- reject(errorMsg);
768
- }
769
- });
770
- });
771
- }
772
-
773
- // packages/utils/src/lib/file-system.ts
774
- import { bold, gray } from "ansis";
775
- import { bundleRequire } from "bundle-require";
776
- import { mkdir, readFile, readdir, rm, stat } from "node:fs/promises";
777
- import { dirname, join } from "node:path";
778
-
779
- // packages/utils/src/lib/formatting.ts
780
- function slugify(text) {
781
- return text.trim().toLowerCase().replace(/\s+|\//g, "-").replace(/[^a-z\d-]/g, "");
782
- }
783
- function pluralize(text, amount) {
784
- if (amount != null && Math.abs(amount) === 1) {
785
- return text;
786
- }
787
- if (text.endsWith("y")) {
788
- return `${text.slice(0, -1)}ies`;
789
- }
790
- if (text.endsWith("s")) {
791
- return `${text}es`;
792
- }
793
- return `${text}s`;
794
- }
795
- function pluralizeToken(token, times) {
796
- return `${times} ${Math.abs(times) === 1 ? token : pluralize(token)}`;
797
- }
798
- function truncateText(text, options) {
799
- const {
800
- maxChars,
801
- position = "end",
802
- ellipsis = "..."
803
- } = typeof options === "number" ? { maxChars: options } : options;
804
- if (text.length <= maxChars) {
805
- return text;
806
- }
807
- const maxLength = maxChars - ellipsis.length;
808
- switch (position) {
809
- case "start":
810
- return ellipsis + text.slice(-maxLength).trim();
811
- case "middle":
812
- const halfMaxChars = Math.floor(maxLength / 2);
813
- return text.slice(0, halfMaxChars).trim() + ellipsis + text.slice(-halfMaxChars).trim();
814
- case "end":
815
- return text.slice(0, maxLength).trim() + ellipsis;
816
- }
817
- }
818
- function truncateIssueMessage(text) {
819
- return truncateText(text, MAX_ISSUE_MESSAGE_LENGTH);
820
- }
821
-
822
- // packages/utils/src/lib/logging.ts
823
- import isaacs_cliui from "@isaacs/cliui";
824
- import { cliui } from "@poppinss/cliui";
825
- import { underline } from "ansis";
826
- var singletonUiInstance;
827
- function ui() {
828
- if (singletonUiInstance === void 0) {
829
- singletonUiInstance = cliui();
830
- }
831
- return {
832
- ...singletonUiInstance,
833
- row: (args) => {
834
- logListItem(args);
835
- }
836
- };
837
- }
838
- var singletonisaacUi;
839
- function logListItem(args) {
840
- if (singletonisaacUi === void 0) {
841
- singletonisaacUi = isaacs_cliui({ width: TERMINAL_WIDTH });
842
- }
843
- singletonisaacUi.div(...args);
844
- const content = singletonisaacUi.toString();
845
- singletonisaacUi.rows = [];
846
- singletonUiInstance?.logger.log(content);
847
- }
848
-
849
- // packages/utils/src/lib/file-system.ts
850
- async function readTextFile(path) {
851
- const buffer = await readFile(path);
852
- return buffer.toString();
853
- }
854
- async function readJsonFile(path) {
855
- const text = await readTextFile(path);
856
- return JSON.parse(text);
857
- }
858
- async function ensureDirectoryExists(baseDir) {
859
- try {
860
- await mkdir(baseDir, { recursive: true });
861
- return;
862
- } catch (error) {
863
- ui().logger.info(error.message);
864
- if (error.code !== "EEXIST") {
865
- throw error;
866
- }
867
- }
868
- }
869
- function pluginWorkDir(slug) {
870
- return join("node_modules", ".code-pushup", slug);
871
- }
872
- function filePathToCliArg(path) {
873
- return `"${path}"`;
874
- }
875
-
876
- // packages/utils/src/lib/git/git.ts
877
- import { simpleGit } from "simple-git";
878
-
879
- // packages/utils/src/lib/transform.ts
880
- function toArray(val) {
881
- return Array.isArray(val) ? val : [val];
882
- }
883
- function objectToEntries(obj) {
884
- return Object.entries(obj);
885
- }
886
- function countOccurrences(values) {
887
- return values.reduce(
888
- (acc, value) => ({ ...acc, [value]: (acc[value] ?? 0) + 1 }),
889
- {}
890
- );
891
- }
892
- function distinct(array) {
893
- return [...new Set(array)];
894
- }
895
-
896
- // packages/utils/src/lib/git/git.commits-and-tags.ts
897
- import { simpleGit as simpleGit2 } from "simple-git";
898
-
899
- // packages/utils/src/lib/semver.ts
900
- import { rcompare, valid } from "semver";
901
-
902
- // packages/utils/src/lib/progress.ts
903
- import { black, bold as bold2, gray as gray2, green } from "ansis";
904
- import { MultiProgressBars } from "multi-progress-bars";
905
-
906
- // packages/utils/src/lib/reports/generate-md-report.ts
907
- import { MarkdownDocument as MarkdownDocument3, md as md4 } from "build-md";
908
-
909
- // packages/utils/src/lib/reports/formatting.ts
910
- import {
911
- MarkdownDocument,
912
- md as md2
913
- } from "build-md";
914
-
915
- // packages/utils/src/lib/reports/generate-md-report-categoy-section.ts
916
- import { MarkdownDocument as MarkdownDocument2, md as md3 } from "build-md";
917
-
918
- // packages/utils/src/lib/reports/generate-md-reports-diff.ts
919
- import {
920
- MarkdownDocument as MarkdownDocument5,
921
- md as md6
922
- } from "build-md";
923
-
924
- // packages/utils/src/lib/reports/generate-md-reports-diff-utils.ts
925
- import { MarkdownDocument as MarkdownDocument4, md as md5 } from "build-md";
926
-
927
- // packages/utils/src/lib/reports/log-stdout-summary.ts
928
- import { bold as bold4, cyan, cyanBright, green as green2, red } from "ansis";
929
-
930
- // packages/plugin-eslint/src/lib/runner/lint.ts
931
- import { platform } from "node:os";
932
-
933
- // packages/plugin-eslint/src/lib/setup.ts
934
- import { ESLint } from "eslint";
935
- async function setupESLint(eslintrc) {
936
- const eslintConstructor = await loadESLint();
937
- return new eslintConstructor({
938
- overrideConfigFile: eslintrc,
939
- errorOnUnmatchedPattern: false
940
- });
941
- }
942
- async function loadESLint() {
943
- const eslint = await import("eslint");
944
- if ("loadESLint" in eslint && typeof eslint.loadESLint === "function") {
945
- return await eslint.loadESLint();
946
- }
947
- return ESLint;
948
- }
949
-
950
- // packages/plugin-eslint/src/lib/runner/lint.ts
951
- async function lint({
952
- eslintrc,
953
- patterns
954
- }) {
955
- const results = await executeLint({ eslintrc, patterns });
956
- const eslint = await setupESLint(eslintrc);
957
- const ruleOptionsPerFile = await loadRuleOptionsPerFile(eslint, results);
958
- return { results, ruleOptionsPerFile };
959
- }
960
- async function executeLint({
961
- eslintrc,
962
- patterns
963
- }) {
964
- const { stdout } = await executeProcess({
965
- command: "npx",
966
- args: [
967
- "eslint",
968
- ...eslintrc ? [`--config=${filePathToCliArg(eslintrc)}`] : [],
969
- ...typeof eslintrc === "object" ? ["--no-eslintrc"] : [],
970
- "--no-error-on-unmatched-pattern",
971
- "--format=json",
972
- ...toArray(patterns).map(
973
- (pattern) => (
974
- // globs need to be escaped on Unix
975
- platform() === "win32" ? pattern : `'${pattern}'`
976
- )
977
- )
978
- ],
979
- ignoreExitCode: true,
980
- cwd: process.cwd()
981
- });
982
- return JSON.parse(stdout);
983
- }
984
- function loadRuleOptionsPerFile(eslint, results) {
985
- return results.reduce(async (acc, { filePath, messages }) => {
986
- const filesMap = await acc;
987
- const config = await eslint.calculateConfigForFile(
988
- filePath
989
- );
990
- const ruleIds = distinct(
991
- messages.map(({ ruleId }) => ruleId).filter((ruleId) => ruleId != null)
992
- );
993
- const rulesMap = Object.fromEntries(
994
- ruleIds.map((ruleId) => [
995
- ruleId,
996
- toArray(config.rules?.[ruleId] ?? []).slice(1)
997
- ])
998
- );
999
- return {
1000
- ...filesMap,
1001
- [filePath]: {
1002
- ...filesMap[filePath],
1003
- ...rulesMap
1004
- }
1005
- };
1006
- }, Promise.resolve({}));
1007
- }
1008
-
1009
- // packages/plugin-eslint/src/lib/meta/hash.ts
1010
- import { createHash } from "node:crypto";
1011
- function ruleIdToSlug(ruleId, options) {
1012
- const slug = slugify(ruleId);
1013
- if (!options?.length) {
1014
- return slug;
1015
- }
1016
- return `${slug}-${jsonHash(options)}`;
1017
- }
1018
- function jsonHash(data, bytes = 8) {
1019
- return createHash("shake256", { outputLength: bytes }).update(JSON.stringify(data) || "null").digest("hex");
1020
- }
1021
-
1022
- // packages/plugin-eslint/src/lib/runner/transform.ts
1023
- function mergeLinterOutputs(outputs) {
1024
- return outputs.reduce(
1025
- (acc, { results, ruleOptionsPerFile }) => ({
1026
- results: [...acc.results, ...results],
1027
- ruleOptionsPerFile: { ...acc.ruleOptionsPerFile, ...ruleOptionsPerFile }
1028
- }),
1029
- { results: [], ruleOptionsPerFile: {} }
1030
- );
1031
- }
1032
- function lintResultsToAudits({
1033
- results,
1034
- ruleOptionsPerFile
1035
- }) {
1036
- const issuesPerAudit = results.flatMap(
1037
- ({ messages, filePath }) => messages.map((message) => ({ ...message, filePath }))
1038
- ).reduce((acc, issue) => {
1039
- const { ruleId, message, filePath } = issue;
1040
- if (!ruleId) {
1041
- ui().logger.warning(
1042
- `ESLint core error - ${message} (file: ${filePath})`
1043
- );
1044
- return acc;
1045
- }
1046
- const options = ruleOptionsPerFile[filePath]?.[ruleId] ?? [];
1047
- const auditSlug = ruleIdToSlug(ruleId, options);
1048
- return { ...acc, [auditSlug]: [...acc[auditSlug] ?? [], issue] };
1049
- }, {});
1050
- return Object.entries(issuesPerAudit).map((entry) => toAudit(...entry));
1051
- }
1052
- function toAudit(slug, issues) {
1053
- const auditIssues = issues.map(convertIssue);
1054
- const severityCounts = countOccurrences(
1055
- auditIssues.map(({ severity }) => severity)
1056
- );
1057
- const severities = objectToEntries(severityCounts);
1058
- const summaryText = severities.toSorted((a, b) => -compareIssueSeverity(a[0], b[0])).map(([severity, count = 0]) => pluralizeToken(severity, count)).join(", ");
1059
- return {
1060
- slug,
1061
- score: Number(auditIssues.length === 0),
1062
- value: auditIssues.length,
1063
- displayValue: summaryText,
1064
- details: {
1065
- issues: auditIssues
1066
- }
1067
- };
1068
- }
1069
- function convertIssue(issue) {
1070
- return {
1071
- message: truncateIssueMessage(issue.message),
1072
- severity: convertSeverity(issue.severity),
1073
- source: {
1074
- file: issue.filePath,
1075
- ...issue.line > 0 && {
1076
- position: {
1077
- startLine: issue.line,
1078
- ...issue.column > 0 && { startColumn: issue.column },
1079
- ...issue.endLine && issue.endLine > 0 && {
1080
- endLine: issue.endLine
1081
- },
1082
- ...issue.endColumn && issue.endColumn > 0 && { endColumn: issue.endColumn }
1083
- }
1084
- }
1085
- }
1086
- };
1087
- }
1088
- function convertSeverity(severity) {
1089
- switch (severity) {
1090
- case 2:
1091
- return "error";
1092
- case 1:
1093
- return "warning";
1094
- case 0:
1095
- throw new Error(`Unexpected severity ${severity} in ESLint results`);
1096
- }
1097
- }
1098
-
1099
- // packages/plugin-eslint/src/lib/runner/index.ts
1100
- var WORKDIR = pluginWorkDir("eslint");
1101
- var RUNNER_OUTPUT_PATH = join2(WORKDIR, "runner-output.json");
1102
- var PLUGIN_CONFIG_PATH = join2(
1103
- process.cwd(),
1104
- WORKDIR,
1105
- "plugin-config.json"
1106
- );
1107
- async function executeRunner() {
1108
- const { slugs, targets } = await readJsonFile(PLUGIN_CONFIG_PATH);
1109
- const linterOutputs = await targets.reduce(
1110
- async (acc, target) => [...await acc, await lint(target)],
1111
- Promise.resolve([])
1112
- );
1113
- const lintResults = mergeLinterOutputs(linterOutputs);
1114
- const failedAudits = lintResultsToAudits(lintResults);
1115
- const audits = slugs.map(
1116
- (slug) => failedAudits.find((audit) => audit.slug === slug) ?? {
1117
- slug,
1118
- score: 1,
1119
- value: 0,
1120
- displayValue: "passed",
1121
- details: { issues: [] }
1122
- }
1123
- );
1124
- await ensureDirectoryExists(dirname2(RUNNER_OUTPUT_PATH));
1125
- await writeFile(RUNNER_OUTPUT_PATH, JSON.stringify(audits));
1126
- }
1127
-
1128
- // packages/plugin-eslint/src/bin.ts
1129
- await executeRunner();