@code-pushup/eslint-plugin 0.48.0 → 0.49.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 (3) hide show
  1. package/bin.js +80 -370
  2. package/index.js +25 -317
  3. package/package.json +3 -3
package/bin.js CHANGED
@@ -700,9 +700,74 @@ var reportsDiffSchema = z15.object({
700
700
  // packages/utils/src/lib/execute-process.ts
701
701
  import { spawn } from "node:child_process";
702
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 { observer, cwd, command, args, ignoreExitCode = false } = cfg;
737
+ const { onStdout, onError, onComplete } = observer ?? {};
738
+ const date = (/* @__PURE__ */ new Date()).toISOString();
739
+ const start = performance.now();
740
+ return new Promise((resolve, reject) => {
741
+ const process2 = spawn(command, args, { cwd, shell: true });
742
+ let stdout = "";
743
+ let stderr = "";
744
+ process2.stdout.on("data", (data) => {
745
+ stdout += String(data);
746
+ onStdout?.(String(data));
747
+ });
748
+ process2.stderr.on("data", (data) => {
749
+ stderr += String(data);
750
+ });
751
+ process2.on("error", (err) => {
752
+ stderr += err.toString();
753
+ });
754
+ process2.on("close", (code2) => {
755
+ const timings = { date, duration: calcDuration(start) };
756
+ if (code2 === 0 || ignoreExitCode) {
757
+ onComplete?.();
758
+ resolve({ code: code2, stdout, stderr, ...timings });
759
+ } else {
760
+ const errorMsg = new ProcessError({ code: code2, stdout, stderr, ...timings });
761
+ onError?.(errorMsg);
762
+ reject(errorMsg);
763
+ }
764
+ });
765
+ });
766
+ }
767
+
703
768
  // packages/utils/src/lib/file-system.ts
769
+ import { bold, gray } from "ansis";
704
770
  import { bundleRequire } from "bundle-require";
705
- import chalk2 from "chalk";
706
771
  import { mkdir, readFile, readdir, rm, stat } from "node:fs/promises";
707
772
  import { join } from "node:path";
708
773
 
@@ -752,12 +817,7 @@ function truncateIssueMessage(text) {
752
817
  // packages/utils/src/lib/logging.ts
753
818
  import isaacs_cliui from "@isaacs/cliui";
754
819
  import { cliui } from "@poppinss/cliui";
755
- import chalk from "chalk";
756
-
757
- // packages/utils/src/lib/reports/constants.ts
758
- var TERMINAL_WIDTH = 80;
759
-
760
- // packages/utils/src/lib/logging.ts
820
+ import { underline } from "ansis";
761
821
  var singletonUiInstance;
762
822
  function ui() {
763
823
  if (singletonUiInstance === void 0) {
@@ -808,37 +868,8 @@ function filePathToCliArg(path) {
808
868
  return `"${path}"`;
809
869
  }
810
870
 
811
- // packages/utils/src/lib/text-formats/constants.ts
812
- var NEW_LINE = "\n";
813
- var TAB = " ";
814
-
815
- // packages/utils/src/lib/text-formats/html/details.ts
816
- function details(title, content, cfg = { open: false }) {
817
- 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.
818
- NEW_LINE}${content}${NEW_LINE}${// @TODO in the future we could consider adding it only if the content ends with a code block
819
- // ⚠️ The blank line ensure Markdown in content is rendered correctly.
820
- NEW_LINE}</details>${// ⚠️ The blank line is needed to ensure Markdown after details is rendered correctly.
821
- NEW_LINE}`;
822
- }
823
-
824
- // packages/utils/src/lib/text-formats/html/font-style.ts
825
- var boldElement = "b";
826
- function bold(text) {
827
- return `<${boldElement}>${text}</${boldElement}>`;
828
- }
829
- var italicElement = "i";
830
- function italic(text) {
831
- return `<${italicElement}>${text}</${italicElement}>`;
832
- }
833
- var codeElement = "code";
834
- function code(text) {
835
- return `<${codeElement}>${text}</${codeElement}>`;
836
- }
837
-
838
- // packages/utils/src/lib/text-formats/html/link.ts
839
- function link(href, text) {
840
- return `<a href="${href}">${text || href}</a>`;
841
- }
871
+ // packages/utils/src/lib/git/git.ts
872
+ import { simpleGit } from "simple-git";
842
873
 
843
874
  // packages/utils/src/lib/transform.ts
844
875
  function toArray(val) {
@@ -856,319 +887,6 @@ function countOccurrences(values) {
856
887
  function distinct(array) {
857
888
  return [...new Set(array)];
858
889
  }
859
- function capitalize(text) {
860
- return `${text.charAt(0).toLocaleUpperCase()}${text.slice(
861
- 1
862
- )}`;
863
- }
864
-
865
- // packages/utils/src/lib/text-formats/table.ts
866
- function rowToStringArray({ rows, columns = [] }) {
867
- if (Array.isArray(rows.at(0)) && typeof columns.at(0) === "object") {
868
- throw new TypeError(
869
- "Column can`t be object when rows are primitive values"
870
- );
871
- }
872
- return rows.map((row) => {
873
- if (Array.isArray(row)) {
874
- return row.map(String);
875
- }
876
- const objectRow = row;
877
- if (columns.length === 0 || typeof columns.at(0) === "string") {
878
- return Object.values(objectRow).map(
879
- (value) => value == null ? "" : String(value)
880
- );
881
- }
882
- return columns.map(
883
- ({ key }) => objectRow[key] == null ? "" : String(objectRow[key])
884
- );
885
- });
886
- }
887
- function columnsToStringArray({
888
- rows,
889
- columns = []
890
- }) {
891
- const firstRow = rows.at(0);
892
- const primitiveRows = Array.isArray(firstRow);
893
- if (typeof columns.at(0) === "string" && !primitiveRows) {
894
- throw new Error("invalid union type. Caught by model parsing.");
895
- }
896
- if (columns.length === 0) {
897
- if (Array.isArray(firstRow)) {
898
- return firstRow.map((_, idx) => String(idx));
899
- }
900
- return Object.keys(firstRow);
901
- }
902
- if (typeof columns.at(0) === "string") {
903
- return columns.map(String);
904
- }
905
- const cols = columns;
906
- return cols.map(({ label, key }) => label ?? capitalize(key));
907
- }
908
- function getColumnAlignmentForKeyAndIndex(targetKey, targetIdx, columns = []) {
909
- const column = columns.at(targetIdx) ?? columns.find((col) => col.key === targetKey);
910
- if (typeof column === "string") {
911
- return column;
912
- } else if (typeof column === "object") {
913
- return column.align ?? "center";
914
- } else {
915
- return "center";
916
- }
917
- }
918
- function getColumnAlignmentForIndex(targetIdx, columns = []) {
919
- const column = columns.at(targetIdx);
920
- if (column == null) {
921
- return "center";
922
- } else if (typeof column === "string") {
923
- return column;
924
- } else if (typeof column === "object") {
925
- return column.align ?? "center";
926
- } else {
927
- return "center";
928
- }
929
- }
930
- function getColumnAlignments(tableData) {
931
- const { rows, columns = [] } = tableData;
932
- if (rows.at(0) == null) {
933
- throw new Error("first row can`t be undefined.");
934
- }
935
- if (Array.isArray(rows.at(0))) {
936
- const firstPrimitiveRow = rows.at(0);
937
- return Array.from({ length: firstPrimitiveRow.length }).map(
938
- (_, idx) => getColumnAlignmentForIndex(idx, columns)
939
- );
940
- }
941
- const biggestRow = [...rows].sort((a, b) => Object.keys(a).length - Object.keys(b).length).at(-1);
942
- if (columns.length > 0) {
943
- return columns.map(
944
- (column, idx) => typeof column === "string" ? column : getColumnAlignmentForKeyAndIndex(
945
- column.key,
946
- idx,
947
- columns
948
- )
949
- );
950
- }
951
- return Object.keys(biggestRow ?? {}).map((_) => "center");
952
- }
953
-
954
- // packages/utils/src/lib/text-formats/html/table.ts
955
- function wrap(elem, content) {
956
- return `<${elem}>${content}</${elem}>${NEW_LINE}`;
957
- }
958
- function wrapRow(content) {
959
- const elem = "tr";
960
- return `<${elem}>${NEW_LINE}${content}</${elem}>${NEW_LINE}`;
961
- }
962
- function table(tableData) {
963
- if (tableData.rows.length === 0) {
964
- throw new Error("Data can't be empty");
965
- }
966
- const tableHeaderCols = columnsToStringArray(tableData).map((s) => wrap("th", s)).join("");
967
- const tableHeaderRow = wrapRow(tableHeaderCols);
968
- const tableBody = rowToStringArray(tableData).map((arr) => {
969
- const columns = arr.map((s) => wrap("td", s)).join("");
970
- return wrapRow(columns);
971
- }).join("");
972
- return wrap("table", `${NEW_LINE}${tableHeaderRow}${tableBody}`);
973
- }
974
-
975
- // packages/utils/src/lib/text-formats/md/font-style.ts
976
- var boldWrap = "**";
977
- function bold2(text) {
978
- return `${boldWrap}${text}${boldWrap}`;
979
- }
980
- var italicWrap = "_";
981
- function italic2(text) {
982
- return `${italicWrap}${text}${italicWrap}`;
983
- }
984
- var strikeThroughWrap = "~";
985
- function strikeThrough(text) {
986
- return `${strikeThroughWrap}${text}${strikeThroughWrap}`;
987
- }
988
- var codeWrap = "`";
989
- function code2(text) {
990
- return `${codeWrap}${text}${codeWrap}`;
991
- }
992
-
993
- // packages/utils/src/lib/text-formats/md/headline.ts
994
- function headline(text, hierarchy = 1) {
995
- return `${"#".repeat(hierarchy)} ${text}${NEW_LINE}`;
996
- }
997
- function h(text, hierarchy = 1) {
998
- return headline(text, hierarchy);
999
- }
1000
- function h1(text) {
1001
- return headline(text, 1);
1002
- }
1003
- function h2(text) {
1004
- return headline(text, 2);
1005
- }
1006
- function h3(text) {
1007
- return headline(text, 3);
1008
- }
1009
- function h4(text) {
1010
- return headline(text, 4);
1011
- }
1012
- function h5(text) {
1013
- return headline(text, 5);
1014
- }
1015
- function h6(text) {
1016
- return headline(text, 6);
1017
- }
1018
-
1019
- // packages/utils/src/lib/text-formats/md/image.ts
1020
- function image(src, alt) {
1021
- return `![${alt}](${src})`;
1022
- }
1023
-
1024
- // packages/utils/src/lib/text-formats/md/link.ts
1025
- function link2(href, text) {
1026
- return `[${text || href}](${href})`;
1027
- }
1028
-
1029
- // packages/utils/src/lib/text-formats/md/list.ts
1030
- function li(text, order = "unordered") {
1031
- const style = order === "unordered" ? "-" : "- [ ]";
1032
- return `${style} ${text}`;
1033
- }
1034
- function indentation(text, level = 1) {
1035
- return `${TAB.repeat(level)}${text}`;
1036
- }
1037
-
1038
- // packages/utils/src/lib/text-formats/md/paragraphs.ts
1039
- function paragraphs(...sections) {
1040
- return sections.filter(Boolean).join(`${NEW_LINE}${NEW_LINE}`);
1041
- }
1042
-
1043
- // packages/utils/src/lib/text-formats/md/section.ts
1044
- function section(...contents) {
1045
- return `${lines(...contents)}${NEW_LINE}`;
1046
- }
1047
- function lines(...contents) {
1048
- const filteredContent = contents.filter(
1049
- (value) => value != null && value !== "" && value !== false
1050
- );
1051
- return `${filteredContent.join(NEW_LINE)}`;
1052
- }
1053
-
1054
- // packages/utils/src/lib/text-formats/md/table.ts
1055
- var alignString = /* @__PURE__ */ new Map([
1056
- ["left", ":--"],
1057
- ["center", ":--:"],
1058
- ["right", "--:"]
1059
- ]);
1060
- function tableRow(rows) {
1061
- return `|${rows.join("|")}|`;
1062
- }
1063
- function table2(data) {
1064
- if (data.rows.length === 0) {
1065
- throw new Error("Data can't be empty");
1066
- }
1067
- const alignmentRow = getColumnAlignments(data).map(
1068
- (s) => alignString.get(s) ?? String(alignString.get("center"))
1069
- );
1070
- return section(
1071
- `${lines(
1072
- tableRow(columnsToStringArray(data)),
1073
- tableRow(alignmentRow),
1074
- ...rowToStringArray(data).map(tableRow)
1075
- )}`
1076
- );
1077
- }
1078
-
1079
- // packages/utils/src/lib/text-formats/index.ts
1080
- var md = {
1081
- bold: bold2,
1082
- italic: italic2,
1083
- strikeThrough,
1084
- code: code2,
1085
- link: link2,
1086
- image,
1087
- headline,
1088
- h,
1089
- h1,
1090
- h2,
1091
- h3,
1092
- h4,
1093
- h5,
1094
- h6,
1095
- indentation,
1096
- lines,
1097
- li,
1098
- section,
1099
- paragraphs,
1100
- table: table2
1101
- };
1102
- var html = {
1103
- bold,
1104
- italic,
1105
- code,
1106
- link,
1107
- details,
1108
- table
1109
- };
1110
-
1111
- // packages/utils/src/lib/reports/utils.ts
1112
- var { image: image2, bold: boldMd } = md;
1113
- function calcDuration(start, stop) {
1114
- return Math.round((stop ?? performance.now()) - start);
1115
- }
1116
- function compareIssueSeverity(severity1, severity2) {
1117
- const levels = {
1118
- info: 0,
1119
- warning: 1,
1120
- error: 2
1121
- };
1122
- return levels[severity1] - levels[severity2];
1123
- }
1124
-
1125
- // packages/utils/src/lib/execute-process.ts
1126
- var ProcessError = class extends Error {
1127
- code;
1128
- stderr;
1129
- stdout;
1130
- constructor(result) {
1131
- super(result.stderr);
1132
- this.code = result.code;
1133
- this.stderr = result.stderr;
1134
- this.stdout = result.stdout;
1135
- }
1136
- };
1137
- function executeProcess(cfg) {
1138
- const { observer, cwd, command, args, ignoreExitCode = false } = cfg;
1139
- const { onStdout, onError, onComplete } = observer ?? {};
1140
- const date = (/* @__PURE__ */ new Date()).toISOString();
1141
- const start = performance.now();
1142
- return new Promise((resolve, reject) => {
1143
- const process2 = spawn(command, args, { cwd, shell: true });
1144
- let stdout = "";
1145
- let stderr = "";
1146
- process2.stdout.on("data", (data) => {
1147
- stdout += String(data);
1148
- onStdout?.(String(data));
1149
- });
1150
- process2.stderr.on("data", (data) => {
1151
- stderr += String(data);
1152
- });
1153
- process2.on("error", (err) => {
1154
- stderr += err.toString();
1155
- });
1156
- process2.on("close", (code3) => {
1157
- const timings = { date, duration: calcDuration(start) };
1158
- if (code3 === 0 || ignoreExitCode) {
1159
- onComplete?.();
1160
- resolve({ code: code3, stdout, stderr, ...timings });
1161
- } else {
1162
- const errorMsg = new ProcessError({ code: code3, stdout, stderr, ...timings });
1163
- onError?.(errorMsg);
1164
- reject(errorMsg);
1165
- }
1166
- });
1167
- });
1168
- }
1169
-
1170
- // packages/utils/src/lib/git/git.ts
1171
- import { simpleGit } from "simple-git";
1172
890
 
1173
891
  // packages/utils/src/lib/git/git.commits-and-tags.ts
1174
892
  import { simpleGit as simpleGit2 } from "simple-git";
@@ -1177,34 +895,26 @@ import { simpleGit as simpleGit2 } from "simple-git";
1177
895
  import { rcompare, valid } from "semver";
1178
896
 
1179
897
  // packages/utils/src/lib/progress.ts
1180
- import chalk3 from "chalk";
898
+ import { black, bold as bold2, gray as gray2, green } from "ansis";
1181
899
  import { MultiProgressBars } from "multi-progress-bars";
1182
900
 
901
+ // packages/utils/src/lib/reports/generate-md-report.ts
902
+ import { MarkdownDocument as MarkdownDocument3, md as md4 } from "build-md";
903
+
1183
904
  // packages/utils/src/lib/reports/formatting.ts
1184
- var { headline: headline2, lines: lines2, link: link3, section: section2, table: table3 } = md;
905
+ import { MarkdownDocument, md as md2 } from "build-md";
1185
906
 
1186
907
  // packages/utils/src/lib/reports/generate-md-report-categoy-section.ts
1187
- var { link: link4, section: section3, h2: h22, lines: lines3, li: li2, bold: boldMd2, h3: h32, indentation: indentation2 } = md;
1188
-
1189
- // packages/utils/src/lib/reports/generate-md-report.ts
1190
- var { h1: h12, h2: h23, h3: h33, lines: lines4, link: link5, section: section4, code: codeMd } = md;
1191
- var { bold: boldHtml, details: details2 } = html;
908
+ import { MarkdownDocument as MarkdownDocument2, md as md3 } from "build-md";
1192
909
 
1193
910
  // packages/utils/src/lib/reports/generate-md-reports-diff.ts
1194
- var {
1195
- h1: h13,
1196
- h2: h24,
1197
- lines: lines5,
1198
- link: link6,
1199
- bold: boldMd3,
1200
- italic: italicMd,
1201
- table: table4,
1202
- section: section5
1203
- } = md;
1204
- var { details: details3 } = html;
911
+ import {
912
+ MarkdownDocument as MarkdownDocument4,
913
+ md as md5
914
+ } from "build-md";
1205
915
 
1206
916
  // packages/utils/src/lib/reports/log-stdout-summary.ts
1207
- import chalk4 from "chalk";
917
+ import { bold as bold4, cyan, cyanBright, green as green2, red } from "ansis";
1208
918
 
1209
919
  // packages/plugin-eslint/src/lib/runner/lint.ts
1210
920
  import { rm as rm2, writeFile } from "node:fs/promises";
package/index.js CHANGED
@@ -4,7 +4,7 @@ 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.48.0";
7
+ var version = "0.49.0";
8
8
 
9
9
  // packages/plugin-eslint/src/lib/config.ts
10
10
  import { z as z16 } from "zod";
@@ -704,9 +704,16 @@ var reportsDiffSchema = z15.object({
704
704
  })
705
705
  );
