pasika 0.10.151 → 0.10.152
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/dist/eslint/pasika/index.js +20 -6
- package/package.json +1 -1
|
@@ -10196,16 +10196,30 @@ var colorLiteralUsageRule = {
|
|
|
10196
10196
|
schema: [],
|
|
10197
10197
|
type: "problem",
|
|
10198
10198
|
docs: {
|
|
10199
|
-
description: "Require fixed
|
|
10199
|
+
description: "Require reusable fixed colors in --color-* tokens; allow one-off drop-shadow literals."
|
|
10200
10200
|
}
|
|
10201
10201
|
},
|
|
10202
10202
|
create(context) {
|
|
10203
10203
|
return {
|
|
10204
10204
|
"StyleSheet:exit"(node) {
|
|
10205
10205
|
const masked = maskNonColors(context.sourceCode.text);
|
|
10206
|
-
const
|
|
10207
|
-
const
|
|
10206
|
+
const declarations = [...masked.matchAll(DECLARATION)];
|
|
10207
|
+
const applyExpressions = [...masked.matchAll(APPLY)];
|
|
10208
|
+
const literalKey = (text) => text.toLowerCase().replace(/\s+/gu, " ").trim();
|
|
10209
|
+
const literalUses = /* @__PURE__ */ new Map();
|
|
10210
|
+
for (const match of [...declarations, ...applyExpressions]) {
|
|
10211
|
+
const value = match.groups?.value;
|
|
10212
|
+
if (value === void 0) continue;
|
|
10208
10213
|
for (const color of colorLiterals(value)) {
|
|
10214
|
+
const key = literalKey(color.text);
|
|
10215
|
+
literalUses.set(key, (literalUses.get(key) ?? 0) + 1);
|
|
10216
|
+
}
|
|
10217
|
+
}
|
|
10218
|
+
const reported = /* @__PURE__ */ new Set();
|
|
10219
|
+
const reportValue = (value, start, isDropShadowToken = false) => {
|
|
10220
|
+
const colors = colorLiterals(value);
|
|
10221
|
+
for (const color of colors) {
|
|
10222
|
+
if (isDropShadowToken && colors.length === 1 && literalUses.get(literalKey(color.text)) === 1) continue;
|
|
10209
10223
|
const offset = start + color.offset;
|
|
10210
10224
|
if (reported.has(offset)) continue;
|
|
10211
10225
|
reported.add(offset);
|
|
@@ -10217,13 +10231,13 @@ var colorLiteralUsageRule = {
|
|
|
10217
10231
|
});
|
|
10218
10232
|
}
|
|
10219
10233
|
};
|
|
10220
|
-
for (const match of
|
|
10234
|
+
for (const match of declarations) {
|
|
10221
10235
|
const property = match.groups?.property;
|
|
10222
10236
|
const value = match.groups?.value;
|
|
10223
10237
|
if (!property || value === void 0 || property.startsWith("--color-")) continue;
|
|
10224
|
-
reportValue(value, match.index + match[0].lastIndexOf(value));
|
|
10238
|
+
reportValue(value, match.index + match[0].lastIndexOf(value), /^--drop-shadow-[\w-]+$/u.test(property));
|
|
10225
10239
|
}
|
|
10226
|
-
for (const match of
|
|
10240
|
+
for (const match of applyExpressions) {
|
|
10227
10241
|
const value = match.groups?.value;
|
|
10228
10242
|
if (value === void 0) continue;
|
|
10229
10243
|
reportValue(value, match.index + match[0].indexOf(value));
|