@code-pushup/eslint-plugin 0.44.4 → 0.45.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.
Files changed (3) hide show
  1. package/bin.js +357 -353
  2. package/index.js +950 -946
  3. package/package.json +3 -3
package/bin.js CHANGED
@@ -2,293 +2,6 @@
2
2
  import { writeFile as writeFile2 } from "node:fs/promises";
3
3
  import { dirname, join as join3 } from "node:path";
4
4
 
5
- // packages/utils/src/lib/text-formats/constants.ts
6
- var NEW_LINE = "\n";
7
- var TAB = " ";
8
-
9
- // packages/utils/src/lib/text-formats/html/details.ts
10
- function details(title, content, cfg = { open: false }) {
11
- 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.
12
- NEW_LINE}${content}${NEW_LINE}${// @TODO in the future we could consider adding it only if the content ends with a code block
13
- // ⚠️ The blank line ensure Markdown in content is rendered correctly.
14
- NEW_LINE}</details>${// ⚠️ The blank line is needed to ensure Markdown after details is rendered correctly.
15
- NEW_LINE}`;
16
- }
17
-
18
- // packages/utils/src/lib/text-formats/html/font-style.ts
19
- var boldElement = "b";
20
- function bold(text) {
21
- return `<${boldElement}>${text}</${boldElement}>`;
22
- }
23
- var italicElement = "i";
24
- function italic(text) {
25
- return `<${italicElement}>${text}</${italicElement}>`;
26
- }
27
- var codeElement = "code";
28
- function code(text) {
29
- return `<${codeElement}>${text}</${codeElement}>`;
30
- }
31
-
32
- // packages/utils/src/lib/text-formats/html/link.ts
33
- function link(href, text) {
34
- return `<a href="${href}">${text || href}"</a>`;
35
- }
36
-
37
- // packages/utils/src/lib/transform.ts
38
- function toArray(val) {
39
- return Array.isArray(val) ? val : [val];
40
- }
41
- function objectToEntries(obj) {
42
- return Object.entries(obj);
43
- }
44
- function countOccurrences(values) {
45
- return values.reduce(
46
- (acc, value) => ({ ...acc, [value]: (acc[value] ?? 0) + 1 }),
47
- {}
48
- );
49
- }
50
- function distinct(array) {
51
- return [...new Set(array)];
52
- }
53
- function capitalize(text) {
54
- return `${text.charAt(0).toLocaleUpperCase()}${text.slice(
55
- 1
56
- )}`;
57
- }
58
-
59
- // packages/utils/src/lib/table.ts
60
- function rowToStringArray({ rows, columns = [] }) {
61
- if (Array.isArray(rows.at(0)) && typeof columns.at(0) === "object") {
62
- throw new TypeError(
63
- "Column can`t be object when rows are primitive values"
64
- );
65
- }
66
- return rows.map((row) => {
67
- if (Array.isArray(row)) {
68
- return row.map(String);
69
- }
70
- const objectRow = row;
71
- if (columns.length === 0 || typeof columns.at(0) === "string") {
72
- return Object.values(objectRow).map(String);
73
- }
74
- return columns.map(
75
- ({ key }) => String(objectRow[key])
76
- );
77
- });
78
- }
79
- function columnsToStringArray({ rows, columns = [] }) {
80
- const firstRow = rows.at(0);
81
- const primitiveRows = Array.isArray(firstRow);
82
- if (typeof columns.at(0) === "string" && !primitiveRows) {
83
- throw new Error("invalid union type. Caught by model parsing.");
84
- }
85
- if (columns.length === 0) {
86
- if (Array.isArray(firstRow)) {
87
- return firstRow.map((_, idx) => String(idx));
88
- }
89
- return Object.keys(firstRow);
90
- }
91
- if (typeof columns.at(0) === "string") {
92
- return columns.map(String);
93
- }
94
- const cols = columns;
95
- return cols.map(({ label, key }) => label ?? capitalize(key));
96
- }
97
- function getColumnAlignmentForKeyAndIndex(targetKey, targetIdx, columns = []) {
98
- const column = columns.at(targetIdx) ?? columns.find((col) => col.key === targetKey);
99
- if (typeof column === "string") {
100
- return column;
101
- } else if (typeof column === "object") {
102
- return column.align ?? "center";
103
- } else {
104
- return "center";
105
- }
106
- }
107
- function getColumnAlignmentForIndex(targetIdx, columns = []) {
108
- const column = columns.at(targetIdx);
109
- if (column == null) {
110
- return "center";
111
- } else if (typeof column === "string") {
112
- return column;
113
- } else if (typeof column === "object") {
114
- return column.align ?? "center";
115
- } else {
116
- return "center";
117
- }
118
- }
119
- function getColumnAlignments({
120
- rows,
121
- columns = []
122
- }) {
123
- if (rows.at(0) == null) {
124
- throw new Error("first row can`t be undefined.");
125
- }
126
- if (Array.isArray(rows.at(0))) {
127
- const firstPrimitiveRow = rows.at(0);
128
- return Array.from({ length: firstPrimitiveRow.length }).map(
129
- (_, idx) => getColumnAlignmentForIndex(idx, columns)
130
- );
131
- }
132
- const firstObject = rows.at(0);
133
- return Object.keys(firstObject).map(
134
- (key, idx) => getColumnAlignmentForKeyAndIndex(key, idx, columns)
135
- );
136
- }
137
-
138
- // packages/utils/src/lib/text-formats/html/table.ts
139
- function wrap(elem, content) {
140
- return `<${elem}>${content}</${elem}>${NEW_LINE}`;
141
- }
142
- function wrapRow(content) {
143
- const elem = "tr";
144
- return `<${elem}>${NEW_LINE}${content}</${elem}>${NEW_LINE}`;
145
- }
146
- function table(tableData) {
147
- if (tableData.rows.length === 0) {
148
- throw new Error("Data can't be empty");
149
- }
150
- const tableHeaderCols = columnsToStringArray(tableData).map((s) => wrap("th", s)).join("");
151
- const tableHeaderRow = wrapRow(tableHeaderCols);
152
- const tableBody = rowToStringArray(tableData).map((arr) => {
153
- const columns = arr.map((s) => wrap("td", s)).join("");
154
- return wrapRow(columns);
155
- }).join("");
156
- return wrap("table", `${NEW_LINE}${tableHeaderRow}${tableBody}`);
157
- }
158
-
159
- // packages/utils/src/lib/text-formats/md/font-style.ts
160
- var boldWrap = "**";
161
- function bold2(text) {
162
- return `${boldWrap}${text}${boldWrap}`;
163
- }
164
- var italicWrap = "_";
165
- function italic2(text) {
166
- return `${italicWrap}${text}${italicWrap}`;
167
- }
168
- var strikeThroughWrap = "~";
169
- function strikeThrough(text) {
170
- return `${strikeThroughWrap}${text}${strikeThroughWrap}`;
171
- }
172
- var codeWrap = "`";
173
- function code2(text) {
174
- return `${codeWrap}${text}${codeWrap}`;
175
- }
176
-
177
- // packages/utils/src/lib/text-formats/md/headline.ts
178
- function headline(text, hierarchy = 1) {
179
- return `${"#".repeat(hierarchy)} ${text}${NEW_LINE}`;
180
- }
181
- function h(text, hierarchy = 1) {
182
- return headline(text, hierarchy);
183
- }
184
- function h1(text) {
185
- return headline(text, 1);
186
- }
187
- function h2(text) {
188
- return headline(text, 2);
189
- }
190
- function h3(text) {
191
- return headline(text, 3);
192
- }
193
- function h4(text) {
194
- return headline(text, 4);
195
- }
196
- function h5(text) {
197
- return headline(text, 5);
198
- }
199
- function h6(text) {
200
- return headline(text, 6);
201
- }
202
-
203
- // packages/utils/src/lib/text-formats/md/image.ts
204
- function image(src, alt) {
205
- return `![${alt}](${src})`;
206
- }
207
-
208
- // packages/utils/src/lib/text-formats/md/link.ts
209
- function link2(href, text) {
210
- return `[${text || href}](${href})`;
211
- }
212
-
213
- // packages/utils/src/lib/text-formats/md/list.ts
214
- function li(text, order = "unordered") {
215
- const style = order === "unordered" ? "-" : "- [ ]";
216
- return `${style} ${text}`;
217
- }
218
- function indentation(text, level = 1) {
219
- return `${TAB.repeat(level)}${text}`;
220
- }
221
-
222
- // packages/utils/src/lib/text-formats/md/paragraphs.ts
223
- function paragraphs(...sections) {
224
- return sections.filter(Boolean).join(`${NEW_LINE}${NEW_LINE}`);
225
- }
226
-
227
- // packages/utils/src/lib/text-formats/md/section.ts
228
- function section(...contents) {
229
- return `${lines(...contents)}${NEW_LINE}`;
230
- }
231
- function lines(...contents) {
232
- return `${contents.filter(Boolean).join(NEW_LINE)}`;
233
- }
234
-
235
- // packages/utils/src/lib/text-formats/md/table.ts
236
- var alignString = /* @__PURE__ */ new Map([
237
- ["left", ":--"],
238
- ["center", ":--:"],
239
- ["right", "--:"]
240
- ]);
241
- function tableRow(rows) {
242
- return `|${rows.join("|")}|`;
243
- }
244
- function table2(data) {
245
- if (data.rows.length === 0) {
246
- throw new Error("Data can't be empty");
247
- }
248
- const alignmentRow = getColumnAlignments(data).map(
249
- (s) => alignString.get(s) ?? String(alignString.get("center"))
250
- );
251
- return section(
252
- `${lines(
253
- tableRow(columnsToStringArray(data)),
254
- tableRow(alignmentRow),
255
- ...rowToStringArray(data).map(tableRow)
256
- )}`
257
- );
258
- }
259
-
260
- // packages/utils/src/lib/text-formats/index.ts
261
- var md = {
262
- bold: bold2,
263
- italic: italic2,
264
- strikeThrough,
265
- code: code2,
266
- link: link2,
267
- image,
268
- headline,
269
- h,
270
- h1,
271
- h2,
272
- h3,
273
- h4,
274
- h5,
275
- h6,
276
- indentation,
277
- lines,
278
- li,
279
- section,
280
- paragraphs,
281
- table: table2
282
- };
283
- var html = {
284
- bold,
285
- italic,
286
- code,
287
- link,
288
- details,
289
- table
290
- };
291
-
292
5
  // packages/models/src/lib/implementation/schemas.ts