706
706
 
707
+ // packages/utils/src/lib/reports/utils.ts
708
+ import ansis from "ansis";
709
+ import { md } from "build-md";
710
+
711
+ // packages/utils/src/lib/reports/constants.ts
712
+ var TERMINAL_WIDTH = 80;
713
+
707
714
  // packages/utils/src/lib/file-system.ts
715
+ import { bold, gray } from "ansis";
708
716
  import { bundleRequire } from "bundle-require";
709
- import chalk2 from "chalk";
710
717
  import { mkdir, readFile, readdir, rm, stat } from "node:fs/promises";
711
718
  import { join } from "node:path";
712
719
 
@@ -744,12 +751,7 @@ function truncateDescription(text) {
744
751
  // packages/utils/src/lib/logging.ts
745
752
  import isaacs_cliui from "@isaacs/cliui";
746
753
  import { cliui } from "@poppinss/cliui";
747
- import chalk from "chalk";
748
-
749
- // packages/utils/src/lib/reports/constants.ts
750
- var TERMINAL_WIDTH = 80;
751
-
752
- // packages/utils/src/lib/logging.ts
754
+ import { underline } from "ansis";
753
755
  var singletonUiInstance;
754
756
  function ui() {
755
757
  if (singletonUiInstance === void 0) {
@@ -800,37 +802,8 @@ function filePathToCliArg(path) {
800
802
  return `"${path}"`;
801
803
  }
802
804
 
803
- // packages/utils/src/lib/text-formats/constants.ts
804
- var NEW_LINE = "\n";
805
- var TAB = " ";
806
-
807
- // packages/utils/src/lib/text-formats/html/details.ts
808
- function details(title, content, cfg = { open: false }) {
809
- 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.
810
- NEW_LINE}${content}${NEW_LINE}${// @TODO in the future we could consider adding it only if the content ends with a code block
811
- // ⚠️ The blank line ensure Markdown in content is rendered correctly.
812
- NEW_LINE}</details>${// ⚠️ The blank line is needed to ensure Markdown after details is rendered correctly.
813
- NEW_LINE}`;
814
- }
815
-
816
- // packages/utils/src/lib/text-formats/html/font-style.ts
817
- var boldElement = "b";
818
- function bold(text) {
819
- return `<${boldElement}>${text}</${boldElement}>`;
820
- }
821
- var italicElement = "i";
822
- function italic(text) {
823
- return `<${italicElement}>${text}</${italicElement}>`;
824
- }
825
- var codeElement = "code";
826
- function code(text) {
827
- return `<${codeElement}>${text}</${codeElement}>`;
828
- }
829
-
830
- // packages/utils/src/lib/text-formats/html/link.ts
831
- function link(href, text) {
832
- return `<a href="${href}">${text || href}</a>`;
833
- }
805
+ // packages/utils/src/lib/git/git.ts
806
+ import { simpleGit } from "simple-git";
834
807
 
835
808
  // packages/utils/src/lib/transform.ts
836
809
  function toArray(val) {
@@ -842,263 +815,6 @@ function objectToKeys(obj) {
842
815
  function distinct(array) {
843
816
  return [...new Set(array)];
844
817
  }
845
- function capitalize(text) {
846
- return `${text.charAt(0).toLocaleUpperCase()}${text.slice(
847
- 1
848
- )}`;
849
- }
850
-
851
- // packages/utils/src/lib/text-formats/table.ts
852
- function rowToStringArray({ rows, columns = [] }) {
853
- if (Array.isArray(rows.at(0)) && typeof columns.at(0) === "object") {
854
- throw new TypeError(
855
- "Column can`t be object when rows are primitive values"
856
- );
857
- }
858
- return rows.map((row) => {
859
- if (Array.isArray(row)) {
860
- return row.map(String);
861
- }
862
- const objectRow = row;
863
- if (columns.length === 0 || typeof columns.at(0) === "string") {
864
- return Object.values(objectRow).map(
865
- (value) => value == null ? "" : String(value)
866
- );
867
- }
868
- return columns.map(
869
- ({ key }) => objectRow[key] == null ? "" : String(objectRow[key])
870
- );
871
- });
872
- }
873
- function columnsToStringArray({
874
- rows,
875
- columns = []
876
- }) {
877
- const firstRow = rows.at(0);
878
- const primitiveRows = Array.isArray(firstRow);
879
- if (typeof columns.at(0) === "string" && !primitiveRows) {
880
- throw new Error("invalid union type. Caught by model parsing.");
881
- }
882
- if (columns.length === 0) {
883
- if (Array.isArray(firstRow)) {
884
- return firstRow.map((_, idx) => String(idx));
885
- }
886
- return Object.keys(firstRow);
887
- }
888
- if (typeof columns.at(0) === "string") {
889
- return columns.map(String);
890
- }
891
- const cols = columns;
892
- return cols.map(({ label, key }) => label ?? capitalize(key));
893
- }
894
- function getColumnAlignmentForKeyAndIndex(targetKey, targetIdx, columns = []) {
895
- const column = columns.at(targetIdx) ?? columns.find((col) => col.key === targetKey);
896
- if (typeof column === "string") {
897
- return column;
898
- } else if (typeof column === "object") {
899
- return column.align ?? "center";
900
- } else {
901
- return "center";
902
- }
903
- }
904
- function getColumnAlignmentForIndex(targetIdx, columns = []) {
905
- const column = columns.at(targetIdx);
906
- if (column == null) {
907
- return "center";
908
- } else if (typeof column === "string") {
909
- return column;
910
- } else if (typeof column === "object") {
911
- return column.align ?? "center";
912
- } else {
913
- return "center";
914
- }
915
- }
916
- function getColumnAlignments(tableData) {
917
- const { rows, columns = [] } = tableData;
918
- if (rows.at(0) == null) {
919
- throw new Error("first row can`t be undefined.");
920
- }
921
- if (Array.isArray(rows.at(0))) {
922
- const firstPrimitiveRow = rows.at(0);
923
- return Array.from({ length: firstPrimitiveRow.length }).map(
924
- (_, idx) => getColumnAlignmentForIndex(idx, columns)
925
- );
926
- }
927
- const biggestRow = [...rows].sort((a, b) => Object.keys(a).length - Object.keys(b).length).at(-1);
928
- if (columns.length > 0) {
929
- return columns.map(
930
- (column, idx) => typeof column === "string" ? column : getColumnAlignmentForKeyAndIndex(
931
- column.key,
932
- idx,
933
- columns
934
- )
935
- );
936
- }
937
- return Object.keys(biggestRow ?? {}).map((_) => "center");
938
- }
939
-
940
- // packages/utils/src/lib/text-formats/html/table.ts
941
- function wrap(elem, content) {
942
- return `<${elem}>${content}</${elem}>${NEW_LINE}`;
943
- }
944
- function wrapRow(content) {
945
- const elem = "tr";
946
- return `<${elem}>${NEW_LINE}${content}</${elem}>${NEW_LINE}`;
947
- }
948
- function table(tableData) {
949
- if (tableData.rows.length === 0) {
950
- throw new Error("Data can't be empty");
951
- }
952
- const tableHeaderCols = columnsToStringArray(tableData).map((s) => wrap("th", s)).join("");
953
- const tableHeaderRow = wrapRow(tableHeaderCols);
954
- const tableBody = rowToStringArray(tableData).map((arr) => {
955
- const columns = arr.map((s) => wrap("td", s)).join("");
956
- return wrapRow(columns);
957
- }).join("");
958
- return wrap("table", `${NEW_LINE}${tableHeaderRow}${tableBody}`);
959
- }
960
-
961
- // packages/utils/src/lib/text-formats/md/font-style.ts
962
- var boldWrap = "**";
963
- function bold2(text) {
964
- return `${boldWrap}${text}${boldWrap}`;
965
- }
966
- var italicWrap = "_";
967
- function italic2(text) {
968
- return `${italicWrap}${text}${italicWrap}`;
969
- }
970
- var strikeThroughWrap = "~";
971
- function strikeThrough(text) {
972
- return `${strikeThroughWrap}${text}${strikeThroughWrap}`;
973
- }
974
- var codeWrap = "`";
975
- function code2(text) {
976
- return `${codeWrap}${text}${codeWrap}`;
977
- }
978
-
979
- // packages/utils/src/lib/text-formats/md/headline.ts
980
- function headline(text, hierarchy = 1) {
981
- return `${"#".repeat(hierarchy)} ${text}${NEW_LINE}`;
982
- }
983
- function h(text, hierarchy = 1) {
984
- return headline(text, hierarchy);
985
- }
986
- function h1(text) {
987
- return headline(text, 1);
988
- }
989
- function h2(text) {
990
- return headline(text, 2);
991
- }
992
- function h3(text) {
993
- return headline(text, 3);
994
- }
995
- function h4(text) {
996
- return headline(text, 4);
997
- }
998
- function h5(text) {
999
- return headline(text, 5);
1000
- }
1001
- function h6(text) {
1002
- return headline(text, 6);
1003
- }
1004
-
1005
- // packages/utils/src/lib/text-formats/md/image.ts
1006
- function image(src, alt) {
1007
- return `![${alt}](${src})`;
1008
- }
1009
-
1010
- // packages/utils/src/lib/text-formats/md/link.ts
1011
- function link2(href, text) {
1012
- return `[${text || href}](${href})`;
1013
- }
1014
-
1015
- // packages/utils/src/lib/text-formats/md/list.ts
1016
- function li(text, order = "unordered") {
1017
- const style = order === "unordered" ? "-" : "- [ ]";
1018
- return `${style} ${text}`;
1019
- }
1020
- function indentation(text, level = 1) {
1021
- return `${TAB.repeat(level)}${text}`;
1022
- }
1023
-
1024
- // packages/utils/src/lib/text-formats/md/paragraphs.ts
1025
- function paragraphs(...sections) {
1026
- return sections.filter(Boolean).join(`${NEW_LINE}${NEW_LINE}`);
1027
- }
1028
-
1029
- // packages/utils/src/lib/text-formats/md/section.ts
1030
- function section(...contents) {
1031
- return `${lines(...contents)}${NEW_LINE}`;
1032
- }
1033
- function lines(...contents) {
1034
- const filteredContent = contents.filter(
1035
- (value) => value != null && value !== "" && value !== false
1036
- );
1037
- return `${filteredContent.join(NEW_LINE)}`;
1038
- }
1039
-
1040
- // packages/utils/src/lib/text-formats/md/table.ts
1041
- var alignString = /* @__PURE__ */ new Map([
1042
- ["left", ":--"],
1043
- ["center", ":--:"],
1044
- ["right", "--:"]
1045
- ]);
1046
- function tableRow(rows) {
1047
- return `|${rows.join("|")}|`;
1048
- }
1049
- function table2(data) {
1050
- if (data.rows.length === 0) {
1051
- throw new Error("Data can't be empty");
1052
- }
1053
- const alignmentRow = getColumnAlignments(data).map(
1054
- (s) => alignString.get(s) ?? String(alignString.get("center"))
1055
- );
1056
- return section(
1057
- `${lines(
1058
- tableRow(columnsToStringArray(data)),
1059
- tableRow(alignmentRow),
1060
- ...rowToStringArray(data).map(tableRow)
1061
- )}`
1062
- );
1063
- }
1064
-
1065
- // packages/utils/src/lib/text-formats/index.ts
1066
- var md = {
1067
- bold: bold2,
1068
- italic: italic2,
1069
- strikeThrough,
1070
- code: code2,
1071
- link: link2,
1072
- image,
1073
- headline,
1074
- h,
1075
- h1,
1076
- h2,
1077
- h3,
1078
- h4,
1079
- h5,
1080
- h6,
1081
- indentation,
1082
- lines,
1083
- li,
1084
- section,
1085
- paragraphs,
1086
- table: table2
1087
- };
1088
- var html = {
1089
- bold,
1090
- italic,
1091
- code,
1092
- link,
1093
- details,
1094
- table
1095
- };
1096
-
1097
- // packages/utils/src/lib/reports/utils.ts
1098
- var { image: image2, bold: boldMd } = md;
1099
-
1100
- // packages/utils/src/lib/git/git.ts
1101
- import { simpleGit } from "simple-git";
1102
818
 
