@clearstory/drywall-react 7.0.1 → 7.1.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.
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import e from "./no-system-props.js";
|
|
2
|
+
import l from "./prefer-vars-palette.js";
|
|
2
3
|
const r = {
|
|
3
4
|
rules: {
|
|
4
|
-
"no-system-props": e
|
|
5
|
+
"no-system-props": e,
|
|
6
|
+
"prefer-vars-palette": l
|
|
5
7
|
},
|
|
6
8
|
configs: {}
|
|
7
9
|
};
|
|
@@ -11,19 +13,21 @@ r.configs.recommended = {
|
|
|
11
13
|
"@clearstory/drywall-react": r
|
|
12
14
|
},
|
|
13
15
|
rules: {
|
|
14
|
-
"@clearstory/drywall-react/no-system-props": "error"
|
|
16
|
+
"@clearstory/drywall-react/no-system-props": "error",
|
|
17
|
+
"@clearstory/drywall-react/prefer-vars-palette": "error"
|
|
15
18
|
}
|
|
16
19
|
};
|
|
17
|
-
const
|
|
20
|
+
const t = {
|
|
18
21
|
name: "@clearstory/drywall-react",
|
|
19
22
|
plugins: {
|
|
20
23
|
"@clearstory/drywall-react": r
|
|
21
24
|
},
|
|
22
25
|
rules: {
|
|
23
|
-
"@clearstory/drywall-react/no-system-props": "error"
|
|
26
|
+
"@clearstory/drywall-react/no-system-props": "error",
|
|
27
|
+
"@clearstory/drywall-react/prefer-vars-palette": "error"
|
|
24
28
|
}
|
|
25
29
|
};
|
|
26
30
|
export {
|
|
27
|
-
|
|
31
|
+
t as default,
|
|
28
32
|
r as plugin
|
|
29
33
|
};
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
const b = /* @__PURE__ */ new Set([
|
|
2
|
+
"color",
|
|
3
|
+
"backgroundColor",
|
|
4
|
+
"bgcolor",
|
|
5
|
+
"background",
|
|
6
|
+
"borderColor",
|
|
7
|
+
"borderTopColor",
|
|
8
|
+
"borderRightColor",
|
|
9
|
+
"borderBottomColor",
|
|
10
|
+
"borderLeftColor",
|
|
11
|
+
"outlineColor",
|
|
12
|
+
"fill",
|
|
13
|
+
"stroke",
|
|
14
|
+
"caretColor",
|
|
15
|
+
"textDecorationColor",
|
|
16
|
+
"columnRuleColor"
|
|
17
|
+
]), p = /* @__PURE__ */ new Set([
|
|
18
|
+
"inherit",
|
|
19
|
+
"transparent",
|
|
20
|
+
"currentColor",
|
|
21
|
+
"currentcolor",
|
|
22
|
+
"initial",
|
|
23
|
+
"unset",
|
|
24
|
+
"none"
|
|
25
|
+
]), C = {
|
|
26
|
+
meta: {
|
|
27
|
+
type: "suggestion",
|
|
28
|
+
docs: {
|
|
29
|
+
description: "Enforce using vars.palette for color properties in sx props instead of string literals or theme.palette",
|
|
30
|
+
category: "Best Practices",
|
|
31
|
+
recommended: !0
|
|
32
|
+
},
|
|
33
|
+
messages: {
|
|
34
|
+
stringColor: 'Avoid string literal "{{value}}" for "{{property}}" in sx. Use vars.palette for type-safe, dark mode-friendly colors.',
|
|
35
|
+
useVarsPalette: "Use vars.palette instead of {{access}} for CSS variable-based dark mode support."
|
|
36
|
+
},
|
|
37
|
+
schema: []
|
|
38
|
+
},
|
|
39
|
+
create(t) {
|
|
40
|
+
return {
|
|
41
|
+
JSXOpeningElement(e) {
|
|
42
|
+
const r = e.attributes.find(
|
|
43
|
+
(s) => s.type === "JSXAttribute" && s.name?.name === "sx"
|
|
44
|
+
);
|
|
45
|
+
if (!r) return;
|
|
46
|
+
const o = r.value;
|
|
47
|
+
if (o && o.type === "JSXExpressionContainer") {
|
|
48
|
+
const s = o.expression;
|
|
49
|
+
y(t, s);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
function y(t, e) {
|
|
56
|
+
if (e)
|
|
57
|
+
switch (e.type) {
|
|
58
|
+
case "ObjectExpression":
|
|
59
|
+
u(t, e);
|
|
60
|
+
break;
|
|
61
|
+
case "ArrowFunctionExpression":
|
|
62
|
+
case "FunctionExpression": {
|
|
63
|
+
d(t, e);
|
|
64
|
+
const n = g(e);
|
|
65
|
+
n && u(t, n);
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
case "ArrayExpression": {
|
|
69
|
+
e.elements.forEach((r) => {
|
|
70
|
+
r && y(t, r);
|
|
71
|
+
});
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function u(t, e) {
|
|
77
|
+
e.properties.forEach((r) => {
|
|
78
|
+
if (r.type !== "Property") return;
|
|
79
|
+
const o = r, s = m(o.key, o.computed);
|
|
80
|
+
if (!s) return;
|
|
81
|
+
const i = o.value;
|
|
82
|
+
if (i.type === "ObjectExpression") {
|
|
83
|
+
u(t, i);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (b.has(s)) {
|
|
87
|
+
if (i.type === "ArrowFunctionExpression" || i.type === "FunctionExpression") {
|
|
88
|
+
d(t, i);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (i.type === "Literal") {
|
|
92
|
+
const a = i.value;
|
|
93
|
+
typeof a == "string" && !p.has(a) && t.report({
|
|
94
|
+
node: i,
|
|
95
|
+
messageId: "stringColor",
|
|
96
|
+
data: { value: a, property: s }
|
|
97
|
+
});
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (i.type === "TemplateLiteral") {
|
|
101
|
+
const a = i;
|
|
102
|
+
if (a.expressions.length === 0) {
|
|
103
|
+
const c = a.quasis[0]?.value.raw;
|
|
104
|
+
c && !p.has(c) && t.report({
|
|
105
|
+
node: i,
|
|
106
|
+
messageId: "stringColor",
|
|
107
|
+
data: { value: c, property: s }
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (i.type === "ConditionalExpression") {
|
|
113
|
+
const a = i;
|
|
114
|
+
l(t, a.consequent, s), l(t, a.alternate, s);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
function l(t, e, n) {
|
|
120
|
+
if (e.type === "Literal") {
|
|
121
|
+
const r = e.value;
|
|
122
|
+
typeof r == "string" && !p.has(r) && t.report({
|
|
123
|
+
node: e,
|
|
124
|
+
messageId: "stringColor",
|
|
125
|
+
data: { value: r, property: n }
|
|
126
|
+
});
|
|
127
|
+
} else if (e.type === "ConditionalExpression") {
|
|
128
|
+
const r = e;
|
|
129
|
+
l(t, r.consequent, n), l(t, r.alternate, n);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
function d(t, e) {
|
|
133
|
+
const n = e.params;
|
|
134
|
+
if (!n || n.length === 0) return;
|
|
135
|
+
const r = n[0];
|
|
136
|
+
if (r.type === "Identifier") {
|
|
137
|
+
const o = r.name, s = e.body;
|
|
138
|
+
f(t, s, o);
|
|
139
|
+
} else r.type === "ObjectPattern" && r.properties.forEach((s) => {
|
|
140
|
+
if (s.type !== "Property") return;
|
|
141
|
+
s.key.name === "palette" && t.report({
|
|
142
|
+
node: s,
|
|
143
|
+
messageId: "useVarsPalette",
|
|
144
|
+
data: { access: "destructured palette" }
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
function f(t, e, n) {
|
|
149
|
+
if (!(!e || typeof e != "object")) {
|
|
150
|
+
if (e.type === "MemberExpression") {
|
|
151
|
+
const r = e.object, o = e.property;
|
|
152
|
+
if (r.type === "Identifier" && r.name === n && o.name === "palette") {
|
|
153
|
+
t.report({
|
|
154
|
+
node: e,
|
|
155
|
+
messageId: "useVarsPalette",
|
|
156
|
+
data: { access: `${n}.palette` }
|
|
157
|
+
});
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
for (const r of Object.keys(e)) {
|
|
162
|
+
if (r === "parent") continue;
|
|
163
|
+
const o = e[r];
|
|
164
|
+
o && typeof o == "object" && (Array.isArray(o) ? o.forEach((s) => {
|
|
165
|
+
s && typeof s == "object" && "type" in s && f(t, s, n);
|
|
166
|
+
}) : "type" in o && f(t, o, n));
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
function g(t) {
|
|
171
|
+
const e = t.body;
|
|
172
|
+
if (e.type === "ObjectExpression")
|
|
173
|
+
return e;
|
|
174
|
+
if (e.type === "BlockStatement") {
|
|
175
|
+
const n = e.body;
|
|
176
|
+
for (const r of n)
|
|
177
|
+
if (r.type === "ReturnStatement") {
|
|
178
|
+
const o = r.argument;
|
|
179
|
+
if (o?.type === "ObjectExpression")
|
|
180
|
+
return o;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
function m(t, e) {
|
|
186
|
+
return t.type === "Identifier" && !e ? t.name || null : t.type === "Literal" && typeof t.value == "string" ? t.value : null;
|
|
187
|
+
}
|
|
188
|
+
export {
|
|
189
|
+
C as default
|
|
190
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clearstory/drywall-react",
|
|
3
|
-
"version": "7.0
|
|
3
|
+
"version": "7.1.0",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"description": "a Clearstory software design system",
|
|
6
6
|
"type": "module",
|
|
@@ -37,12 +37,12 @@
|
|
|
37
37
|
"@mui/material": "7.3.7",
|
|
38
38
|
"@mui/system": "7.3.7",
|
|
39
39
|
"@mui/utils": "7.3.7",
|
|
40
|
-
"@mui/x-date-pickers": "8.
|
|
40
|
+
"@mui/x-date-pickers": "8.27.0",
|
|
41
41
|
"react-hot-toast": "2.6.0",
|
|
42
42
|
"react-number-format": "^5.4.4"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@chromatic-com/storybook": "^
|
|
45
|
+
"@chromatic-com/storybook": "^5.0.1",
|
|
46
46
|
"@eslint/js": "^9.29.0",
|
|
47
47
|
"@storybook/addon-a11y": "^10.0.5",
|
|
48
48
|
"@storybook/addon-docs": "^10.0.5",
|