@clearstory/drywall-react 4.2.1 → 4.2.3
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.
|
@@ -122,11 +122,11 @@ const b = [
|
|
|
122
122
|
"typography",
|
|
123
123
|
// other common system props
|
|
124
124
|
"spacing"
|
|
125
|
-
], S = ["Box", "Stack", "Typography", "Link"],
|
|
125
|
+
], S = ["Box", "Stack", "Typography", "Link"], $ = {
|
|
126
126
|
Typography: ["color"],
|
|
127
127
|
// semantic colors only
|
|
128
128
|
Link: ["color"]
|
|
129
|
-
},
|
|
129
|
+
}, j = {
|
|
130
130
|
meta: {
|
|
131
131
|
type: "problem",
|
|
132
132
|
docs: {
|
|
@@ -140,64 +140,64 @@ const b = [
|
|
|
140
140
|
},
|
|
141
141
|
schema: []
|
|
142
142
|
},
|
|
143
|
-
create(
|
|
144
|
-
const o = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set(), g =
|
|
143
|
+
create(p) {
|
|
144
|
+
const o = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set(), g = p.getSourceCode();
|
|
145
145
|
return {
|
|
146
|
-
ImportDeclaration(
|
|
147
|
-
const
|
|
148
|
-
|
|
146
|
+
ImportDeclaration(m) {
|
|
147
|
+
const t = m;
|
|
148
|
+
t.source.value === "@clearstory/drywall-react" && t.specifiers.forEach((r) => {
|
|
149
149
|
r.type === "ImportSpecifier" && r.imported && S.includes(r.imported.name) ? o.add(r.local.name) : r.type === "ImportNamespaceSpecifier" && u.add(r.local.name);
|
|
150
150
|
});
|
|
151
151
|
},
|
|
152
|
-
JSXOpeningElement(
|
|
153
|
-
const
|
|
152
|
+
JSXOpeningElement(m) {
|
|
153
|
+
const t = m;
|
|
154
154
|
let r;
|
|
155
|
-
if ("name" in
|
|
156
|
-
if (r =
|
|
155
|
+
if ("name" in t.name) {
|
|
156
|
+
if (r = t.name.name, !o.has(r))
|
|
157
157
|
return;
|
|
158
|
-
} else if (
|
|
159
|
-
const
|
|
160
|
-
if (r =
|
|
158
|
+
} else if (t.name.type === "JSXMemberExpression") {
|
|
159
|
+
const l = t.name.object.name;
|
|
160
|
+
if (r = t.name.property.name, !u.has(l) || !S.includes(r))
|
|
161
161
|
return;
|
|
162
162
|
} else
|
|
163
163
|
return;
|
|
164
|
-
const
|
|
164
|
+
const a = [];
|
|
165
165
|
let x = null;
|
|
166
|
-
|
|
167
|
-
const
|
|
168
|
-
if (
|
|
166
|
+
t.attributes.forEach((l) => {
|
|
167
|
+
const e = l;
|
|
168
|
+
if (e.type !== "JSXAttribute" || !e.name)
|
|
169
169
|
return;
|
|
170
|
-
const d =
|
|
170
|
+
const d = e.name.name;
|
|
171
171
|
if (d === "sx") {
|
|
172
|
-
x =
|
|
172
|
+
x = e;
|
|
173
173
|
return;
|
|
174
174
|
}
|
|
175
175
|
if (!b.includes(d))
|
|
176
176
|
return;
|
|
177
|
-
const y =
|
|
177
|
+
const y = $[r];
|
|
178
178
|
if (y && y.includes(d))
|
|
179
|
-
if (d === "color" &&
|
|
180
|
-
const h =
|
|
179
|
+
if (d === "color" && e.value) {
|
|
180
|
+
const h = w(e.value);
|
|
181
181
|
if (C(h))
|
|
182
182
|
return;
|
|
183
183
|
} else
|
|
184
184
|
return;
|
|
185
|
-
|
|
186
|
-
|
|
185
|
+
a.push(
|
|
186
|
+
e
|
|
187
187
|
);
|
|
188
|
-
}),
|
|
189
|
-
|
|
190
|
-
node:
|
|
188
|
+
}), a.forEach((l) => {
|
|
189
|
+
p.report({
|
|
190
|
+
node: l,
|
|
191
191
|
messageId: "systemProp",
|
|
192
192
|
data: {
|
|
193
|
-
prop:
|
|
193
|
+
prop: l.name.name,
|
|
194
194
|
component: r
|
|
195
195
|
},
|
|
196
|
-
fix(
|
|
196
|
+
fix(e) {
|
|
197
197
|
return I(
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
198
|
+
e,
|
|
199
|
+
m,
|
|
200
|
+
a,
|
|
201
201
|
x,
|
|
202
202
|
g
|
|
203
203
|
);
|
|
@@ -208,9 +208,9 @@ const b = [
|
|
|
208
208
|
};
|
|
209
209
|
}
|
|
210
210
|
};
|
|
211
|
-
function
|
|
212
|
-
if (!
|
|
213
|
-
const o =
|
|
211
|
+
function w(p) {
|
|
212
|
+
if (!p) return null;
|
|
213
|
+
const o = p;
|
|
214
214
|
if (o.type === "Literal")
|
|
215
215
|
return String(o.value);
|
|
216
216
|
if (o.type === "JSXExpressionContainer" && o.expression) {
|
|
@@ -221,7 +221,7 @@ function $(s) {
|
|
|
221
221
|
}
|
|
222
222
|
return null;
|
|
223
223
|
}
|
|
224
|
-
function C(
|
|
224
|
+
function C(p) {
|
|
225
225
|
return [
|
|
226
226
|
"inherit",
|
|
227
227
|
"primary",
|
|
@@ -230,55 +230,56 @@ function C(s) {
|
|
|
230
230
|
"warning",
|
|
231
231
|
"info",
|
|
232
232
|
"success"
|
|
233
|
-
].includes(
|
|
233
|
+
].includes(p || "");
|
|
234
234
|
}
|
|
235
|
-
function I(
|
|
236
|
-
const
|
|
237
|
-
const n = i.name.name,
|
|
238
|
-
if (!
|
|
235
|
+
function I(p, o, u, g, m) {
|
|
236
|
+
const t = o, r = "name" in t.name ? t.name.name : t.name.type === "JSXMemberExpression" ? `${t.name.object.name}.${t.name.property.name}` : "UnknownComponent", a = u.map((i) => {
|
|
237
|
+
const n = i.name.name, s = i.value;
|
|
238
|
+
if (!s)
|
|
239
239
|
return `${n}: true`;
|
|
240
|
-
const c =
|
|
240
|
+
const c = s;
|
|
241
241
|
if (c.type === "Literal")
|
|
242
242
|
return `${n}: ${JSON.stringify(c.value)}`;
|
|
243
243
|
if (c.type === "JSXExpressionContainer" && c.expression) {
|
|
244
|
-
const f =
|
|
244
|
+
const f = m.getText(c.expression);
|
|
245
245
|
return `${n}: ${f}`;
|
|
246
246
|
}
|
|
247
247
|
return `${n}: true`;
|
|
248
248
|
}), x = new Set(
|
|
249
249
|
u.map((i) => i.name.name)
|
|
250
|
-
),
|
|
251
|
-
|
|
250
|
+
), l = [];
|
|
251
|
+
t.attributes.forEach((i) => {
|
|
252
252
|
const n = i;
|
|
253
253
|
if (n.type !== "JSXAttribute" || !n.name) {
|
|
254
|
-
|
|
254
|
+
l.push(m.getText(i));
|
|
255
255
|
return;
|
|
256
256
|
}
|
|
257
|
-
const
|
|
258
|
-
x.has(
|
|
257
|
+
const s = n.name.name;
|
|
258
|
+
x.has(s) || s === "sx" && g || l.push(m.getText(i));
|
|
259
259
|
});
|
|
260
|
-
let
|
|
260
|
+
let e;
|
|
261
261
|
if (g) {
|
|
262
|
-
const i =
|
|
262
|
+
const i = m.getText(g.value);
|
|
263
263
|
if (i.startsWith("{") && i.endsWith("}")) {
|
|
264
264
|
const n = i.slice(1, -1).trim();
|
|
265
|
-
if (n.startsWith("{") && n.endsWith("}"))
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
265
|
+
if (n.startsWith("{") && n.endsWith("}")) {
|
|
266
|
+
const s = n.slice(1, -1).trim(), c = s.includes("...");
|
|
267
|
+
s ? c ? e = `sx={{ ${a.join(", ")}, ...${n} }}` : e = `sx={{ ${a.join(", ")}, ${s} }}` : e = `sx={{ ${a.join(", ")} }}`;
|
|
268
|
+
} else if (n.startsWith("[") && n.endsWith("]"))
|
|
269
|
+
e = `sx={[{ ${a.join(", ")} }, ...${n}]}`;
|
|
269
270
|
else {
|
|
270
|
-
const
|
|
271
|
-
|
|
272
|
-
) ?
|
|
273
|
-
|
|
271
|
+
const s = n.trimStart(), f = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(
|
|
272
|
+
s
|
|
273
|
+
) ? s : n;
|
|
274
|
+
e = `sx={[{ ${a.join(", ")} }, ...(Array.isArray(${f}) ? ${f} : [${f}])]}`;
|
|
274
275
|
}
|
|
275
276
|
} else
|
|
276
|
-
|
|
277
|
+
e = `sx={{ ${a.join(", ")} }}`;
|
|
277
278
|
} else
|
|
278
|
-
|
|
279
|
-
const d = [...
|
|
280
|
-
return [
|
|
279
|
+
e = `sx={{ ${a.join(", ")} }}`;
|
|
280
|
+
const d = [...l, e], y = d.length > 0 ? " " + d.join(" ") : "", h = `<${r}${y}${t.selfClosing ? " />" : ">"}`;
|
|
281
|
+
return [p.replaceText(o, h)];
|
|
281
282
|
}
|
|
282
283
|
export {
|
|
283
|
-
|
|
284
|
+
j as default
|
|
284
285
|
};
|