293
6
  import { MATERIAL_ICONS } from "vscode-material-icons";
294
7
  import { z } from "zod";
@@ -398,6 +111,7 @@ var fileNameSchema = z.string().trim().regex(filenameRegex, {
398
111
  }).min(1, { message: "file name is invalid" });
399
112
  var positiveIntSchema = z.number().int().positive();
400
113
  var nonnegativeIntSchema = z.number().int().nonnegative();
114
+ var nonnegativeNumberSchema = z.number().nonnegative();
401
115
  function packageVersionSchema(options) {
402
116
  const { versionDescription = "NPM version of the package", required } = options ?? {};
403
117
  const packageSchema = z.string({ description: "NPM package name" });
@@ -410,7 +124,7 @@ function packageVersionSchema(options) {
410
124
  { description: "NPM package name and version of a published package" }
411
125
  );
412
126
  }
413
- var weightSchema = nonnegativeIntSchema.describe(
127
+ var weightSchema = nonnegativeNumberSchema.describe(
414
128
  "Coefficient for the given score (use weight 0 if only for display)"
415
129
  );
416
130
  function weightedRefSchema(description, slugDescription) {
@@ -552,7 +266,7 @@ var tableObjectSchema = tableSharedSchema.merge(
552
266
  var tableSchema = (description = "Table information") => z4.union([tablePrimitiveSchema, tableObjectSchema], { description });
553
267
 
554
268
  // packages/models/src/lib/audit-output.ts
555
- var auditValueSchema = nonnegativeIntSchema.describe("Raw numeric value");
269
+ var auditValueSchema = nonnegativeNumberSchema.describe("Raw numeric value");
556
270
  var auditDisplayValueSchema = z5.string({ description: "Formatted value (e.g. '0.9 s', '2.1 MB')" }).optional();
557
271
  var auditDetailsSchema = z5.object(
558
272
  {
@@ -996,88 +710,378 @@ import { join } from "node:path";
996
710
  function slugify(text) {
997
711
  return text.trim().toLowerCase().replace(/\s+|\//g, "-").replace(/[^a-z\d-]/g, "");
998
712
  }
999
- function pluralize(text, amount) {
1000
- if (amount != null && Math.abs(amount) === 1) {
1001
- return text;
713
+ function pluralize(text, amount) {
714
+ if (amount != null && Math.abs(amount) === 1) {
715
+ return text;
716
+ }
717
+ if (text.endsWith("y")) {
718
+ return `${text.slice(0, -1)}ies`;
719
+ }
720
+ if (text.endsWith("s")) {
721
+ return `${text}es`;
722
+ }
723
+ return `${text}s`;
724
+ }
725
+ function pluralizeToken(token, times) {
726
+ return `${times} ${Math.abs(times) === 1 ? token : pluralize(token)}`;
727
+ }
728
+ function truncateText(text, maxChars) {
729
+ if (text.length <= maxChars) {
730
+ return text;
731
+ }
732
+ const ellipsis = "...";
733
+ return text.slice(0, maxChars - ellipsis.length) + ellipsis;
734
+ }
735
+ function truncateIssueMessage(text) {
736
+ return truncateText(text, MAX_ISSUE_MESSAGE_LENGTH);
737
+ }
738
+
739
+ // packages/utils/src/lib/logging.ts
740
+ import isaacs_cliui from "@isaacs/cliui";
741
+ import { cliui } from "@poppinss/cliui";
742
+ import chalk from "chalk";
743
+
744
+ // packages/utils/src/lib/reports/constants.ts
745
+ var TERMINAL_WIDTH = 80;
746
+
747
+ // packages/utils/src/lib/logging.ts
748
+ var singletonUiInstance;
749
+ function ui() {
750
+ if (singletonUiInstance === void 0) {
751
+ singletonUiInstance = cliui();
752
+ }
753
+ return {
754
+ ...singletonUiInstance,
755
+ row: (args) => {
756
+ logListItem(args);
757
+ }
758
+ };
759
+ }
760
+ var singletonisaacUi;
761
+ function logListItem(args) {
762
+ if (singletonisaacUi === void 0) {
763
+ singletonisaacUi = isaacs_cliui({ width: TERMINAL_WIDTH });
764
+ }
765
+ singletonisaacUi.div(...args);
766
+ const content = singletonisaacUi.toString();
767
+ singletonisaacUi.rows = [];
768
+ singletonUiInstance?.logger.log(content);
769
+ }
770
+
771
+ // packages/utils/src/lib/file-system.ts
772
+ async function readTextFile(path) {
773
+ const buffer = await readFile(path);
774
+ return buffer.toString();
775
+ }
776
+ async function readJsonFile(path) {
777
+ const text = await readTextFile(path);
778
+ return JSON.parse(text);
779
+ }
780
+ async function ensureDirectoryExists(baseDir) {
781
+ try {
782
+ await mkdir(baseDir, { recursive: true });
783
+ return;
784
+ } catch (error) {
785
+ ui().logger.info(error.message);
786
+ if (error.code !== "EEXIST") {
787
+ throw error;
788
+ }
789
+ }
790
+ }
791
+ function pluginWorkDir(slug) {
792
+ return join("node_modules", ".code-pushup", slug);
793
+ }
794
+ function filePathToCliArg(path) {
795
+ return `"${path}"`;
796
+ }
797
+
798
+ // packages/utils/src/lib/text-formats/constants.ts
799
+ var NEW_LINE = "\n";
800
+ var TAB = " ";
801
+
802
+ // packages/utils/src/lib/text-formats/html/details.ts
803
+ function details(title, content, cfg = { open: false }) {
804
+ 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.
805
+ NEW_LINE}${content}${NEW_LINE}${// @TODO in the future we could consider adding it only if the content ends with a code block
806
+ // ⚠️ The blank line ensure Markdown in content is rendered correctly.
807
+ NEW_LINE}</details>${// ⚠️ The blank line is needed to ensure Markdown after details is rendered correctly.
808
+ NEW_LINE}`;
809
+ }
810
+
811
+ // packages/utils/src/lib/text-formats/html/font-style.ts
812
+ var boldElement = "b";
813
+ function bold(text) {
814
+ return `<${boldElement}>${text}</${boldElement}>`;
815
+ }
816
+ var italicElement = "i";
817
+ function italic(text) {
818
+ return `<${italicElement}>${text}</${italicElement}>`;
819
+ }
820
+ var codeElement = "code";
821
+ function code(text) {
822
+ return `<${codeElement}>${text}</${codeElement}>`;
823
+ }
824
+
825
+ // packages/utils/src/lib/text-formats/html/link.ts
826
+ function link(href, text) {
827
+ return `<a href="${href}">${text || href}"</a>`;
828
+ }
829
+
830
+ // packages/utils/src/lib/transform.ts
831
+ function toArray(val) {
832
+ return Array.isArray(val) ? val : [val];
833
+ }
834
+ function objectToEntries(obj) {
835
+ return Object.entries(obj);
836
+ }
837
+ function countOccurrences(values) {
838
+ return values.reduce(
839
+ (acc, value) => ({ ...acc, [value]: (acc[value] ?? 0) + 1 }),
840
+ {}
841
+ );
842
+ }
843
+ function distinct(array) {
844
+ return [...new Set(array)];
845
+ }
846
+ function capitalize(text) {
847
+ return `${text.charAt(0).toLocaleUpperCase()}${text.slice(
848
+ 1
849
+ )}`;
850
+ }
851
+
852
+ // packages/utils/src/lib/table.ts
853
+ function rowToStringArray({ rows, columns = [] }) {
854
+ if (Array.isArray(rows.at(0)) && typeof columns.at(0) === "object") {
855
+ throw new TypeError(
856
+ "Column can`t be object when rows are primitive values"
857
+ );
858
+ }
859
+ return rows.map((row) => {
860
+ if (Array.isArray(row)) {
861
+ return row.map(String);
862
+ }
863
+ const objectRow = row;
864
+ if (columns.length === 0 || typeof columns.at(0) === "string") {
865
+ return Object.values(objectRow).map(String);
866
+ }
867
+ return columns.map(
868
+ ({ key }) => String(objectRow[key])
869
+ );
870
+ });
871
+ }
872
+ function columnsToStringArray({ rows, columns = [] }) {
873
+ const firstRow = rows.at(0);
874
+ const primitiveRows = Array.isArray(firstRow);
875
+ if (typeof columns.at(0) === "string" && !primitiveRows) {
876
+ throw new Error("invalid union type. Caught by model parsing.");
877
+ }
878
+ if (columns.length === 0) {
879
+ if (Array.isArray(firstRow)) {
880
+ return firstRow.map((_, idx) => String(idx));
881
+ }
882
+ return Object.keys(firstRow);
883
+ }
884
+ if (typeof columns.at(0) === "string") {
885
+ return columns.map(String);
886
+ }
887
+ const cols = columns;
888
+ return cols.map(({ label, key }) => label ?? capitalize(key));
889
+ }
890
+ function getColumnAlignmentForKeyAndIndex(targetKey, targetIdx, columns = []) {
891
+ const column = columns.at(targetIdx) ?? columns.find((col) => col.key === targetKey);
892
+ if (typeof column === "string") {
893
+ return column;
894
+ } else if (typeof column === "object") {
895
+ return column.align ?? "center";
896
+ } else {
897
+ return "center";
1002
898
  }
1003
- if (text.endsWith("y")) {
1004
- return `${text.slice(0, -1)}ies`;
899
+ }
900
+ function getColumnAlignmentForIndex(targetIdx, columns = []) {
901
+ const column = columns.at(targetIdx);
902
+ if (column == null) {
903
+ return "center";
904
+ } else if (typeof column === "string") {
905
+ return column;
906
+ } else if (typeof column === "object") {
907
+ return column.align ?? "center";
908
+ } else {
909
+ return "center";
1005
910
  }
1006
- if (text.endsWith("s")) {
1007
- return `${text}es`;
911
+ }
912
+ function getColumnAlignments({
913
+ rows,
914
+ columns = []
915
+ }) {
916
+ if (rows.at(0) == null) {
917
+ throw new Error("first row can`t be undefined.");
1008
918
  }
1009
- return `${text}s`;
919
+ if (Array.isArray(rows.at(0))) {
920
+ const firstPrimitiveRow = rows.at(0);
921
+ return Array.from({ length: firstPrimitiveRow.length }).map(
922
+ (_, idx) => getColumnAlignmentForIndex(idx, columns)
923
+ );
924
+ }
925
+ const firstObject = rows.at(0);
926
+ return Object.keys(firstObject).map(
927
+ (key, idx) => getColumnAlignmentForKeyAndIndex(key, idx, columns)
928
+ );
1010
929
  }
1011
- function pluralizeToken(token, times) {
1012
- return `${times} ${Math.abs(times) === 1 ? token : pluralize(token)}`;
930
+
931
+ // packages/utils/src/lib/text-formats/html/table.ts
932
+ function wrap(elem, content) {
933
+ return `<${elem}>${content}</${elem}>${NEW_LINE}`;
1013
934
  }
1014
- function truncateText(text, maxChars) {
1015
- if (text.length <= maxChars) {
1016
- return text;
935
+ function wrapRow(content) {
936
+ const elem = "tr";
937
+ return `<${elem}>${NEW_LINE}${content}</${elem}>${NEW_LINE}`;
938
+ }
939
+ function table(tableData) {
940
+ if (tableData.rows.length === 0) {
941
+ throw new Error("Data can't be empty");
1017
942
  }
1018
- const ellipsis = "...";
1019
- return text.slice(0, maxChars - ellipsis.length) + ellipsis;
943
+ const tableHeaderCols = columnsToStringArray(tableData).map((s) => wrap("th", s)).join("");
944
+ const tableHeaderRow = wrapRow(tableHeaderCols);
945
+ const tableBody = rowToStringArray(tableData).map((arr) => {
946
+ const columns = arr.map((s) => wrap("td", s)).join("");
947
+ return wrapRow(columns);
948
+ }).join("");
949
+ return wrap("table", `${NEW_LINE}${tableHeaderRow}${tableBody}`);
1020
950
  }
1021
- function truncateIssueMessage(text) {
1022
- return truncateText(text, MAX_ISSUE_MESSAGE_LENGTH);
951
+
952
+ // packages/utils/src/lib/text-formats/md/font-style.ts
953
+ var boldWrap = "**";
954
+ function bold2(text) {
955
+ return `${boldWrap}${text}${boldWrap}`;
956
+ }
957
+ var italicWrap = "_";
958
+ function italic2(text) {
959
+ return `${italicWrap}${text}${italicWrap}`;
960
+ }
961
+ var strikeThroughWrap = "~";
962
+ function strikeThrough(text) {
963
+ return `${strikeThroughWrap}${text}${strikeThroughWrap}`;
964
+ }
965
+ var codeWrap = "`";
966
+ function code2(text) {
967
+ return `${codeWrap}${text}${codeWrap}`;
1023
968
  }
1024
969
 
1025
- // packages/utils/src/lib/logging.ts
1026
- import isaacs_cliui from "@isaacs/cliui";
1027
- import { cliui } from "@poppinss/cliui";
1028
- import chalk from "chalk";
970
+ // packages/utils/src/lib/text-formats/md/headline.ts
971
+ function headline(text, hierarchy = 1) {
972
+ return `${"#".repeat(hierarchy)} ${text}${NEW_LINE}`;
973
+ }
974
+ function h(text, hierarchy = 1) {
975
+ return headline(text, hierarchy);
976
+ }
977
+ function h1(text) {
978
+ return headline(text, 1);
979
+ }
980
+ function h2(text) {
981
+ return headline(text, 2);
982
+ }
983
+ function h3(text) {
984
+ return headline(text, 3);
985
+ }
986
+ function h4(text) {
987
+ return headline(text, 4);
988
+ }
989
+ function h5(text) {
990
+ return headline(text, 5);
991
+ }
992
+ function h6(text) {
993
+ return headline(text, 6);
994
+ }
1029
995
 
1030
- // packages/utils/src/lib/reports/constants.ts
1031
- var TERMINAL_WIDTH = 80;
996
+ // packages/utils/src/lib/text-formats/md/image.ts
997
+ function image(src, alt) {
998
+ return `![${alt}](${src})`;
999
+ }
1032
1000
 
1033
- // packages/utils/src/lib/logging.ts
1034
- var singletonUiInstance;
1035
- function ui() {
1036
- if (singletonUiInstance === void 0) {
1037
- singletonUiInstance = cliui();
1038
- }
1039
- return {
1040
- ...singletonUiInstance,
1041
- row: (args) => {
1042
- logListItem(args);
1043
- }
1044
- };
1001
+ // packages/utils/src/lib/text-formats/md/link.ts
1002
+ function link2(href, text) {
1003
+ return `[${text || href}](${href})`;
1045
1004
  }
1046
- var singletonisaacUi;
1047
- function logListItem(args) {
1048
- if (singletonisaacUi === void 0) {
1049
- singletonisaacUi = isaacs_cliui({ width: TERMINAL_WIDTH });
1050
- }
1051
- singletonisaacUi.div(...args);
1052
- const content = singletonisaacUi.toString();
1053
- singletonisaacUi.rows = [];
1054
- singletonUiInstance?.logger.log(content);
1005
+
1006
+ // packages/utils/src/lib/text-formats/md/list.ts
1007
+ function li(text, order = "unordered") {
1008
+ const style = order === "unordered" ? "-" : "- [ ]";
1009
+ return `${style} ${text}`;
1010
+ }
1011
+ function indentation(text, level = 1) {
1012
+ return `${TAB.repeat(level)}${text}`;
1055
1013
  }
1056
1014
 
1057
- // packages/utils/src/lib/file-system.ts
1058
- async function readTextFile(path) {
1059
- const buffer = await readFile(path);
1060
- return buffer.toString();
1015
+ // packages/utils/src/lib/text-formats/md/paragraphs.ts
1016
+ function paragraphs(...sections) {
1017
+ return sections.filter(Boolean).join(`${NEW_LINE}${NEW_LINE}`);
1061
1018
  }
1062
- async function readJsonFile(path) {
1063
- const text = await readTextFile(path);
1064
- return JSON.parse(text);
1019
+
1020
+ // packages/utils/src/lib/text-formats/md/section.ts
1021
+ function section(...contents) {
1022
+ return `${lines(...contents)}${NEW_LINE}`;
1065
1023
  }
1066
- async function ensureDirectoryExists(baseDir) {
1067
- try {
1068
- await mkdir(baseDir, { recursive: true });
1069
- return;
1070
- } catch (error) {
1071
- ui().logger.info(error.message);
1072
- if (error.code !== "EEXIST") {
1073
- throw error;
1074
- }
1075
- }
1024
+ function lines(...contents) {
1025
+ return `${contents.filter(Boolean).join(NEW_LINE)}`;
1076
1026
  }
1077
- function pluginWorkDir(slug) {
1078
- return join("node_modules", ".code-pushup", slug);
1027
+
1028
+ // packages/utils/src/lib/text-formats/md/table.ts
1029
+ var alignString = /* @__PURE__ */ new Map([
1030
+ ["left", ":--"],
1031
+ ["center", ":--:"],
1032
+ ["right", "--:"]
1033
+ ]);
1034
+ function tableRow(rows) {
1035
+ return `|${rows.join("|")}|`;
1036
+ }
1037
+ function table2(data) {
1038
+ if (data.rows.length === 0) {
1039
+ throw new Error("Data can't be empty");
1040
+ }
1041
+ const alignmentRow = getColumnAlignments(data).map(
1042
+ (s) => alignString.get(s) ?? String(alignString.get("center"))
1043
+ );
1044
+ return section(
1045
+ `${lines(
1046
+ tableRow(columnsToStringArray(data)),
1047
+ tableRow(alignmentRow),
1048
+ ...rowToStringArray(data).map(tableRow)
1049
+ )}`
1050
+ );
1079
1051
  }
1080
1052
 
1053
+ // packages/utils/src/lib/text-formats/index.ts
1054
+ var md = {
1055
+ bold: bold2,
1056
+ italic: italic2,
1057
+ strikeThrough,
1058
+ code: code2,
1059
+ link: link2,
1060
+ image,
1061
+ headline,
1062
+ h,
1063
+ h1,
1064
+ h2,
1065
+ h3,
1066
+ h4,
1067
+ h5,
1068
+ h6,
1069
+ indentation,
1070
+ lines,
1071
+ li,
1072
+ section,
1073
+ paragraphs,
1074
+ table: table2
1075
+ };
1076
+ var html = {
1077
+ bold,
1078
+ italic,
1079
+ code,
1080
+ link,
1081
+ details,
1082
+ table
1083
+ };
1084
+
1081
1085
  // packages/utils/src/lib/reports/utils.ts
1082
1086
  var { image: image2, bold: boldMd } = md;
1083
1087
  function calcDuration(start, stop) {
@@ -1212,7 +1216,7 @@ function executeLint({
1212
1216
  command: "npx",
1213
1217
  args: [
1214
1218
  "eslint",
1215
- ...configPath ? [`--config=${configPath}`] : [],
1219
+ ...configPath ? [`--config=${filePathToCliArg(configPath)}`] : [],
1216
1220
  ...typeof eslintrc === "object" ? ["--no-eslintrc"] : [],
1217
1221
  "--no-error-on-unmatched-pattern",
1218
1222
  "--format=json",