pasika 0.10.150 → 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 +26 -8
- 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));
|
|
@@ -11682,7 +11696,10 @@ function groupForConsumers(consumers) {
|
|
|
11682
11696
|
paths.push(consumer);
|
|
11683
11697
|
scopes.set(scope, paths);
|
|
11684
11698
|
}
|
|
11685
|
-
return [...scopes].map(([scope, paths]) =>
|
|
11699
|
+
return [...scopes].map(([scope, paths]) => {
|
|
11700
|
+
const concretePaths = [...new Set(paths.filter((consumer) => consumer !== scope))];
|
|
11701
|
+
return concretePaths.length === 1 ? concretePaths[0] ?? scope : scope;
|
|
11702
|
+
}).sort().join(", ");
|
|
11686
11703
|
}
|
|
11687
11704
|
var themeTokenOrderRule = {
|
|
11688
11705
|
meta: {
|
|
@@ -11761,7 +11778,8 @@ var themeTokenOrderRule = {
|
|
|
11761
11778
|
fix(fixer) {
|
|
11762
11779
|
const start = context.sourceCode.getIndexFromLoc({ line: currentGroup.line, column: 1 });
|
|
11763
11780
|
const end = start + (lines[currentGroup.line - 1] ?? "").length;
|
|
11764
|
-
|
|
11781
|
+
const indentation = /^\s*/u.exec(lines[currentGroup.line - 1] ?? "")?.[0] ?? "";
|
|
11782
|
+
return fixer.replaceTextRange([start, end], `${indentation}/* Group: ${item.owner} */`);
|
|
11765
11783
|
}
|
|
11766
11784
|
} : {}
|
|
11767
11785
|
});
|