1103
819
  // packages/utils/src/lib/git/git.commits-and-tags.ts
1104
820
  import { simpleGit as simpleGit2 } from "simple-git";
@@ -1107,34 +823,26 @@ import { simpleGit as simpleGit2 } from "simple-git";
1107
823
  import { rcompare, valid } from "semver";
1108
824
 
1109
825
  // packages/utils/src/lib/progress.ts
1110
- import chalk3 from "chalk";
826
+ import { black, bold as bold2, gray as gray2, green } from "ansis";
1111
827
  import { MultiProgressBars } from "multi-progress-bars";
1112
828
 
829
+ // packages/utils/src/lib/reports/generate-md-report.ts
830
+ import { MarkdownDocument as MarkdownDocument3, md as md4 } from "build-md";
831
+
1113
832
  // packages/utils/src/lib/reports/formatting.ts
1114
- var { headline: headline2, lines: lines2, link: link3, section: section2, table: table3 } = md;
833
+ import { MarkdownDocument, md as md2 } from "build-md";
1115
834
 
1116
835
  // packages/utils/src/lib/reports/generate-md-report-categoy-section.ts
1117
- var { link: link4, section: section3, h2: h22, lines: lines3, li: li2, bold: boldMd2, h3: h32, indentation: indentation2 } = md;
1118
-
1119
- // packages/utils/src/lib/reports/generate-md-report.ts
1120
- var { h1: h12, h2: h23, h3: h33, lines: lines4, link: link5, section: section4, code: codeMd } = md;
1121
- var { bold: boldHtml, details: details2 } = html;
836
+ import { MarkdownDocument as MarkdownDocument2, md as md3 } from "build-md";
1122
837
 
