@code-pushup/eslint-plugin 0.48.0 → 0.50.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 CHANGED
@@ -670,6 +670,8 @@ var auditResultSchema = scorableWithPluginMetaSchema.merge(
670
670
  );
671
671
  var reportsDiffSchema = z15.object({
672
672
  commits: makeComparisonSchema(commitSchema).nullable().describe("Commits identifying compared reports"),
673
+ portalUrl: urlSchema.optional().describe("Link to comparison page in Code PushUp portal"),
674
+ label: z15.string().optional().describe("Label (e.g. project name)"),
673
675
  categories: makeArraysComparisonSchema(
674
676
  categoryDiffSchema,
675
677
  categoryResultSchema,
@@ -698,11 +700,82 @@ var reportsDiffSchema = z15.object({
698
700
  );
699
701
 
700
702
  // packages/utils/src/lib/execute-process.ts
701
- import { spawn } from "node:child_process";
703
+ import {
704
+ spawn
705
+ } from "node:child_process";
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
+
714
+ // packages/utils/src/lib/reports/utils.ts
715
+ function calcDuration(start, stop) {
716
+ return Math.round((stop ?? performance.now()) - start);
717
+ }
718
+ function compareIssueSeverity(severity1, severity2) {
719
+ const levels = {
720
+ info: 0,
721
+ warning: 1,
722
+ error: 2
723
+ };
724
+ return levels[severity1] - levels[severity2];
725
+ }
726
+
727
+ // packages/utils/src/lib/execute-process.ts
728
+ var ProcessError = class extends Error {
729
+ code;
730
+ stderr;
731
+ stdout;
732
+ constructor(result) {
733
+ super(result.stderr);
734
+ this.code = result.code;
735
+ this.stderr = result.stderr;
736
+ this.stdout = result.stdout;
737
+ }
738
+ };
739
+ function executeProcess(cfg) {
740
+ const { command, args, observer, ignoreExitCode = false, ...options } = cfg;
741
+ const { onStdout, onStderr, onError, onComplete } = observer ?? {};
742
+ const date = (/* @__PURE__ */ new Date()).toISOString();
743
+ const start = performance.now();
744
+ return new Promise((resolve, reject) => {
745
+ const spawnedProcess = spawn(command, args ?? [], {
746
+ shell: true,
747
+ ...options
748
+ });
749
+ let stdout = "";
750
+ let stderr = "";
751
+ spawnedProcess.stdout.on("data", (data) => {
752
+ stdout += String(data);
753
+ onStdout?.(String(data), spawnedProcess);
754
+ });
755
+ spawnedProcess.stderr.on("data", (data) => {
756
+ stderr += String(data);
757
+ onStderr?.(String(data), spawnedProcess);
758
+ });
759
+ spawnedProcess.on("error", (err) => {
760
+ stderr += err.toString();
761
+ });
762
+ spawnedProcess.on("close", (code2) => {
763
+ const timings = { date, duration: calcDuration(start) };
764
+ if (code2 === 0 || ignoreExitCode) {
765
+ onComplete?.();
766
+ resolve({ code: code2, stdout, stderr, ...timings });
767
+ } else {
768
+ const errorMsg = new ProcessError({ code: code2, stdout, stderr, ...timings });
769
+ onError?.(errorMsg);
770
+ reject(errorMsg);
771
+ }
772
+ });
773
+ });
774
+ }
702
775
 
703
776
  // packages/utils/src/lib/file-system.ts
777
+ import { bold, gray } from "ansis";
704
778
  import { bundleRequire } from "bundle-require";
705
- import chalk2 from "chalk";
706
779
  import { mkdir, readFile, readdir, rm, stat } from "node:fs/promises";
707
780
  import { join } from "node:path";
708
781
 
@@ -752,12 +825,7 @@ function truncateIssueMessage(text) {
752
825
  // packages/utils/src/lib/logging.ts
753
826
  import isaacs_cliui from "@isaacs/cliui";
754
827
  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
828
+ import { underline } from "ansis";
761
829
  var singletonUiInstance;
762
830
  function ui() {
763
831
  if (singletonUiInstance === void 0) {
@@ -808,37 +876,8 @@ function filePathToCliArg(path) {
808
876
  return `"${path}"`;
809
877
  }
810
878
 
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
- }
879
+ // packages/utils/src/lib/git/git.ts
880
+ import { simpleGit } from "simple-git";
842
881
 
843
882
  // packages/utils/src/lib/transform.ts
844
883
  function toArray(val) {
@@ -856,319 +895,6 @@ function countOccurrences(values) {
856
895
  function distinct(array) {
857
896
  return [...new Set(array)];
858
897
  }
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
898
 
1173
899
  // packages/utils/src/lib/git/git.commits-and-tags.ts
1174
900
  import { simpleGit as simpleGit2 } from "simple-git";
@@ -1177,34 +903,32 @@ import { simpleGit as simpleGit2 } from "simple-git";
1177
903
  import { rcompare, valid } from "semver";
1178
904
 
1179
905
  // packages/utils/src/lib/progress.ts
1180
- import chalk3 from "chalk";
906
+ import { black, bold as bold2, gray as gray2, green } from "ansis";
1181
907
  import { MultiProgressBars } from "multi-progress-bars";
1182
908
 
909
+ // packages/utils/src/lib/reports/generate-md-report.ts
910
+ import { MarkdownDocument as MarkdownDocument3, md as md4 } from "build-md";
911
+
1183
912
  // packages/utils/src/lib/reports/formatting.ts
1184
- var { headline: headline2, lines: lines2, link: link3, section: section2, table: table3 } = md;
913
+ import {
914
+ MarkdownDocument,
915
+ md as md2
916
+ } from "build-md";
1185
917
 
1186
918
  // 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;
919
+ import { MarkdownDocument as MarkdownDocument2, md as md3 } from "build-md";
1192
920
 
1193
921
  // 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;
922
+ import {
923
+ MarkdownDocument as MarkdownDocument5,
924
+ md as md6
925
+ } from "build-md";
926
+
927
+ // packages/utils/src/lib/reports/generate-md-reports-diff-utils.ts
928
+ import { MarkdownDocument as MarkdownDocument4, md as md5 } from "build-md";
1205
929
 
1206
930
  // packages/utils/src/lib/reports/log-stdout-summary.ts
1207
- import chalk4 from "chalk";
931
+ import { bold as bold4, cyan, cyanBright, green as green2, red } from "ansis";
1208
932
 
1209
933
  // packages/plugin-eslint/src/lib/runner/lint.ts
1210
934
  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.50.0";
8
8
 
9
9
  // packages/plugin-eslint/src/lib/config.ts
10
10
  import { z as z16 } from "zod";
@@ -677,6 +677,8 @@ var auditResultSchema = scorableWithPluginMetaSchema.merge(
677
677
  );
678
678
  var reportsDiffSchema = z15.object({
679
679
  commits: makeComparisonSchema(commitSchema).nullable().describe("Commits identifying compared reports"),
680
+ portalUrl: urlSchema.optional().describe("Link to comparison page in Code PushUp portal"),
681
+ label: z15.string().optional().describe("Label (e.g. project name)"),
680
682
  categories: makeArraysComparisonSchema(
681
683
  categoryDiffSchema,
682
684
  categoryResultSchema,
@@ -704,9 +706,16 @@ var reportsDiffSchema = z15.object({
704
706
  })
705
707
  );
706
708
 
709
+ // packages/utils/src/lib/reports/utils.ts
710
+ import ansis from "ansis";
711
+ import { md } from "build-md";
712
+
713
+ // packages/utils/src/lib/reports/constants.ts
714
+ var TERMINAL_WIDTH = 80;
715
+
707
716
  // packages/utils/src/lib/file-system.ts
717
+ import { bold, gray } from "ansis";
708
718
  import { bundleRequire } from "bundle-require";
709
- import chalk2 from "chalk";
710
719
  import { mkdir, readFile, readdir, rm, stat } from "node:fs/promises";
711
720
  import { join } from "node:path";
712
721
 
@@ -744,12 +753,7 @@ function truncateDescription(text) {
744
753
  // packages/utils/src/lib/logging.ts
745
754
  import isaacs_cliui from "@isaacs/cliui";
746
755
  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
756
+ import { underline } from "ansis";
753
757
  var singletonUiInstance;
754
758
  function ui() {
755
759
  if (singletonUiInstance === void 0) {
@@ -800,37 +804,8 @@ function filePathToCliArg(path) {
800
804
  return `"${path}"`;
801
805
  }
802
806
 
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
- }
807
+ // packages/utils/src/lib/git/git.ts
808
+ import { simpleGit } from "simple-git";
834
809
 
835
810
  // packages/utils/src/lib/transform.ts
836
811
  function toArray(val) {
@@ -842,263 +817,6 @@ function objectToKeys(obj) {
842
817
  function distinct(array) {
843
818
  return [...new Set(array)];
844
819
  }
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
820
 
1103
821
  // packages/utils/src/lib/git/git.commits-and-tags.ts
1104
822
  import { simpleGit as simpleGit2 } from "simple-git";
@@ -1107,34 +825,32 @@ import { simpleGit as simpleGit2 } from "simple-git";
1107
825
  import { rcompare, valid } from "semver";
1108
826
 
1109
827
  // packages/utils/src/lib/progress.ts
1110
- import chalk3 from "chalk";
828
+ import { black, bold as bold2, gray as gray2, green } from "ansis";
1111
829
  import { MultiProgressBars } from "multi-progress-bars";
1112
830
 
831
+ // packages/utils/src/lib/reports/generate-md-report.ts
832
+ import { MarkdownDocument as MarkdownDocument3, md as md4 } from "build-md";
833
+
1113
834
  // packages/utils/src/lib/reports/formatting.ts
1114
- var { headline: headline2, lines: lines2, link: link3, section: section2, table: table3 } = md;
835
+ import {
836
+ MarkdownDocument,
837
+ md as md2
838
+ } from "build-md";
1115
839
 
1116
840
  // 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;
841
+ import { MarkdownDocument as MarkdownDocument2, md as md3 } from "build-md";
1122
842
 
1123
843
  // 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;
844
+ import {
845
+ MarkdownDocument as MarkdownDocument5,
846
+ md as md6
847
+ } from "build-md";
848
+
849
+ // packages/utils/src/lib/reports/generate-md-reports-diff-utils.ts
850
+ import { MarkdownDocument as MarkdownDocument4, md as md5 } from "build-md";
1135
851
 
1136
852
  // packages/utils/src/lib/reports/log-stdout-summary.ts
1137
- import chalk4 from "chalk";
853
+ import { bold as bold4, cyan, cyanBright, green as green2, red } from "ansis";
1138
854
 
1139
855
  // packages/plugin-eslint/src/lib/config.ts
1140
856
  var patternsSchema = z16.union([z16.string(), z16.array(z16.string()).min(1)], {
@@ -1340,7 +1056,7 @@ function ruleToAudit({ ruleId, meta, options }) {
1340
1056
  const name2 = ruleId.split("/").at(-1) ?? ruleId;
1341
1057
  const plugin = name2 === ruleId ? null : ruleId.slice(0, ruleId.lastIndexOf("/"));
1342
1058
  const pluginContext = plugin ? `, from _${plugin}_ plugin` : "";
1343
- const lines6 = [
1059
+ const lines = [
1344
1060
  `ESLint rule **${name2}**${pluginContext}.`,
1345
1061
  ...options?.length ? ["Custom options:"] : [],
1346
1062
  ...options?.map(
@@ -1350,7 +1066,7 @@ function ruleToAudit({ ruleId, meta, options }) {
1350
1066
  return {
1351
1067
  slug: ruleIdToSlug(ruleId, options),
1352
1068
  title: truncateTitle(meta.docs?.description ?? name2),
1353
- description: truncateDescription(lines6.join("\n\n")),
1069
+ description: truncateDescription(lines.join("\n\n")),
1354
1070
  ...meta.docs?.url && {
1355
1071
  docsUrl: meta.docs.url
1356
1072
  }
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@code-pushup/eslint-plugin",
3
- "version": "0.48.0",
3
+ "version": "0.50.0",
4
4
  "license": "MIT",
5
+ "description": "Code PushUp plugin for detecting problems in source code using ESLint.📋",
5
6
  "dependencies": {
6
- "@code-pushup/utils": "0.48.0",
7
- "@code-pushup/models": "0.48.0",
7
+ "@code-pushup/utils": "0.50.0",
8
+ "@code-pushup/models": "0.50.0",
8
9
  "eslint": "^8.46.0",
9
10
  "zod": "^3.22.4"
10
11
  },
@@ -16,7 +17,7 @@
16
17
  "optional": true
17
18
  }
18
19
  },
19
- "homepage": "https://github.com/code-pushup/cli#readme",
20
+ "homepage": "https://github.com/code-pushup/cli/tree/main/packages/plugin-eslint#readme",
20
21
  "bugs": {
21
22
  "url": "https://github.com/code-pushup/cli/issues"
22
23
  },
@@ -25,33 +26,6 @@
25
26
  "url": "git+https://github.com/code-pushup/cli.git",
26
27
  "directory": "packages/plugin-eslint"
27
28
  },
28
- "contributors": [
29
- {
30
- "name": "Igor Katsuba",
31
- "email": "igor@katsuba.dev",
32
- "url": "https://katsuba.dev"
33
- },
34
- {
35
- "name": "Kateřina Pilátová",
36
- "email": "katerina.pilatova@flowup.cz",
37
- "url": "https://github.com/Tlacenka"
38
- },
39
- {
40
- "name": "Matěj Chalk",
41
- "email": "matej.chalk@flowup.cz",
42
- "url": "https://github.com/matejchalk"
43
- },
44
- {
45
- "name": "Michael Hladky",
46
- "email": "michael.hladky@push-based.io",
47
- "url": "https://push-based.io"
48
- },
49
- {
50
- "name": "Michael Seredenko",
51
- "email": "misha.seredenko@push-based.io",
52
- "url": "https://github.com/MishaSeredenkoPushBased"
53
- }
54
- ],
55
29
  "type": "module",
56
30
  "main": "./index.js",
57
31
  "types": "./src/index.d.ts"
@@ -1,5 +1,5 @@
1
- import { PluginConfig } from '@code-pushup/models';
2
- import { ESLintPluginConfig } from './config';
1
+ import type { PluginConfig } from '@code-pushup/models';
2
+ import { type ESLintPluginConfig } from './config';
3
3
  /**
4
4
  * Instantiates Code PushUp ESLint plugin for use in core config.
5
5
  *
@@ -1,3 +1,3 @@
1
1
  import type { Audit } from '@code-pushup/models';
2
- import { RuleData } from './rules';
2
+ import type { RuleData } from './rules';
3
3
  export declare function ruleToAudit({ ruleId, meta, options }: RuleData): Audit;
@@ -1,5 +1,5 @@
1
1
  import type { Audit, RunnerConfig } from '@code-pushup/models';
2
- import { type ESLintTarget } from '../config';
2
+ import type { ESLintTarget } from '../config';
3
3
  export declare const WORKDIR: string;
4
4
  export declare const RUNNER_OUTPUT_PATH: string;
5
5
  export declare const PLUGIN_CONFIG_PATH: string;