@code-pushup/eslint-plugin 0.39.0 → 0.42.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.
- package/bin.js +434 -90
- package/index.js +436 -90
- package/package.json +4 -4
package/index.js
CHANGED
|
@@ -4,13 +4,291 @@ import { fileURLToPath } from "node:url";
|
|
|
4
4
|
|
|
5
5
|
// packages/plugin-eslint/package.json
|
|
6
6
|
var name = "@code-pushup/eslint-plugin";
|
|
7
|
-
var version = "0.
|
|
7
|
+
var version = "0.42.0";
|
|
8
8
|
|
|
9
9
|
// packages/plugin-eslint/src/lib/config.ts
|
|
10
|
-
import { z as
|
|
10
|
+
import { z as z16 } from "zod";
|
|
11
11
|
|
|
12
|
-
// packages/
|
|
13
|
-
|
|
12
|
+
// packages/utils/src/lib/text-formats/constants.ts
|
|
13
|
+
var NEW_LINE = "\n";
|
|
14
|
+
var TAB = " ";
|
|
15
|
+
|
|
16
|
+
// packages/utils/src/lib/text-formats/html/details.ts
|
|
17
|
+
function details(title, content, cfg = { open: false }) {
|
|
18
|
+
return `<details${cfg.open ? " open" : ""}>${NEW_LINE}<summary>${title}</summary>${NEW_LINE}${// ⚠️ The blank line is needed to ensure Markdown in content is rendered correctly.
|
|
19
|
+
NEW_LINE}${content}${NEW_LINE}${// @TODO in the future we could consider adding it only if the content ends with a code block
|
|
20
|
+
// ⚠️ The blank line ensure Markdown in content is rendered correctly.
|
|
21
|
+
NEW_LINE}</details>${// ⚠️ The blank line is needed to ensure Markdown after details is rendered correctly.
|
|
22
|
+
NEW_LINE}`;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// packages/utils/src/lib/text-formats/html/font-style.ts
|
|
26
|
+
var boldElement = "b";
|
|
27
|
+
function bold(text) {
|
|
28
|
+
return `<${boldElement}>${text}</${boldElement}>`;
|
|
29
|
+
}
|
|
30
|
+
var italicElement = "i";
|
|
31
|
+
function italic(text) {
|
|
32
|
+
return `<${italicElement}>${text}</${italicElement}>`;
|
|
33
|
+
}
|
|
34
|
+
var codeElement = "code";
|
|
35
|
+
function code(text) {
|
|
36
|
+
return `<${codeElement}>${text}</${codeElement}>`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// packages/utils/src/lib/text-formats/html/link.ts
|
|
40
|
+
function link(href, text) {
|
|
41
|
+
return `<a href="${href}">${text || href}"</a>`;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// packages/utils/src/lib/transform.ts
|
|
45
|
+
function toArray(val) {
|
|
46
|
+
return Array.isArray(val) ? val : [val];
|
|
47
|
+
}
|
|
48
|
+
function objectToKeys(obj) {
|
|
49
|
+
return Object.keys(obj);
|
|
50
|
+
}
|
|
51
|
+
function distinct(array) {
|
|
52
|
+
return [...new Set(array)];
|
|
53
|
+
}
|
|
54
|
+
function capitalize(text) {
|
|
55
|
+
return `${text.charAt(0).toLocaleUpperCase()}${text.slice(
|
|
56
|
+
1
|
|
57
|
+
)}`;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// packages/utils/src/lib/table.ts
|
|
61
|
+
function rowToStringArray({ rows, columns = [] }) {
|
|
62
|
+
if (Array.isArray(rows.at(0)) && typeof columns.at(0) === "object") {
|
|
63
|
+
throw new TypeError(
|
|
64
|
+
"Column can`t be object when rows are primitive values"
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
return rows.map((row) => {
|
|
68
|
+
if (Array.isArray(row)) {
|
|
69
|
+
return row.map(String);
|
|
70
|
+
}
|
|
71
|
+
const objectRow = row;
|
|
72
|
+
if (columns.length === 0 || typeof columns.at(0) === "string") {
|
|
73
|
+
return Object.values(objectRow).map(String);
|
|
74
|
+
}
|
|
75
|
+
return columns.map(
|
|
76
|
+
({ key }) => String(objectRow[key])
|
|
77
|
+
);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
function columnsToStringArray({ rows, columns = [] }) {
|
|
81
|
+
const firstRow = rows.at(0);
|
|
82
|
+
const primitiveRows = Array.isArray(firstRow);
|
|
83
|
+
if (typeof columns.at(0) === "string" && !primitiveRows) {
|
|
84
|
+
throw new Error("invalid union type. Caught by model parsing.");
|
|
85
|
+
}
|
|
86
|
+
if (columns.length === 0) {
|
|
87
|
+
if (Array.isArray(firstRow)) {
|
|
88
|
+
return firstRow.map((_, idx) => String(idx));
|
|
89
|
+
}
|
|
90
|
+
return Object.keys(firstRow);
|
|
91
|
+
}
|
|
92
|
+
if (typeof columns.at(0) === "string") {
|
|
93
|
+
return columns.map(String);
|
|
94
|
+
}
|
|
95
|
+
const cols = columns;
|
|
96
|
+
return cols.map(({ label, key }) => label ?? capitalize(key));
|
|
97
|
+
}
|
|
98
|
+
function getColumnAlignmentForKeyAndIndex(targetKey, targetIdx, columns = []) {
|
|
99
|
+
const column = columns.at(targetIdx) ?? columns.find((col) => col.key === targetKey);
|
|
100
|
+
if (typeof column === "string") {
|
|
101
|
+
return column;
|
|
102
|
+
} else if (typeof column === "object") {
|
|
103
|
+
return column.align ?? "center";
|
|
104
|
+
} else {
|
|
105
|
+
return "center";
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function getColumnAlignmentForIndex(targetIdx, columns = []) {
|
|
109
|
+
const column = columns.at(targetIdx);
|
|
110
|
+
if (column == null) {
|
|
111
|
+
return "center";
|
|
112
|
+
} else if (typeof column === "string") {
|
|
113
|
+
return column;
|
|
114
|
+
} else if (typeof column === "object") {
|
|
115
|
+
return column.align ?? "center";
|
|
116
|
+
} else {
|
|
117
|
+
return "center";
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function getColumnAlignments({
|
|
121
|
+
rows,
|
|
122
|
+
columns = []
|
|
123
|
+
}) {
|
|
124
|
+
if (rows.at(0) == null) {
|
|
125
|
+
throw new Error("first row can`t be undefined.");
|
|
126
|
+
}
|
|
127
|
+
if (Array.isArray(rows.at(0))) {
|
|
128
|
+
const firstPrimitiveRow = rows.at(0);
|
|
129
|
+
return Array.from({ length: firstPrimitiveRow.length }).map(
|
|
130
|
+
(_, idx) => getColumnAlignmentForIndex(idx, columns)
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
const firstObject = rows.at(0);
|
|
134
|
+
return Object.keys(firstObject).map(
|
|
135
|
+
(key, idx) => getColumnAlignmentForKeyAndIndex(key, idx, columns)
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// packages/utils/src/lib/text-formats/html/table.ts
|
|
140
|
+
function wrap(elem, content) {
|
|
141
|
+
return `<${elem}>${content}</${elem}>${NEW_LINE}`;
|
|
142
|
+
}
|
|
143
|
+
function wrapRow(content) {
|
|
144
|
+
const elem = "tr";
|
|
145
|
+
return `<${elem}>${NEW_LINE}${content}</${elem}>${NEW_LINE}`;
|
|
146
|
+
}
|
|
147
|
+
function table(tableData) {
|
|
148
|
+
if (tableData.rows.length === 0) {
|
|
149
|
+
throw new Error("Data can't be empty");
|
|
150
|
+
}
|
|
151
|
+
const tableHeaderCols = columnsToStringArray(tableData).map((s) => wrap("th", s)).join("");
|
|
152
|
+
const tableHeaderRow = wrapRow(tableHeaderCols);
|
|
153
|
+
const tableBody = rowToStringArray(tableData).map((arr) => {
|
|
154
|
+
const columns = arr.map((s) => wrap("td", s)).join("");
|
|
155
|
+
return wrapRow(columns);
|
|
156
|
+
}).join("");
|
|
157
|
+
return wrap("table", `${NEW_LINE}${tableHeaderRow}${tableBody}`);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// packages/utils/src/lib/text-formats/md/font-style.ts
|
|
161
|
+
var boldWrap = "**";
|
|
162
|
+
function bold2(text) {
|
|
163
|
+
return `${boldWrap}${text}${boldWrap}`;
|
|
164
|
+
}
|
|
165
|
+
var italicWrap = "_";
|
|
166
|
+
function italic2(text) {
|
|
167
|
+
return `${italicWrap}${text}${italicWrap}`;
|
|
168
|
+
}
|
|
169
|
+
var strikeThroughWrap = "~";
|
|
170
|
+
function strikeThrough(text) {
|
|
171
|
+
return `${strikeThroughWrap}${text}${strikeThroughWrap}`;
|
|
172
|
+
}
|
|
173
|
+
var codeWrap = "`";
|
|
174
|
+
function code2(text) {
|
|
175
|
+
return `${codeWrap}${text}${codeWrap}`;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// packages/utils/src/lib/text-formats/md/headline.ts
|
|
179
|
+
function headline(text, hierarchy = 1) {
|
|
180
|
+
return `${"#".repeat(hierarchy)} ${text}${NEW_LINE}`;
|
|
181
|
+
}
|
|
182
|
+
function h(text, hierarchy = 1) {
|
|
183
|
+
return headline(text, hierarchy);
|
|
184
|
+
}
|
|
185
|
+
function h1(text) {
|
|
186
|
+
return headline(text, 1);
|
|
187
|
+
}
|
|
188
|
+
function h2(text) {
|
|
189
|
+
return headline(text, 2);
|
|
190
|
+
}
|
|
191
|
+
function h3(text) {
|
|
192
|
+
return headline(text, 3);
|
|
193
|
+
}
|
|
194
|
+
function h4(text) {
|
|
195
|
+
return headline(text, 4);
|
|
196
|
+
}
|
|
197
|
+
function h5(text) {
|
|
198
|
+
return headline(text, 5);
|
|
199
|
+
}
|
|
200
|
+
function h6(text) {
|
|
201
|
+
return headline(text, 6);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// packages/utils/src/lib/text-formats/md/image.ts
|
|
205
|
+
function image(src, alt) {
|
|
206
|
+
return ``;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// packages/utils/src/lib/text-formats/md/link.ts
|
|
210
|
+
function link2(href, text) {
|
|
211
|
+
return `[${text || href}](${href})`;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// packages/utils/src/lib/text-formats/md/list.ts
|
|
215
|
+
function li(text, order = "unordered") {
|
|
216
|
+
const style = order === "unordered" ? "-" : "- [ ]";
|
|
217
|
+
return `${style} ${text}`;
|
|
218
|
+
}
|
|
219
|
+
function indentation(text, level = 1) {
|
|
220
|
+
return `${TAB.repeat(level)}${text}`;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// packages/utils/src/lib/text-formats/md/paragraphs.ts
|
|
224
|
+
function paragraphs(...sections) {
|
|
225
|
+
return sections.filter(Boolean).join(`${NEW_LINE}${NEW_LINE}`);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// packages/utils/src/lib/text-formats/md/section.ts
|
|
229
|
+
function section(...contents) {
|
|
230
|
+
return `${lines(...contents)}${NEW_LINE}`;
|
|
231
|
+
}
|
|
232
|
+
function lines(...contents) {
|
|
233
|
+
return `${contents.filter(Boolean).join(NEW_LINE)}`;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// packages/utils/src/lib/text-formats/md/table.ts
|
|
237
|
+
var alignString = /* @__PURE__ */ new Map([
|
|
238
|
+
["left", ":--"],
|
|
239
|
+
["center", ":--:"],
|
|
240
|
+
["right", "--:"]
|
|
241
|
+
]);
|
|
242
|
+
function tableRow(rows) {
|
|
243
|
+
return `|${rows.join("|")}|`;
|
|
244
|
+
}
|
|
245
|
+
function table2(data) {
|
|
246
|
+
if (data.rows.length === 0) {
|
|
247
|
+
throw new Error("Data can't be empty");
|
|
248
|
+
}
|
|
249
|
+
const alignmentRow = getColumnAlignments(data).map(
|
|
250
|
+
(s) => alignString.get(s) ?? String(alignString.get("center"))
|
|
251
|
+
);
|
|
252
|
+
return section(
|
|
253
|
+
`${lines(
|
|
254
|
+
tableRow(columnsToStringArray(data)),
|
|
255
|
+
tableRow(alignmentRow),
|
|
256
|
+
...rowToStringArray(data).map(tableRow)
|
|
257
|
+
)}`
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// packages/utils/src/lib/text-formats/index.ts
|
|
262
|
+
var md = {
|
|
263
|
+
bold: bold2,
|
|
264
|
+
italic: italic2,
|
|
265
|
+
strikeThrough,
|
|
266
|
+
code: code2,
|
|
267
|
+
link: link2,
|
|
268
|
+
image,
|
|
269
|
+
headline,
|
|
270
|
+
h,
|
|
271
|
+
h1,
|
|
272
|
+
h2,
|
|
273
|
+
h3,
|
|
274
|
+
h4,
|
|
275
|
+
h5,
|
|
276
|
+
h6,
|
|
277
|
+
indentation,
|
|
278
|
+
lines,
|
|
279
|
+
li,
|
|
280
|
+
section,
|
|
281
|
+
paragraphs,
|
|
282
|
+
table: table2
|
|
283
|
+
};
|
|
284
|
+
var html = {
|
|
285
|
+
bold,
|
|
286
|
+
italic,
|
|
287
|
+
code,
|
|
288
|
+
link,
|
|
289
|
+
details,
|
|
290
|
+
table
|
|
291
|
+
};
|
|
14
292
|
|
|
15
293
|
// packages/models/src/lib/implementation/schemas.ts
|
|
16
294
|
import { MATERIAL_ICONS } from "vscode-material-icons";
|
|
@@ -77,6 +355,7 @@ function missingRefsForCategoriesErrorMsg(categories, plugins) {
|
|
|
77
355
|
}
|
|
78
356
|
|
|
79
357
|
// packages/models/src/lib/implementation/schemas.ts
|
|
358
|
+
var primitiveValueSchema = z.union([z.string(), z.number()]);
|
|
80
359
|
function executionMetaSchema(options = {
|
|
81
360
|
descriptionDate: "Execution start date and time",
|
|
82
361
|
descriptionDuration: "Execution duration in ms"
|
|
@@ -168,6 +447,7 @@ function hasNonZeroWeightedRef(refs) {
|
|
|
168
447
|
}
|
|
169
448
|
|
|
170
449
|
// packages/models/src/lib/audit.ts
|
|
450
|
+
import { z as z2 } from "zod";
|
|
171
451
|
var auditSchema = z2.object({
|
|
172
452
|
slug: slugSchema.describe("ID (unique within plugin)")
|
|
173
453
|
}).merge(
|
|
@@ -197,7 +477,7 @@ function getDuplicateSlugsInAudits(audits) {
|
|
|
197
477
|
}
|
|
198
478
|
|
|
199
479
|
// packages/models/src/lib/audit-output.ts
|
|
200
|
-
import { z as
|
|
480
|
+
import { z as z5 } from "zod";
|
|
201
481
|
|
|
202
482
|
// packages/models/src/lib/issue.ts
|
|
203
483
|
import { z as z3 } from "zod";
|
|
@@ -228,16 +508,61 @@ var issueSchema = z3.object(
|
|
|
228
508
|
{ description: "Issue information" }
|
|
229
509
|
);
|
|
230
510
|
|
|
511
|
+
// packages/models/src/lib/table.ts
|
|
512
|
+
import { z as z4 } from "zod";
|
|
513
|
+
var tableAlignmentSchema = z4.enum(["left", "center", "right"], {
|
|
514
|
+
description: "Cell alignment"
|
|
515
|
+
});
|
|
516
|
+
var tableColumnObjectSchema = z4.object({
|
|
517
|
+
key: z4.string(),
|
|
518
|
+
label: z4.string().optional(),
|
|
519
|
+
align: tableAlignmentSchema.optional()
|
|
520
|
+
});
|
|
521
|
+
var tableRowObjectSchema = z4.record(primitiveValueSchema, {
|
|
522
|
+
description: "Object row"
|
|
523
|
+
});
|
|
524
|
+
var tableRowPrimitiveSchema = z4.array(primitiveValueSchema, {
|
|
525
|
+
description: "Primitive row"
|
|
526
|
+
});
|
|
527
|
+
var tableSharedSchema = z4.object({
|
|
528
|
+
title: z4.string().optional().describe("Display title for table")
|
|
529
|
+
});
|
|
530
|
+
var tablePrimitiveSchema = tableSharedSchema.merge(
|
|
531
|
+
z4.object(
|
|
532
|
+
{
|
|
533
|
+
columns: z4.array(tableAlignmentSchema).optional(),
|
|
534
|
+
rows: z4.array(tableRowPrimitiveSchema)
|
|
535
|
+
},
|
|
536
|
+
{ description: "Table with primitive rows and optional alignment columns" }
|
|
537
|
+
)
|
|
538
|
+
);
|
|
539
|
+
var tableObjectSchema = tableSharedSchema.merge(
|
|
540
|
+
z4.object(
|
|
541
|
+
{
|
|
542
|
+
columns: z4.union([
|
|
543
|
+
z4.array(tableAlignmentSchema),
|
|
544
|
+
z4.array(tableColumnObjectSchema)
|
|
545
|
+
]).optional(),
|
|
546
|
+
rows: z4.array(tableRowObjectSchema)
|
|
547
|
+
},
|
|
548
|
+
{
|
|
549
|
+
description: "Table with object rows and optional alignment or object columns"
|
|
550
|
+
}
|
|
551
|
+
)
|
|
552
|
+
);
|
|
553
|
+
var tableSchema = (description = "Table information") => z4.union([tablePrimitiveSchema, tableObjectSchema], { description });
|
|
554
|
+
|
|
231
555
|
// packages/models/src/lib/audit-output.ts
|
|
232
556
|
var auditValueSchema = nonnegativeIntSchema.describe("Raw numeric value");
|
|
233
|
-
var auditDisplayValueSchema =
|
|
234
|
-
var auditDetailsSchema =
|
|
557
|
+
var auditDisplayValueSchema = z5.string({ description: "Formatted value (e.g. '0.9 s', '2.1 MB')" }).optional();
|
|
558
|
+
var auditDetailsSchema = z5.object(
|
|
235
559
|
{
|
|
236
|
-
issues:
|
|
560
|
+
issues: z5.array(issueSchema, { description: "List of findings" }).optional(),
|
|
561
|
+
table: tableSchema("Table of related findings").optional()
|
|
237
562
|
},
|
|
238
563
|
{ description: "Detailed information" }
|
|
239
564
|
);
|
|
240
|
-
var auditOutputSchema =
|
|
565
|
+
var auditOutputSchema = z5.object(
|
|
241
566
|
{
|
|
242
567
|
slug: slugSchema.describe("Reference to audit"),
|
|
243
568
|
displayValue: auditDisplayValueSchema,
|
|
@@ -247,7 +572,7 @@ var auditOutputSchema = z4.object(
|
|
|
247
572
|
},
|
|
248
573
|
{ description: "Audit information" }
|
|
249
574
|
);
|
|
250
|
-
var auditOutputsSchema =
|
|
575
|
+
var auditOutputsSchema = z5.array(auditOutputSchema, {
|
|
251
576
|
description: "List of JSON formatted audit output emitted by the runner process of a plugin"
|
|
252
577
|
}).refine(
|
|
253
578
|
(audits) => !getDuplicateSlugsInAudits2(audits),
|
|
@@ -264,13 +589,13 @@ function getDuplicateSlugsInAudits2(audits) {
|
|
|
264
589
|
}
|
|
265
590
|
|
|
266
591
|
// packages/models/src/lib/category-config.ts
|
|
267
|
-
import { z as
|
|
592
|
+
import { z as z6 } from "zod";
|
|
268
593
|
var categoryRefSchema = weightedRefSchema(
|
|
269
594
|
"Weighted references to audits and/or groups for the category",
|
|
270
595
|
"Slug of an audit or group (depending on `type`)"
|
|
271
596
|
).merge(
|
|
272
|
-
|
|
273
|
-
type:
|
|
597
|
+
z6.object({
|
|
598
|
+
type: z6.enum(["audit", "group"], {
|
|
274
599
|
description: "Discriminant for reference kind, affects where `slug` is looked up"
|
|
275
600
|
}),
|
|
276
601
|
plugin: slugSchema.describe(
|
|
@@ -291,8 +616,8 @@ var categoryConfigSchema = scorableSchema(
|
|
|
291
616
|
description: "Meta info for category"
|
|
292
617
|
})
|
|
293
618
|
).merge(
|
|
294
|
-
|
|
295
|
-
isBinary:
|
|
619
|
+
z6.object({
|
|
620
|
+
isBinary: z6.boolean({
|
|
296
621
|
description: 'Is this a binary category (i.e. only a perfect score considered a "pass")?'
|
|
297
622
|
}).optional()
|
|
298
623
|
})
|
|
@@ -308,7 +633,7 @@ function getDuplicateRefsInCategoryMetrics(metrics) {
|
|
|
308
633
|
metrics.map(({ slug, type, plugin }) => `${type} :: ${plugin} / ${slug}`)
|
|
309
634
|
);
|
|
310
635
|
}
|
|
311
|
-
var categoriesSchema =
|
|
636
|
+
var categoriesSchema = z6.array(categoryConfigSchema, {
|
|
312
637
|
description: "Categorization of individual audits"
|
|
313
638
|
}).refine(
|
|
314
639
|
(categoryCfg) => !getDuplicateSlugCategories(categoryCfg),
|
|
@@ -327,18 +652,18 @@ function getDuplicateSlugCategories(categories) {
|
|
|
327
652
|
}
|
|
328
653
|
|
|
329
654
|
// packages/models/src/lib/commit.ts
|
|
330
|
-
import { z as
|
|
331
|
-
var commitSchema =
|
|
655
|
+
import { z as z7 } from "zod";
|
|
656
|
+
var commitSchema = z7.object(
|
|
332
657
|
{
|
|
333
|
-
hash:
|
|
658
|
+
hash: z7.string({ description: "Commit SHA (full)" }).regex(
|
|
334
659
|
/^[\da-f]{40}$/,
|
|
335
660
|
"Commit SHA should be a 40-character hexadecimal string"
|
|
336
661
|
),
|
|
337
|
-
message:
|
|
338
|
-
date:
|
|
662
|
+
message: z7.string({ description: "Commit message" }),
|
|
663
|
+
date: z7.coerce.date({
|
|
339
664
|
description: "Date and time when commit was authored"
|
|
340
665
|
}),
|
|
341
|
-
author:
|
|
666
|
+
author: z7.string({
|
|
342
667
|
description: "Commit author name"
|
|
343
668
|
}).trim()
|
|
344
669
|
},
|
|
@@ -346,22 +671,22 @@ var commitSchema = z6.object(
|
|
|
346
671
|
);
|
|
347
672
|
|
|
348
673
|
// packages/models/src/lib/core-config.ts
|
|
349
|
-
import { z as
|
|
674
|
+
import { z as z13 } from "zod";
|
|
350
675
|
|
|
351
676
|
// packages/models/src/lib/persist-config.ts
|
|
352
|
-
import { z as
|
|
353
|
-
var formatSchema =
|
|
354
|
-
var persistConfigSchema =
|
|
677
|
+
import { z as z8 } from "zod";
|
|
678
|
+
var formatSchema = z8.enum(["json", "md"]);
|
|
679
|
+
var persistConfigSchema = z8.object({
|
|
355
680
|
outputDir: filePathSchema.describe("Artifacts folder").optional(),
|
|
356
681
|
filename: fileNameSchema.describe("Artifacts file name (without extension)").optional(),
|
|
357
|
-
format:
|
|
682
|
+
format: z8.array(formatSchema).optional()
|
|
358
683
|
});
|
|
359
684
|
|
|
360
685
|
// packages/models/src/lib/plugin-config.ts
|
|
361
|
-
import { z as
|
|
686
|
+
import { z as z11 } from "zod";
|
|
362
687
|
|
|
363
688
|
// packages/models/src/lib/group.ts
|
|
364
|
-
import { z as
|
|
689
|
+
import { z as z9 } from "zod";
|
|
365
690
|
var groupRefSchema = weightedRefSchema(
|
|
366
691
|
"Weighted reference to a group",
|
|
367
692
|
"Reference slug to a group within this plugin (e.g. 'max-lines')"
|
|
@@ -378,7 +703,7 @@ var groupSchema = scorableSchema(
|
|
|
378
703
|
getDuplicateRefsInGroups,
|
|
379
704
|
duplicateRefsInGroupsErrorMsg
|
|
380
705
|
).merge(groupMetaSchema);
|
|
381
|
-
var groupsSchema =
|
|
706
|
+
var groupsSchema = z9.array(groupSchema, {
|
|
382
707
|
description: "List of groups"
|
|
383
708
|
}).optional().refine(
|
|
384
709
|
(groups) => !getDuplicateSlugsInGroups(groups),
|
|
@@ -406,14 +731,14 @@ function getDuplicateSlugsInGroups(groups) {
|
|
|
406
731
|
}
|
|
407
732
|
|
|
408
733
|
// packages/models/src/lib/runner-config.ts
|
|
409
|
-
import { z as
|
|
410
|
-
var outputTransformSchema =
|
|
411
|
-
var runnerConfigSchema =
|
|
734
|
+
import { z as z10 } from "zod";
|
|
735
|
+
var outputTransformSchema = z10.function().args(z10.unknown()).returns(z10.union([auditOutputsSchema, z10.promise(auditOutputsSchema)]));
|
|
736
|
+
var runnerConfigSchema = z10.object(
|
|
412
737
|
{
|
|
413
|
-
command:
|
|
738
|
+
command: z10.string({
|
|
414
739
|
description: "Shell command to execute"
|
|
415
740
|
}),
|
|
416
|
-
args:
|
|
741
|
+
args: z10.array(z10.string({ description: "Command arguments" })).optional(),
|
|
417
742
|
outputFile: filePathSchema.describe("Output path"),
|
|
418
743
|
outputTransform: outputTransformSchema.optional()
|
|
419
744
|
},
|
|
@@ -421,8 +746,8 @@ var runnerConfigSchema = z9.object(
|
|
|
421
746
|
description: "How to execute runner"
|
|
422
747
|
}
|
|
423
748
|
);
|
|
424
|
-
var onProgressSchema =
|
|
425
|
-
var runnerFunctionSchema =
|
|
749
|
+
var onProgressSchema = z10.function().args(z10.unknown()).returns(z10.void());
|
|
750
|
+
var runnerFunctionSchema = z10.function().args(onProgressSchema.optional()).returns(z10.union([auditOutputsSchema, z10.promise(auditOutputsSchema)]));
|
|
426
751
|
|
|
427
752
|
// packages/models/src/lib/plugin-config.ts
|
|
428
753
|
var pluginMetaSchema = packageVersionSchema().merge(
|
|
@@ -433,13 +758,13 @@ var pluginMetaSchema = packageVersionSchema().merge(
|
|
|
433
758
|
description: "Plugin metadata"
|
|
434
759
|
})
|
|
435
760
|
).merge(
|
|
436
|
-
|
|
761
|
+
z11.object({
|
|
437
762
|
slug: slugSchema.describe("Unique plugin slug within core config"),
|
|
438
763
|
icon: materialIconSchema
|
|
439
764
|
})
|
|
440
765
|
);
|
|
441
|
-
var pluginDataSchema =
|
|
442
|
-
runner:
|
|
766
|
+
var pluginDataSchema = z11.object({
|
|
767
|
+
runner: z11.union([runnerConfigSchema, runnerFunctionSchema]),
|
|
443
768
|
audits: pluginAuditsSchema,
|
|
444
769
|
groups: groupsSchema
|
|
445
770
|
});
|
|
@@ -465,22 +790,22 @@ function getMissingRefsFromGroups(pluginCfg) {
|
|
|
465
790
|
}
|
|
466
791
|
|
|
467
792
|
// packages/models/src/lib/upload-config.ts
|
|
468
|
-
import { z as
|
|
469
|
-
var uploadConfigSchema =
|
|
793
|
+
import { z as z12 } from "zod";
|
|
794
|
+
var uploadConfigSchema = z12.object({
|
|
470
795
|
server: urlSchema.describe("URL of deployed portal API"),
|
|
471
|
-
apiKey:
|
|
796
|
+
apiKey: z12.string({
|
|
472
797
|
description: "API key with write access to portal (use `process.env` for security)"
|
|
473
798
|
}),
|
|
474
799
|
organization: slugSchema.describe(
|
|
475
800
|
"Organization slug from Code PushUp portal"
|
|
476
801
|
),
|
|
477
802
|
project: slugSchema.describe("Project slug from Code PushUp portal"),
|
|
478
|
-
timeout:
|
|
803
|
+
timeout: z12.number({ description: "Request timeout in minutes (default is 5)" }).positive().int().optional()
|
|
479
804
|
});
|
|
480
805
|
|
|
481
806
|
// packages/models/src/lib/core-config.ts
|
|
482
|
-
var unrefinedCoreConfigSchema =
|
|
483
|
-
plugins:
|
|
807
|
+
var unrefinedCoreConfigSchema = z13.object({
|
|
808
|
+
plugins: z13.array(pluginConfigSchema, {
|
|
484
809
|
description: "List of plugins to be used (official, community-provided, or custom)"
|
|
485
810
|
}).min(1),
|
|
486
811
|
/** portal configuration for persisting results */
|
|
@@ -503,7 +828,7 @@ function refineCoreConfig(schema) {
|
|
|
503
828
|
}
|
|
504
829
|
|
|
505
830
|
// packages/models/src/lib/report.ts
|
|
506
|
-
import { z as
|
|
831
|
+
import { z as z14 } from "zod";
|
|
507
832
|
var auditReportSchema = auditSchema.merge(auditOutputSchema);
|
|
508
833
|
var pluginReportSchema = pluginMetaSchema.merge(
|
|
509
834
|
executionMetaSchema({
|
|
@@ -511,9 +836,9 @@ var pluginReportSchema = pluginMetaSchema.merge(
|
|
|
511
836
|
descriptionDuration: "Duration of the plugin run in ms"
|
|
512
837
|
})
|
|
513
838
|
).merge(
|
|
514
|
-
|
|
515
|
-
audits:
|
|
516
|
-
groups:
|
|
839
|
+
z14.object({
|
|
840
|
+
audits: z14.array(auditReportSchema).min(1),
|
|
841
|
+
groups: z14.array(groupSchema).optional()
|
|
517
842
|
})
|
|
518
843
|
).refine(
|
|
519
844
|
(pluginReport) => !getMissingRefsFromGroups2(pluginReport.audits, pluginReport.groups ?? []),
|
|
@@ -547,10 +872,10 @@ var reportSchema = packageVersionSchema({
|
|
|
547
872
|
descriptionDuration: "Duration of the collect run in ms"
|
|
548
873
|
})
|
|
549
874
|
).merge(
|
|
550
|
-
|
|
875
|
+
z14.object(
|
|
551
876
|
{
|
|
552
|
-
categories:
|
|
553
|
-
plugins:
|
|
877
|
+
categories: z14.array(categoryConfigSchema),
|
|
878
|
+
plugins: z14.array(pluginReportSchema).min(1),
|
|
554
879
|
commit: commitSchema.describe("Git commit for which report was collected").nullable()
|
|
555
880
|
},
|
|
556
881
|
{ description: "Collect output data" }
|
|
@@ -566,40 +891,40 @@ var reportSchema = packageVersionSchema({
|
|
|
566
891
|
);
|
|
567
892
|
|
|
568
893
|
// packages/models/src/lib/reports-diff.ts
|
|
569
|
-
import { z as
|
|
894
|
+
import { z as z15 } from "zod";
|
|
570
895
|
function makeComparisonSchema(schema) {
|
|
571
896
|
const sharedDescription = schema.description || "Result";
|
|
572
|
-
return
|
|
897
|
+
return z15.object({
|
|
573
898
|
before: schema.describe(`${sharedDescription} (source commit)`),
|
|
574
899
|
after: schema.describe(`${sharedDescription} (target commit)`)
|
|
575
900
|
});
|
|
576
901
|
}
|
|
577
902
|
function makeArraysComparisonSchema(diffSchema, resultSchema, description) {
|
|
578
|
-
return
|
|
903
|
+
return z15.object(
|
|
579
904
|
{
|
|
580
|
-
changed:
|
|
581
|
-
unchanged:
|
|
582
|
-
added:
|
|
583
|
-
removed:
|
|
905
|
+
changed: z15.array(diffSchema),
|
|
906
|
+
unchanged: z15.array(resultSchema),
|
|
907
|
+
added: z15.array(resultSchema),
|
|
908
|
+
removed: z15.array(resultSchema)
|
|
584
909
|
},
|
|
585
910
|
{ description }
|
|
586
911
|
);
|
|
587
912
|
}
|
|
588
|
-
var scorableMetaSchema =
|
|
913
|
+
var scorableMetaSchema = z15.object({
|
|
589
914
|
slug: slugSchema,
|
|
590
915
|
title: titleSchema,
|
|
591
916
|
docsUrl: docsUrlSchema
|
|
592
917
|
});
|
|
593
918
|
var scorableWithPluginMetaSchema = scorableMetaSchema.merge(
|
|
594
|
-
|
|
919
|
+
z15.object({
|
|
595
920
|
plugin: pluginMetaSchema.pick({ slug: true, title: true, docsUrl: true }).describe("Plugin which defines it")
|
|
596
921
|
})
|
|
597
922
|
);
|
|
598
923
|
var scorableDiffSchema = scorableMetaSchema.merge(
|
|
599
|
-
|
|
924
|
+
z15.object({
|
|
600
925
|
scores: makeComparisonSchema(scoreSchema).merge(
|
|
601
|
-
|
|
602
|
-
diff:
|
|
926
|
+
z15.object({
|
|
927
|
+
diff: z15.number().min(-1).max(1).describe("Score change (`scores.after - scores.before`)")
|
|
603
928
|
})
|
|
604
929
|
).describe("Score comparison")
|
|
605
930
|
})
|
|
@@ -610,10 +935,10 @@ var scorableWithPluginDiffSchema = scorableDiffSchema.merge(
|
|
|
610
935
|
var categoryDiffSchema = scorableDiffSchema;
|
|
611
936
|
var groupDiffSchema = scorableWithPluginDiffSchema;
|
|
612
937
|
var auditDiffSchema = scorableWithPluginDiffSchema.merge(
|
|
613
|
-
|
|
938
|
+
z15.object({
|
|
614
939
|
values: makeComparisonSchema(auditValueSchema).merge(
|
|
615
|
-
|
|
616
|
-
diff:
|
|
940
|
+
z15.object({
|
|
941
|
+
diff: z15.number().int().describe("Value change (`values.after - values.before`)")
|
|
617
942
|
})
|
|
618
943
|
).describe("Audit `value` comparison"),
|
|
619
944
|
displayValues: makeComparisonSchema(auditDisplayValueSchema).describe(
|
|
@@ -622,15 +947,15 @@ var auditDiffSchema = scorableWithPluginDiffSchema.merge(
|
|
|
622
947
|
})
|
|
623
948
|
);
|
|
624
949
|
var categoryResultSchema = scorableMetaSchema.merge(
|
|
625
|
-
|
|
950
|
+
z15.object({ score: scoreSchema })
|
|
626
951
|
);
|
|
627
952
|
var groupResultSchema = scorableWithPluginMetaSchema.merge(
|
|
628
|
-
|
|
953
|
+
z15.object({ score: scoreSchema })
|
|
629
954
|
);
|
|
630
955
|
var auditResultSchema = scorableWithPluginMetaSchema.merge(
|
|
631
956
|
auditOutputSchema.pick({ score: true, value: true, displayValue: true })
|
|
632
957
|
);
|
|
633
|
-
var reportsDiffSchema =
|
|
958
|
+
var reportsDiffSchema = z15.object({
|
|
634
959
|
commits: makeComparisonSchema(commitSchema).nullable().describe("Commits identifying compared reports"),
|
|
635
960
|
categories: makeArraysComparisonSchema(
|
|
636
961
|
categoryDiffSchema,
|
|
@@ -739,43 +1064,64 @@ function pluginWorkDir(slug) {
|
|
|
739
1064
|
return join("node_modules", ".code-pushup", slug);
|
|
740
1065
|
}
|
|
741
1066
|
|
|
742
|
-
// packages/utils/src/lib/
|
|
1067
|
+
// packages/utils/src/lib/reports/utils.ts
|
|
1068
|
+
var { image: image2, bold: boldMd } = md;
|
|
1069
|
+
|
|
1070
|
+
// packages/utils/src/lib/git/git.ts
|
|
743
1071
|
import { simpleGit } from "simple-git";
|
|
744
1072
|
|
|
745
|
-
// packages/utils/src/lib/
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
return Object.keys(obj);
|
|
751
|
-
}
|
|
752
|
-
function distinct(array) {
|
|
753
|
-
return [...new Set(array)];
|
|
754
|
-
}
|
|
1073
|
+
// packages/utils/src/lib/git/git.commits-and-tags.ts
|
|
1074
|
+
import { simpleGit as simpleGit2 } from "simple-git";
|
|
1075
|
+
|
|
1076
|
+
// packages/utils/src/lib/semver.ts
|
|
1077
|
+
import { rcompare, valid } from "semver";
|
|
755
1078
|
|
|
756
1079
|
// packages/utils/src/lib/progress.ts
|
|
757
1080
|
import chalk3 from "chalk";
|
|
758
1081
|
import { MultiProgressBars } from "multi-progress-bars";
|
|
759
1082
|
|
|
1083
|
+
// packages/utils/src/lib/reports/formatting.ts
|
|
1084
|
+
var { headline: headline2, lines: lines2, link: link3, section: section2, table: table3 } = md;
|
|
1085
|
+
|
|
1086
|
+
// packages/utils/src/lib/reports/generate-md-report-categoy-section.ts
|
|
1087
|
+
var { link: link4, section: section3, h2: h22, lines: lines3, li: li2, bold: boldMd2, h3: h32, indentation: indentation2 } = md;
|
|
1088
|
+
|
|
1089
|
+
// packages/utils/src/lib/reports/generate-md-report.ts
|
|
1090
|
+
var { h1: h12, h2: h23, h3: h33, lines: lines4, link: link5, section: section4, code: codeMd } = md;
|
|
1091
|
+
var { bold: boldHtml, details: details2 } = html;
|
|
1092
|
+
|
|
1093
|
+
// packages/utils/src/lib/reports/generate-md-reports-diff.ts
|
|
1094
|
+
var {
|
|
1095
|
+
h1: h13,
|
|
1096
|
+
h2: h24,
|
|
1097
|
+
lines: lines5,
|
|
1098
|
+
link: link6,
|
|
1099
|
+
bold: boldMd3,
|
|
1100
|
+
italic: italicMd,
|
|
1101
|
+
table: table4,
|
|
1102
|
+
section: section5
|
|
1103
|
+
} = md;
|
|
1104
|
+
var { details: details3 } = html;
|
|
1105
|
+
|
|
760
1106
|
// packages/utils/src/lib/reports/log-stdout-summary.ts
|
|
761
1107
|
import chalk4 from "chalk";
|
|
762
1108
|
|
|
763
1109
|
// packages/plugin-eslint/src/lib/config.ts
|
|
764
|
-
var eslintTargetSchema =
|
|
765
|
-
eslintrc:
|
|
1110
|
+
var eslintTargetSchema = z16.object({
|
|
1111
|
+
eslintrc: z16.union(
|
|
766
1112
|
[
|
|
767
|
-
|
|
768
|
-
|
|
1113
|
+
z16.string({ description: "Path to ESLint config file" }),
|
|
1114
|
+
z16.record(z16.string(), z16.unknown(), {
|
|
769
1115
|
description: "ESLint config object"
|
|
770
1116
|
})
|
|
771
1117
|
],
|
|
772
1118
|
{ description: "ESLint config as file path or inline object" }
|
|
773
1119
|
),
|
|
774
|
-
patterns:
|
|
1120
|
+
patterns: z16.union([z16.string(), z16.array(z16.string()).min(1)], {
|
|
775
1121
|
description: "Lint target files. May contain file paths, directory paths or glob patterns"
|
|
776
1122
|
})
|
|
777
1123
|
});
|
|
778
|
-
var eslintPluginConfigSchema =
|
|
1124
|
+
var eslintPluginConfigSchema = z16.union([eslintTargetSchema, z16.array(eslintTargetSchema).min(1)]).transform(toArray);
|
|
779
1125
|
|
|
780
1126
|
// packages/plugin-eslint/src/lib/meta/hash.ts
|
|
781
1127
|
import { createHash } from "node:crypto";
|
|
@@ -956,7 +1302,7 @@ function ruleToAudit({ ruleId, meta, options }) {
|
|
|
956
1302
|
const name2 = ruleId.split("/").at(-1) ?? ruleId;
|
|
957
1303
|
const plugin = name2 === ruleId ? null : ruleId.slice(0, ruleId.lastIndexOf("/"));
|
|
958
1304
|
const pluginContext = plugin ? `, from _${plugin}_ plugin` : "";
|
|
959
|
-
const
|
|
1305
|
+
const lines6 = [
|
|
960
1306
|
`ESLint rule **${name2}**${pluginContext}.`,
|
|
961
1307
|
...options?.length ? ["Custom options:"] : [],
|
|
962
1308
|
...options?.map(
|
|
@@ -966,7 +1312,7 @@ function ruleToAudit({ ruleId, meta, options }) {
|
|
|
966
1312
|
return {
|
|
967
1313
|
slug: ruleIdToSlug(ruleId, options),
|
|
968
1314
|
title: truncateTitle(meta.docs?.description ?? name2),
|
|
969
|
-
description: truncateDescription(
|
|
1315
|
+
description: truncateDescription(lines6.join("\n\n")),
|
|
970
1316
|
...meta.docs?.url && {
|
|
971
1317
|
docsUrl: meta.docs.url
|
|
972
1318
|
}
|