@code-pushup/eslint-plugin 0.45.1 → 0.47.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 +46 -20
- package/index.js +47 -21
- package/package.json +3 -3
- package/src/lib/config.d.ts +15 -15
package/bin.js
CHANGED
|
@@ -67,7 +67,7 @@ function missingRefsForCategoriesErrorMsg(categories, plugins) {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
// packages/models/src/lib/implementation/schemas.ts
|
|
70
|
-
var
|
|
70
|
+
var tableCellValueSchema = z.union([z.string(), z.number(), z.boolean(), z.null()]).default(null);
|
|
71
71
|
function executionMetaSchema(options = {
|
|
72
72
|
descriptionDate: "Execution start date and time",
|
|
73
73
|
descriptionDuration: "Execution duration in ms"
|
|
@@ -231,10 +231,10 @@ var tableColumnObjectSchema = z4.object({
|
|
|
231
231
|
label: z4.string().optional(),
|
|
232
232
|
align: tableAlignmentSchema.optional()
|
|
233
233
|
});
|
|
234
|
-
var tableRowObjectSchema = z4.record(
|
|
234
|
+
var tableRowObjectSchema = z4.record(tableCellValueSchema, {
|
|
235
235
|
description: "Object row"
|
|
236
236
|
});
|
|
237
|
-
var tableRowPrimitiveSchema = z4.array(
|
|
237
|
+
var tableRowPrimitiveSchema = z4.array(tableCellValueSchema, {
|
|
238
238
|
description: "Primitive row"
|
|
239
239
|
});
|
|
240
240
|
var tableSharedSchema = z4.object({
|
|
@@ -725,12 +725,25 @@ function pluralize(text, amount) {
|
|
|
725
725
|
function pluralizeToken(token, times) {
|
|
726
726
|
return `${times} ${Math.abs(times) === 1 ? token : pluralize(token)}`;
|
|
727
727
|
}
|
|
728
|
-
function truncateText(text,
|
|
728
|
+
function truncateText(text, options) {
|
|
729
|
+
const {
|
|
730
|
+
maxChars,
|
|
731
|
+
position = "end",
|
|
732
|
+
ellipsis = "..."
|
|
733
|
+
} = typeof options === "number" ? { maxChars: options } : options;
|
|
729
734
|
if (text.length <= maxChars) {
|
|
730
735
|
return text;
|
|
731
736
|
}
|
|
732
|
-
const
|
|
733
|
-
|
|
737
|
+
const maxLength = maxChars - ellipsis.length;
|
|
738
|
+
switch (position) {
|
|
739
|
+
case "start":
|
|
740
|
+
return ellipsis + text.slice(-maxLength).trim();
|
|
741
|
+
case "middle":
|
|
742
|
+
const halfMaxChars = Math.floor(maxLength / 2);
|
|
743
|
+
return text.slice(0, halfMaxChars).trim() + ellipsis + text.slice(-halfMaxChars).trim();
|
|
744
|
+
case "end":
|
|
745
|
+
return text.slice(0, maxLength).trim() + ellipsis;
|
|
746
|
+
}
|
|
734
747
|
}
|
|
735
748
|
function truncateIssueMessage(text) {
|
|
736
749
|
return truncateText(text, MAX_ISSUE_MESSAGE_LENGTH);
|
|
@@ -824,7 +837,7 @@ function code(text) {
|
|
|
824
837
|
|
|
825
838
|
// packages/utils/src/lib/text-formats/html/link.ts
|
|
826
839
|
function link(href, text) {
|
|
827
|
-
return `<a href="${href}">${text || href}
|
|
840
|
+
return `<a href="${href}">${text || href}</a>`;
|
|
828
841
|
}
|
|
829
842
|
|
|
830
843
|
// packages/utils/src/lib/transform.ts
|
|
@@ -849,7 +862,7 @@ function capitalize(text) {
|
|
|
849
862
|
)}`;
|
|
850
863
|
}
|
|
851
864
|
|
|
852
|
-
// packages/utils/src/lib/table.ts
|
|
865
|
+
// packages/utils/src/lib/text-formats/table.ts
|
|
853
866
|
function rowToStringArray({ rows, columns = [] }) {
|
|
854
867
|
if (Array.isArray(rows.at(0)) && typeof columns.at(0) === "object") {
|
|
855
868
|
throw new TypeError(
|
|
@@ -862,14 +875,19 @@ function rowToStringArray({ rows, columns = [] }) {
|
|
|
862
875
|
}
|
|
863
876
|
const objectRow = row;
|
|
864
877
|
if (columns.length === 0 || typeof columns.at(0) === "string") {
|
|
865
|
-
return Object.values(objectRow).map(
|
|
878
|
+
return Object.values(objectRow).map(
|
|
879
|
+
(value) => value == null ? "" : String(value)
|
|
880
|
+
);
|
|
866
881
|
}
|
|
867
882
|
return columns.map(
|
|
868
|
-
({ key }) => String(objectRow[key])
|
|
883
|
+
({ key }) => objectRow[key] == null ? "" : String(objectRow[key])
|
|
869
884
|
);
|
|
870
885
|
});
|
|
871
886
|
}
|
|
872
|
-
function columnsToStringArray({
|
|
887
|
+
function columnsToStringArray({
|
|
888
|
+
rows,
|
|
889
|
+
columns = []
|
|
890
|
+
}) {
|
|
873
891
|
const firstRow = rows.at(0);
|
|
874
892
|
const primitiveRows = Array.isArray(firstRow);
|
|
875
893
|
if (typeof columns.at(0) === "string" && !primitiveRows) {
|
|
@@ -909,10 +927,8 @@ function getColumnAlignmentForIndex(targetIdx, columns = []) {
|
|
|
909
927
|
return "center";
|
|
910
928
|
}
|
|
911
929
|
}
|
|
912
|
-
function getColumnAlignments({
|
|
913
|
-
rows,
|
|
914
|
-
columns = []
|
|
915
|
-
}) {
|
|
930
|
+
function getColumnAlignments(tableData) {
|
|
931
|
+
const { rows, columns = [] } = tableData;
|
|
916
932
|
if (rows.at(0) == null) {
|
|
917
933
|
throw new Error("first row can`t be undefined.");
|
|
918
934
|
}
|
|
@@ -922,10 +938,17 @@ function getColumnAlignments({
|
|
|
922
938
|
(_, idx) => getColumnAlignmentForIndex(idx, columns)
|
|
923
939
|
);
|
|
924
940
|
}
|
|
925
|
-
const
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
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");
|
|
929
952
|
}
|
|
930
953
|
|
|
931
954
|
// packages/utils/src/lib/text-formats/html/table.ts
|
|
@@ -1022,7 +1045,10 @@ function section(...contents) {
|
|
|
1022
1045
|
return `${lines(...contents)}${NEW_LINE}`;
|
|
1023
1046
|
}
|
|
1024
1047
|
function lines(...contents) {
|
|
1025
|
-
|
|
1048
|
+
const filteredContent = contents.filter(
|
|
1049
|
+
(value) => value != null && value !== "" && value !== false
|
|
1050
|
+
);
|
|
1051
|
+
return `${filteredContent.join(NEW_LINE)}`;
|
|
1026
1052
|
}
|
|
1027
1053
|
|
|
1028
1054
|
// packages/utils/src/lib/text-formats/md/table.ts
|
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.
|
|
7
|
+
var version = "0.47.0";
|
|
8
8
|
|
|
9
9
|
// packages/plugin-eslint/src/lib/config.ts
|
|
10
10
|
import { z as z16 } from "zod";
|
|
@@ -74,7 +74,7 @@ function missingRefsForCategoriesErrorMsg(categories, plugins) {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
// packages/models/src/lib/implementation/schemas.ts
|
|
77
|
-
var
|
|
77
|
+
var tableCellValueSchema = z.union([z.string(), z.number(), z.boolean(), z.null()]).default(null);
|
|
78
78
|
function executionMetaSchema(options = {
|
|
79
79
|
descriptionDate: "Execution start date and time",
|
|
80
80
|
descriptionDuration: "Execution duration in ms"
|
|
@@ -238,10 +238,10 @@ var tableColumnObjectSchema = z4.object({
|
|
|
238
238
|
label: z4.string().optional(),
|
|
239
239
|
align: tableAlignmentSchema.optional()
|
|
240
240
|
});
|
|
241
|
-
var tableRowObjectSchema = z4.record(
|
|
241
|
+
var tableRowObjectSchema = z4.record(tableCellValueSchema, {
|
|
242
242
|
description: "Object row"
|
|
243
243
|
});
|
|
244
|
-
var tableRowPrimitiveSchema = z4.array(
|
|
244
|
+
var tableRowPrimitiveSchema = z4.array(tableCellValueSchema, {
|
|
245
245
|
description: "Primitive row"
|
|
246
246
|
});
|
|
247
247
|
var tableSharedSchema = z4.object({
|
|
@@ -714,12 +714,25 @@ import { join } from "node:path";
|
|
|
714
714
|
function slugify(text) {
|
|
715
715
|
return text.trim().toLowerCase().replace(/\s+|\//g, "-").replace(/[^a-z\d-]/g, "");
|
|
716
716
|
}
|
|
717
|
-
function truncateText(text,
|
|
717
|
+
function truncateText(text, options) {
|
|
718
|
+
const {
|
|
719
|
+
maxChars,
|
|
720
|
+
position = "end",
|
|
721
|
+
ellipsis = "..."
|
|
722
|
+
} = typeof options === "number" ? { maxChars: options } : options;
|
|
718
723
|
if (text.length <= maxChars) {
|
|
719
724
|
return text;
|
|
720
725
|
}
|
|
721
|
-
const
|
|
722
|
-
|
|
726
|
+
const maxLength = maxChars - ellipsis.length;
|
|
727
|
+
switch (position) {
|
|
728
|
+
case "start":
|
|
729
|
+
return ellipsis + text.slice(-maxLength).trim();
|
|
730
|
+
case "middle":
|
|
731
|
+
const halfMaxChars = Math.floor(maxLength / 2);
|
|
732
|
+
return text.slice(0, halfMaxChars).trim() + ellipsis + text.slice(-halfMaxChars).trim();
|
|
733
|
+
case "end":
|
|
734
|
+
return text.slice(0, maxLength).trim() + ellipsis;
|
|
735
|
+
}
|
|
723
736
|
}
|
|
724
737
|
function truncateTitle(text) {
|
|
725
738
|
return truncateText(text, MAX_TITLE_LENGTH);
|
|
@@ -816,7 +829,7 @@ function code(text) {
|
|
|
816
829
|
|
|
817
830
|
// packages/utils/src/lib/text-formats/html/link.ts
|
|
818
831
|
function link(href, text) {
|
|
819
|
-
return `<a href="${href}">${text || href}
|
|
832
|
+
return `<a href="${href}">${text || href}</a>`;
|
|
820
833
|
}
|
|
821
834
|
|
|
822
835
|
// packages/utils/src/lib/transform.ts
|
|
@@ -835,7 +848,7 @@ function capitalize(text) {
|
|
|
835
848
|
)}`;
|
|
836
849
|
}
|
|
837
850
|
|
|
838
|
-
// packages/utils/src/lib/table.ts
|
|
851
|
+
// packages/utils/src/lib/text-formats/table.ts
|
|
839
852
|
function rowToStringArray({ rows, columns = [] }) {
|
|
840
853
|
if (Array.isArray(rows.at(0)) && typeof columns.at(0) === "object") {
|
|
841
854
|
throw new TypeError(
|
|
@@ -848,14 +861,19 @@ function rowToStringArray({ rows, columns = [] }) {
|
|
|
848
861
|
}
|
|
849
862
|
const objectRow = row;
|
|
850
863
|
if (columns.length === 0 || typeof columns.at(0) === "string") {
|
|
851
|
-
return Object.values(objectRow).map(
|
|
864
|
+
return Object.values(objectRow).map(
|
|
865
|
+
(value) => value == null ? "" : String(value)
|
|
866
|
+
);
|
|
852
867
|
}
|
|
853
868
|
return columns.map(
|
|
854
|
-
({ key }) => String(objectRow[key])
|
|
869
|
+
({ key }) => objectRow[key] == null ? "" : String(objectRow[key])
|
|
855
870
|
);
|
|
856
871
|
});
|
|
857
872
|
}
|
|
858
|
-
function columnsToStringArray({
|
|
873
|
+
function columnsToStringArray({
|
|
874
|
+
rows,
|
|
875
|
+
columns = []
|
|
876
|
+
}) {
|
|
859
877
|
const firstRow = rows.at(0);
|
|
860
878
|
const primitiveRows = Array.isArray(firstRow);
|
|
861
879
|
if (typeof columns.at(0) === "string" && !primitiveRows) {
|
|
@@ -895,10 +913,8 @@ function getColumnAlignmentForIndex(targetIdx, columns = []) {
|
|
|
895
913
|
return "center";
|
|
896
914
|
}
|
|
897
915
|
}
|
|
898
|
-
function getColumnAlignments({
|
|
899
|
-
rows,
|
|
900
|
-
columns = []
|
|
901
|
-
}) {
|
|
916
|
+
function getColumnAlignments(tableData) {
|
|
917
|
+
const { rows, columns = [] } = tableData;
|
|
902
918
|
if (rows.at(0) == null) {
|
|
903
919
|
throw new Error("first row can`t be undefined.");
|
|
904
920
|
}
|
|
@@ -908,10 +924,17 @@ function getColumnAlignments({
|
|
|
908
924
|
(_, idx) => getColumnAlignmentForIndex(idx, columns)
|
|
909
925
|
);
|
|
910
926
|
}
|
|
911
|
-
const
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
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");
|
|
915
938
|
}
|
|
916
939
|
|
|
917
940
|
// packages/utils/src/lib/text-formats/html/table.ts
|
|
@@ -1008,7 +1031,10 @@ function section(...contents) {
|
|
|
1008
1031
|
return `${lines(...contents)}${NEW_LINE}`;
|
|
1009
1032
|
}
|
|
1010
1033
|
function lines(...contents) {
|
|
1011
|
-
|
|
1034
|
+
const filteredContent = contents.filter(
|
|
1035
|
+
(value) => value != null && value !== "" && value !== false
|
|
1036
|
+
);
|
|
1037
|
+
return `${filteredContent.join(NEW_LINE)}`;
|
|
1012
1038
|
}
|
|
1013
1039
|
|
|
1014
1040
|
// packages/utils/src/lib/text-formats/md/table.ts
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@code-pushup/eslint-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.47.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@code-pushup/utils": "0.
|
|
7
|
-
"@code-pushup/models": "0.
|
|
6
|
+
"@code-pushup/utils": "0.47.0",
|
|
7
|
+
"@code-pushup/models": "0.47.0",
|
|
8
8
|
"eslint": "^8.46.0",
|
|
9
9
|
"zod": "^3.22.4"
|
|
10
10
|
},
|
package/src/lib/config.d.ts
CHANGED
|
@@ -4,16 +4,16 @@ export declare const eslintTargetSchema: z.ZodEffects<z.ZodUnion<[z.ZodUnion<[z.
|
|
|
4
4
|
eslintrc: z.ZodOptional<z.ZodUnion<[z.ZodString, ZodType<ESLint.ConfigData<import("eslint").Linter.RulesRecord>, z.ZodTypeDef, ESLint.ConfigData<import("eslint").Linter.RulesRecord>>]>>;
|
|
5
5
|
patterns: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
|
|
6
6
|
}, "strip", z.ZodTypeAny, {
|
|
7
|
-
patterns:
|
|
7
|
+
patterns: string | string[];
|
|
8
8
|
eslintrc?: string | ESLint.ConfigData<import("eslint").Linter.RulesRecord> | undefined;
|
|
9
9
|
}, {
|
|
10
|
-
patterns:
|
|
10
|
+
patterns: string | string[];
|
|
11
11
|
eslintrc?: string | ESLint.ConfigData<import("eslint").Linter.RulesRecord> | undefined;
|
|
12
12
|
}>]>, {
|
|
13
|
-
patterns:
|
|
13
|
+
patterns: string | string[];
|
|
14
14
|
eslintrc?: string | ESLint.ConfigData<import("eslint").Linter.RulesRecord> | undefined;
|
|
15
15
|
}, string | string[] | {
|
|
16
|
-
patterns:
|
|
16
|
+
patterns: string | string[];
|
|
17
17
|
eslintrc?: string | ESLint.ConfigData<import("eslint").Linter.RulesRecord> | undefined;
|
|
18
18
|
}>;
|
|
19
19
|
export type ESLintTarget = z.infer<typeof eslintTargetSchema>;
|
|
@@ -21,40 +21,40 @@ export declare const eslintPluginConfigSchema: z.ZodEffects<z.ZodUnion<[z.ZodEff
|
|
|
21
21
|
eslintrc: z.ZodOptional<z.ZodUnion<[z.ZodString, ZodType<ESLint.ConfigData<import("eslint").Linter.RulesRecord>, z.ZodTypeDef, ESLint.ConfigData<import("eslint").Linter.RulesRecord>>]>>;
|
|
22
22
|
patterns: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
|
|
23
23
|
}, "strip", z.ZodTypeAny, {
|
|
24
|
-
patterns:
|
|
24
|
+
patterns: string | string[];
|
|
25
25
|
eslintrc?: string | ESLint.ConfigData<import("eslint").Linter.RulesRecord> | undefined;
|
|
26
26
|
}, {
|
|
27
|
-
patterns:
|
|
27
|
+
patterns: string | string[];
|
|
28
28
|
eslintrc?: string | ESLint.ConfigData<import("eslint").Linter.RulesRecord> | undefined;
|
|
29
29
|
}>]>, {
|
|
30
|
-
patterns:
|
|
30
|
+
patterns: string | string[];
|
|
31
31
|
eslintrc?: string | ESLint.ConfigData<import("eslint").Linter.RulesRecord> | undefined;
|
|
32
32
|
}, string | string[] | {
|
|
33
|
-
patterns:
|
|
33
|
+
patterns: string | string[];
|
|
34
34
|
eslintrc?: string | ESLint.ConfigData<import("eslint").Linter.RulesRecord> | undefined;
|
|
35
35
|
}>, z.ZodArray<z.ZodEffects<z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
|
|
36
36
|
eslintrc: z.ZodOptional<z.ZodUnion<[z.ZodString, ZodType<ESLint.ConfigData<import("eslint").Linter.RulesRecord>, z.ZodTypeDef, ESLint.ConfigData<import("eslint").Linter.RulesRecord>>]>>;
|
|
37
37
|
patterns: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
|
|
38
38
|
}, "strip", z.ZodTypeAny, {
|
|
39
|
-
patterns:
|
|
39
|
+
patterns: string | string[];
|
|
40
40
|
eslintrc?: string | ESLint.ConfigData<import("eslint").Linter.RulesRecord> | undefined;
|
|
41
41
|
}, {
|
|
42
|
-
patterns:
|
|
42
|
+
patterns: string | string[];
|
|
43
43
|
eslintrc?: string | ESLint.ConfigData<import("eslint").Linter.RulesRecord> | undefined;
|
|
44
44
|
}>]>, {
|
|
45
|
-
patterns:
|
|
45
|
+
patterns: string | string[];
|
|
46
46
|
eslintrc?: string | ESLint.ConfigData<import("eslint").Linter.RulesRecord> | undefined;
|
|
47
47
|
}, string | string[] | {
|
|
48
|
-
patterns:
|
|
48
|
+
patterns: string | string[];
|
|
49
49
|
eslintrc?: string | ESLint.ConfigData<import("eslint").Linter.RulesRecord> | undefined;
|
|
50
50
|
}>, "many">]>, {
|
|
51
|
-
patterns:
|
|
51
|
+
patterns: string | string[];
|
|
52
52
|
eslintrc?: string | ESLint.ConfigData<import("eslint").Linter.RulesRecord> | undefined;
|
|
53
53
|
}[], string | string[] | {
|
|
54
|
-
patterns:
|
|
54
|
+
patterns: string | string[];
|
|
55
55
|
eslintrc?: string | ESLint.ConfigData<import("eslint").Linter.RulesRecord> | undefined;
|
|
56
56
|
} | (string | string[] | {
|
|
57
|
-
patterns:
|
|
57
|
+
patterns: string | string[];
|
|
58
58
|
eslintrc?: string | ESLint.ConfigData<import("eslint").Linter.RulesRecord> | undefined;
|
|
59
59
|
})[]>;
|
|
60
60
|
export type ESLintPluginConfig = z.input<typeof eslintPluginConfigSchema>;
|