design-system-silkhaus 3.12.0 → 3.13.0-beta.lint-rule.1
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.
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
meta: {
|
|
3
|
+
type: 'problem',
|
|
4
|
+
docs: {
|
|
5
|
+
description: 'Restrict listed names in tailwind tokens',
|
|
6
|
+
recommended: false,
|
|
7
|
+
},
|
|
8
|
+
messages: {
|
|
9
|
+
disallowedToken:
|
|
10
|
+
"Avoid using '{{ token }}' in token names. Use a semantic design token name instead.",
|
|
11
|
+
},
|
|
12
|
+
schema: [],
|
|
13
|
+
},
|
|
14
|
+
|
|
15
|
+
create(context) {
|
|
16
|
+
const DISALLOWED_TOKENS = [
|
|
17
|
+
'white',
|
|
18
|
+
'black',
|
|
19
|
+
'red',
|
|
20
|
+
'green',
|
|
21
|
+
'grey',
|
|
22
|
+
'gray',
|
|
23
|
+
'eggplant',
|
|
24
|
+
'carrot',
|
|
25
|
+
'teal',
|
|
26
|
+
'mustard',
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
const regex = new RegExp(`\\b(${DISALLOWED_TOKENS.join('|')})\\b`, 'i');
|
|
30
|
+
|
|
31
|
+
function reportIfTokenUsed(node, value) {
|
|
32
|
+
const match = regex.exec(value);
|
|
33
|
+
if (match) {
|
|
34
|
+
context.report({
|
|
35
|
+
node,
|
|
36
|
+
messageId: 'disallowedToken',
|
|
37
|
+
data: {
|
|
38
|
+
token: match[1],
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
Literal(node) {
|
|
46
|
+
if (typeof node.value === 'string') {
|
|
47
|
+
reportIfTokenUsed(node, node.value);
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
JSXAttribute(node) {
|
|
51
|
+
if (
|
|
52
|
+
node.name &&
|
|
53
|
+
['class', 'className', 'style'].includes(node.name.name) &&
|
|
54
|
+
node.value &&
|
|
55
|
+
node.value.type === 'Literal' &&
|
|
56
|
+
typeof node.value.value === 'string'
|
|
57
|
+
) {
|
|
58
|
+
reportIfTokenUsed(node.value, node.value.value);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Also handle JSXExpressionContainer e.g. className={"my-class red-text"}
|
|
62
|
+
if (
|
|
63
|
+
node.value &&
|
|
64
|
+
node.value.type === 'JSXExpressionContainer' &&
|
|
65
|
+
node.value.expression &&
|
|
66
|
+
node.value.expression.type === 'Literal' &&
|
|
67
|
+
typeof node.value.expression.value === 'string'
|
|
68
|
+
) {
|
|
69
|
+
reportIfTokenUsed(node.value.expression, node.value.expression.value);
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
TemplateLiteral(node) {
|
|
73
|
+
node.quasis.forEach((quasi) => {
|
|
74
|
+
reportIfTokenUsed(quasi, quasi.value.cooked || '');
|
|
75
|
+
});
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
},
|
|
79
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -35050,7 +35050,12 @@ const HV = ({ isOpen: e, setOpen: t, images: r, index: n }) => {
|
|
|
35050
35050
|
return;
|
|
35051
35051
|
}
|
|
35052
35052
|
}, Np = ({ className: e, minDate: t, maxDate: r, value: n, year: a, onChange: i }) => {
|
|
35053
|
-
const o = Array.from({ length: 12 }, (d, c) => c), s = (d, c, f, h, p) =>
|
|
35053
|
+
const o = Array.from({ length: 12 }, (d, c) => c), s = (d, c, f, h, p) => {
|
|
35054
|
+
if (!Rp({ month: d, year: c }, f, h)) return "disabled";
|
|
35055
|
+
if (!p) return "unselected";
|
|
35056
|
+
const { startDate: m, endDate: g } = p;
|
|
35057
|
+
return rn({ month: d, year: c }, m) && (!g || rn({ month: d, year: c }, g)) ? "selected" : rn({ month: d, year: c }, m) ? "selected-start" : g && rn({ month: d, year: c }, g) ? "selected-end" : g && Rp({ month: d, year: c }, m, g) ? "in-range" : "unselected";
|
|
35058
|
+
}, l = (d) => {
|
|
35054
35059
|
i && (!n || !Ip(n) ? i({ startDate: { month: d, year: a } }, "custom") : Ip(n) && (xq({ month: d, year: a }, n.startDate) ? i({ startDate: { month: d, year: a } }, "custom") : i({ startDate: n.startDate, endDate: { month: d, year: a } }, "custom")));
|
|
35055
35060
|
};
|
|
35056
35061
|
return /* @__PURE__ */ u.jsx("div", { className: xe("ds-flex ds-flex-wrap ds-gap-y-1", e), children: o.map((d) => /* @__PURE__ */ u.jsx(
|
|
@@ -35066,8 +35071,8 @@ const HV = ({ isOpen: e, setOpen: t, images: r, index: n }) => {
|
|
|
35066
35071
|
}, Pq = {
|
|
35067
35072
|
unselected: "ds-bg-white",
|
|
35068
35073
|
selected: "ds-bg-accentEggplant-100 ds-text-white ds-rounded",
|
|
35069
|
-
"selected-start": "ds-bg-accentEggplant-100 ds-text-white ds-rounded-l",
|
|
35070
|
-
"selected-end": "ds-bg-accentEggplant-100 ds-text-white ds-rounded-r",
|
|
35074
|
+
"selected-start": "ds-bg-accentEggplant-100 ds-text-white ds-rounded-l rtl:ds-rounded-r rtl:ds-rounded-l-none",
|
|
35075
|
+
"selected-end": "ds-bg-accentEggplant-100 ds-text-white ds-rounded-r rtl:ds-rounded-l rtl:ds-rounded-r-none",
|
|
35071
35076
|
"in-range": "ds-bg-accentEggplant-5 ds-text-accentEggplant-100",
|
|
35072
35077
|
disabled: "ds-bg-white ds-text-Text-tertiary ds-pointer-events-none"
|
|
35073
35078
|
}, Dq = ({ state: e = "unselected", value: t, className: r, onClick: n }) => /* @__PURE__ */ u.jsx(
|
|
@@ -35224,7 +35229,7 @@ const HV = ({ isOpen: e, setOpen: t, images: r, index: n }) => {
|
|
|
35224
35229
|
e === t && "ds-cursor-not-allowed ds-opacity-20"
|
|
35225
35230
|
),
|
|
35226
35231
|
onClick: () => e !== t && n(e - 1),
|
|
35227
|
-
children: /* @__PURE__ */ u.jsx(df, { className: "ds-size-4" })
|
|
35232
|
+
children: /* @__PURE__ */ u.jsx(df, { className: "ds-size-4 rtl:ds-rotate-180" })
|
|
35228
35233
|
}
|
|
35229
35234
|
),
|
|
35230
35235
|
/* @__PURE__ */ u.jsx(jn, { variant: "mediumCaption1Emphasized", children: e }),
|
|
@@ -35236,7 +35241,7 @@ const HV = ({ isOpen: e, setOpen: t, images: r, index: n }) => {
|
|
|
35236
35241
|
e === r && "ds-cursor-not-allowed ds-opacity-20"
|
|
35237
35242
|
),
|
|
35238
35243
|
onClick: () => e !== r && n(e + 1),
|
|
35239
|
-
children: /* @__PURE__ */ u.jsx(cf, { className: "ds-size-4" })
|
|
35244
|
+
children: /* @__PURE__ */ u.jsx(cf, { className: "ds-size-4 rtl:ds-rotate-180" })
|
|
35240
35245
|
}
|
|
35241
35246
|
)
|
|
35242
35247
|
] }), Tq = (e) => {
|