@code-pushup/eslint-plugin 0.4.4 → 0.5.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 +11 -6
- package/index.js +13 -8
- package/package.json +1 -1
package/bin.js
CHANGED
|
@@ -122,12 +122,14 @@ function scorableSchema(description, refSchema, duplicateCheckFn, duplicateMessa
|
|
|
122
122
|
return z.object(
|
|
123
123
|
{
|
|
124
124
|
slug: slugSchema('Human-readable unique ID, e.g. "performance"'),
|
|
125
|
-
refs: z.array(refSchema).refine(
|
|
125
|
+
refs: z.array(refSchema).min(1).refine(
|
|
126
126
|
(refs) => !duplicateCheckFn(refs),
|
|
127
127
|
(refs) => ({
|
|
128
128
|
message: duplicateMessageFn(refs)
|
|
129
129
|
})
|
|
130
|
-
)
|
|
130
|
+
).refine(hasWeightedRefsInCategories, () => ({
|
|
131
|
+
message: `In a category there has to be at least one ref with weight > 0`
|
|
132
|
+
}))
|
|
131
133
|
},
|
|
132
134
|
{ description }
|
|
133
135
|
);
|
|
@@ -136,6 +138,9 @@ var materialIconSchema = z.enum(
|
|
|
136
138
|
MATERIAL_ICONS,
|
|
137
139
|
{ description: "Icon from VSCode Material Icons extension" }
|
|
138
140
|
);
|
|
141
|
+
function hasWeightedRefsInCategories(categoryRefs) {
|
|
142
|
+
return categoryRefs.reduce((acc, { weight }) => weight + acc, 0) !== 0;
|
|
143
|
+
}
|
|
139
144
|
|
|
140
145
|
// packages/models/src/lib/category-config.ts
|
|
141
146
|
var categoryRefSchema = weightedRefSchema(
|
|
@@ -433,10 +438,10 @@ var unrefinedCoreConfigSchema = z11.object({
|
|
|
433
438
|
upload: uploadConfigSchema.optional(),
|
|
434
439
|
categories: z11.array(categoryConfigSchema, {
|
|
435
440
|
description: "Categorization of individual audits"
|
|
436
|
-
}).refine(
|
|
437
|
-
(
|
|
438
|
-
(
|
|
439
|
-
message: duplicateSlugCategoriesErrorMsg(
|
|
441
|
+
}).min(1).refine(
|
|
442
|
+
(categories) => !getDuplicateSlugCategories(categories),
|
|
443
|
+
(categories) => ({
|
|
444
|
+
message: duplicateSlugCategoriesErrorMsg(categories)
|
|
440
445
|
})
|
|
441
446
|
)
|
|
442
447
|
});
|
package/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { fileURLToPath } from "url";
|
|
|
5
5
|
|
|
6
6
|
// packages/plugin-eslint/package.json
|
|
7
7
|
var name = "@code-pushup/eslint-plugin";
|
|
8
|
-
var version = "0.
|
|
8
|
+
var version = "0.5.0";
|
|
9
9
|
|
|
10
10
|
// packages/plugin-eslint/src/lib/config.ts
|
|
11
11
|
import { z } from "zod";
|
|
@@ -144,12 +144,14 @@ function scorableSchema(description, refSchema, duplicateCheckFn, duplicateMessa
|
|
|
144
144
|
return z2.object(
|
|
145
145
|
{
|
|
146
146
|
slug: slugSchema('Human-readable unique ID, e.g. "performance"'),
|
|
147
|
-
refs: z2.array(refSchema).refine(
|
|
147
|
+
refs: z2.array(refSchema).min(1).refine(
|
|
148
148
|
(refs) => !duplicateCheckFn(refs),
|
|
149
149
|
(refs) => ({
|
|
150
150
|
message: duplicateMessageFn(refs)
|
|
151
151
|
})
|
|
152
|
-
)
|
|
152
|
+
).refine(hasWeightedRefsInCategories, () => ({
|
|
153
|
+
message: `In a category there has to be at least one ref with weight > 0`
|
|
154
|
+
}))
|
|
153
155
|
},
|
|
154
156
|
{ description }
|
|
155
157
|
);
|
|
@@ -158,6 +160,9 @@ var materialIconSchema = z2.enum(
|
|
|
158
160
|
MATERIAL_ICONS,
|
|
159
161
|
{ description: "Icon from VSCode Material Icons extension" }
|
|
160
162
|
);
|
|
163
|
+
function hasWeightedRefsInCategories(categoryRefs) {
|
|
164
|
+
return categoryRefs.reduce((acc, { weight }) => weight + acc, 0) !== 0;
|
|
165
|
+
}
|
|
161
166
|
|
|
162
167
|
// packages/models/src/lib/category-config.ts
|
|
163
168
|
var categoryRefSchema = weightedRefSchema(
|
|
@@ -455,10 +460,10 @@ var unrefinedCoreConfigSchema = z12.object({
|
|
|
455
460
|
upload: uploadConfigSchema.optional(),
|
|
456
461
|
categories: z12.array(categoryConfigSchema, {
|
|
457
462
|
description: "Categorization of individual audits"
|
|
458
|
-
}).refine(
|
|
459
|
-
(
|
|
460
|
-
(
|
|
461
|
-
message: duplicateSlugCategoriesErrorMsg(
|
|
463
|
+
}).min(1).refine(
|
|
464
|
+
(categories) => !getDuplicateSlugCategories(categories),
|
|
465
|
+
(categories) => ({
|
|
466
|
+
message: duplicateSlugCategoriesErrorMsg(categories)
|
|
462
467
|
})
|
|
463
468
|
)
|
|
464
469
|
});
|
|
@@ -760,7 +765,7 @@ function groupsFromRuleTypes(rules) {
|
|
|
760
765
|
refs: auditSlugsMap[type]?.map(
|
|
761
766
|
(slug) => ({ slug, weight: 1 })
|
|
762
767
|
) ?? []
|
|
763
|
-
}));
|
|
768
|
+
})).filter((group) => group.refs.length);
|
|
764
769
|
}
|
|
765
770
|
function groupsFromRuleCategories(rules) {
|
|
766
771
|
const categoriesMap = rules.reduce(
|