1123
838
  // packages/utils/src/lib/reports/generate-md-reports-diff.ts
1124
- var {
1125
- h1: h13,
1126
- h2: h24,
1127
- lines: lines5,
1128
- link: link6,
1129
- bold: boldMd3,
1130
- italic: italicMd,
1131
- table: table4,
1132
- section: section5
1133
- } = md;
1134
- var { details: details3 } = html;
839
+ import {
840
+ MarkdownDocument as MarkdownDocument4,
841
+ md as md5
842
+ } from "build-md";
1135
843
 
1136
844
  // packages/utils/src/lib/reports/log-stdout-summary.ts
1137
- import chalk4 from "chalk";
845
+ import { bold as bold4, cyan, cyanBright, green as green2, red } from "ansis";
1138
846
 
1139
847
  // packages/plugin-eslint/src/lib/config.ts
1140
848
  var patternsSchema = z16.union([z16.string(), z16.array(z16.string()).min(1)], {
@@ -1340,7 +1048,7 @@ function ruleToAudit({ ruleId, meta, options }) {
1340
1048
  const name2 = ruleId.split("/").at(-1) ?? ruleId;
1341
1049
  const plugin = name2 === ruleId ? null : ruleId.slice(0, ruleId.lastIndexOf("/"));
1342
1050
  const pluginContext = plugin ? `, from _${plugin}_ plugin` : "";
1343
- const lines6 = [
1051
+ const lines = [
1344
1052
  `ESLint rule **${name2}**${pluginContext}.`,
1345
1053
  ...options?.length ? ["Custom options:"] : [],
1346
1054
  ...options?.map(
@@ -1350,7 +1058,7 @@ function ruleToAudit({ ruleId, meta, options }) {
1350
1058
  return {
1351
1059
  slug: ruleIdToSlug(ruleId, options),
1352
1060
  title: truncateTitle(meta.docs?.description ?? name2),
1353
- description: truncateDescription(lines6.join("\n\n")),
1061
+ description: truncateDescription(lines.join("\n\n")),
1354
1062
  ...meta.docs?.url && {
1355
1063
  docsUrl: meta.docs.url
1356
1064
  }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@code-pushup/eslint-plugin",
3
- "version": "0.48.0",
3
+ "version": "0.49.0",
4
4
  "license": "MIT",
5
5
  "dependencies": {
6
- "@code-pushup/utils": "0.48.0",
7
- "@code-pushup/models": "0.48.0",
6
+ "@code-pushup/utils": "0.49.0",
7
+ "@code-pushup/models": "0.49.0",
8
8
  "eslint": "^8.46.0",
9
9
  "zod": "^3.22.4"
10
10
  },