astralis-cli 0.6.0 → 0.7.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.
- package/CHANGELOG.md +13 -0
- package/package.json +2 -2
- package/src/lib/validate-core.mjs +64 -4
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,19 @@ breaking changes; a patch never does.
|
|
|
6
6
|
Versions marked **internal** were set in the repository but never published to
|
|
7
7
|
npm. Their changes reached npm in the next published version.
|
|
8
8
|
|
|
9
|
+
## 0.7.0 (2026-11-22)
|
|
10
|
+
|
|
11
|
+
Published with astralis-ui 0.11.0: `unknown-prop` reads the spec's new `ownProps`, `domProps` and `domAttributes`. With an older spec it stays silent.
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- **`unknown-state-prop`** (error): `hover`, `focusVisible` or `active` on a component that takes no state props (Card, Button, Image...), where it changes nothing. Box, the layout primitives, Text, Heading and Link take them.
|
|
16
|
+
- **`unknown-prop`** (error): a prop the component's type does not take, with the nearest real one (`Image has no fit prop... did you mean "objectFit"?`). Silent with `as`, a spread, a polymorphic component or an unknown one.
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- **The paint-prop hint names the props a component really has**, and for a part points to its compound's: `CardFooter is part of Card and has no look of its own: set variant or size on the Card, or put p on a Box inside it`.
|
|
21
|
+
|
|
9
22
|
## 0.6.0 (2026-11-21)
|
|
10
23
|
|
|
11
24
|
Publish with astralis-ui 0.10.0, whose system spec is version 4.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astralis-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Setup and tooling CLI for Astralis UI — scaffold or wire up a project, add blocks, generate a static brand theme, validate code against the design system, connect the MCP server.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"@babel/parser": "^8.0.4",
|
|
57
|
-
"astralis-ui": "^0.
|
|
57
|
+
"astralis-ui": "^0.11.0"
|
|
58
58
|
},
|
|
59
59
|
"scripts": {
|
|
60
60
|
"test": "node --test \"test/*.test.mjs\"",
|
|
@@ -23,6 +23,10 @@
|
|
|
23
23
|
"inherit" would copy the nearest w above, not the parent's width
|
|
24
24
|
- a style prop the component does not take, which reaches the HTML as a
|
|
25
25
|
stray attribute and changes nothing (unknown-style-prop)
|
|
26
|
+
- hover/focusVisible/active on a component that takes (unknown-state-prop)
|
|
27
|
+
no state props: only the box and text groups resolve them
|
|
28
|
+
- a prop the component's type does not take at all, when the spec lists
|
|
29
|
+
the type's whole prop set (ownProps) (unknown-prop)
|
|
26
30
|
- a component left empty that its type requires children for (missing-children):
|
|
27
31
|
tsc catches it too, but agents and copied snippets produce code no one type-checks
|
|
28
32
|
|
|
@@ -61,6 +65,12 @@ const DOCTRINE_PAINT_PROPS = new Set([
|
|
|
61
65
|
so they are never reported as stray. */
|
|
62
66
|
const HTML_ATTRIBUTE_NAMES = new Set(["width", "height", "size", "color", "wrap", "align", "border"]);
|
|
63
67
|
|
|
68
|
+
/* The recipe props a paint-prop hint may point to, when the component has them. */
|
|
69
|
+
const LOOK_PROPS = ["variant", "size", "colorScheme"];
|
|
70
|
+
|
|
71
|
+
/* Props React itself takes on every component, whatever its type declares. */
|
|
72
|
+
const REACT_PROPS = new Set(["key", "ref", "children"]);
|
|
73
|
+
|
|
64
74
|
/* Packages whose components are icons, for the icon-only Button rule. */
|
|
65
75
|
const ICON_PACKAGES = /^(lucide-react|react-icons(\/.*)?|@heroicons\/react(\/.*)?|@radix-ui\/react-icons|@tabler\/icons-react|@phosphor-icons\/react)$/;
|
|
66
76
|
|
|
@@ -98,6 +108,9 @@ export function prepareSpec(spec) {
|
|
|
98
108
|
// them and older code must keep validating.
|
|
99
109
|
bpKeys: new Set(["base", ...Object.keys(spec.breakpoints), ...Object.keys(spec.containerBreakpoints ?? {})]),
|
|
100
110
|
stateProps: new Set(Object.keys(spec.states)),
|
|
111
|
+
// React's DOM and SVG attributes any component's type inherits (spec builds
|
|
112
|
+
// that list each component's ownProps). Null when the spec cannot say.
|
|
113
|
+
domAttributeSet: spec.domAttributes ? new Set(spec.domAttributes) : null,
|
|
101
114
|
// Every exported value and type (spec 3+). Null for older specs.
|
|
102
115
|
exportSet: spec.exports ? new Set(spec.exports) : null,
|
|
103
116
|
};
|
|
@@ -418,7 +431,33 @@ function checkOwnValue(ctx, name, comp, prop, attr) {
|
|
|
418
431
|
}
|
|
419
432
|
}
|
|
420
433
|
|
|
421
|
-
|
|
434
|
+
/** The hint for a paint prop on a component that owns its look: its own
|
|
435
|
+
* variant/size/colorScheme, or for a part, the ones on the compound it belongs to. */
|
|
436
|
+
function lookHint(ctx, name, comp, prop) {
|
|
437
|
+
const lookOf = (entry) => LOOK_PROPS.filter((p) => entry?.props?.[p]);
|
|
438
|
+
const or = (list) => (list.length > 1 ? `${list.slice(0, -1).join(", ")} or ${list.at(-1)}` : list[0]);
|
|
439
|
+
if (comp.partOf) {
|
|
440
|
+
const owner = comp.partOf;
|
|
441
|
+
const vocab = lookOf(ctx.spec.components[owner]);
|
|
442
|
+
return `${name} is part of ${owner} and has no look of its own: ` +
|
|
443
|
+
(vocab.length ? `set ${or(vocab)} on the ${owner}, or ` : "") + `put ${prop} on a Box inside it`;
|
|
444
|
+
}
|
|
445
|
+
const vocab = lookOf(comp);
|
|
446
|
+
return vocab.length
|
|
447
|
+
? `${name} owns how it looks; reach for ${or(vocab)}`
|
|
448
|
+
: `${name} owns how it looks; put ${prop} on a Box around it`;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
/** Whether the component's type takes `prop` at all. Null when the spec cannot
|
|
452
|
+
* say: it lists ownProps only for types it read whole (not polymorphic ones). */
|
|
453
|
+
function takesProp(ctx, comp, allowed, prop) {
|
|
454
|
+
if (!comp.ownProps || (comp.domProps && !ctx.domAttributeSet)) return null;
|
|
455
|
+
if (allowed[prop] || comp.ownProps.includes(prop) || REACT_PROPS.has(prop) || /^data-/.test(prop)) return true;
|
|
456
|
+
if (comp.props?.[prop] || comp.scalarProps?.[prop] || comp.overrides?.includes(prop)) return true;
|
|
457
|
+
return Boolean(comp.domProps && (/^on[A-Z]/.test(prop) || ctx.domAttributeSet.has(prop)));
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
function checkComponentProp(ctx, identity, comp, allowed, attr, prop, open) {
|
|
422
461
|
const name = identity.specName;
|
|
423
462
|
if (comp.exclude?.includes(prop)) {
|
|
424
463
|
const short = allowed[prop]?.short;
|
|
@@ -439,6 +478,14 @@ function checkComponentProp(ctx, identity, comp, allowed, attr, prop) {
|
|
|
439
478
|
// Link only those they take as base props. Elsewhere no claim.
|
|
440
479
|
if (comp.groups.includes("box")) checkStateValue(ctx, name, prop, attr.value);
|
|
441
480
|
else if (comp.groups.includes("text")) checkStateValue(ctx, name, prop, attr.value, allowed);
|
|
481
|
+
// Only box- and text-group components resolve state props. Decided only
|
|
482
|
+
// when the spec read the type (ownStyleProps), and never against a state
|
|
483
|
+
// name the component declares itself.
|
|
484
|
+
else if (comp.ownStyleProps && !comp.props?.[prop] && !comp.scalarProps?.[prop] && !comp.ownProps?.includes(prop)) {
|
|
485
|
+
ctx.error("unknown-state-prop", attr,
|
|
486
|
+
`${name} does not take ${prop}: state props work on Box, the layout primitives, Text, Heading and Link, ` +
|
|
487
|
+
`so here it changes nothing (put ${prop} on a Box around ${name})`);
|
|
488
|
+
}
|
|
442
489
|
return;
|
|
443
490
|
}
|
|
444
491
|
if (!overridden && allowed[prop]) {
|
|
@@ -463,10 +510,22 @@ function checkComponentProp(ctx, identity, comp, allowed, attr, prop) {
|
|
|
463
510
|
ctx.error("unknown-style-prop", attr,
|
|
464
511
|
`${name} does not take ${prop}: it reaches the HTML as a stray attribute and changes nothing` +
|
|
465
512
|
(recipe
|
|
466
|
-
? ` (${name
|
|
513
|
+
? ` (${lookHint(ctx, name, comp, prop)})`
|
|
467
514
|
: ` (${name} takes ${comp.groups.length ? `${comp.groups.join(", ")} props` : "no style props"}; put ${prop} on a Box around it)`));
|
|
515
|
+
return;
|
|
468
516
|
}
|
|
469
|
-
//
|
|
517
|
+
// Style-prop names are the rule above's; `as` or a spread may hand the
|
|
518
|
+
// element another component's props, so neither is judged.
|
|
519
|
+
if (open || ctx.stylePropNames.has(prop) || takesProp(ctx, comp, allowed, prop) !== false) return;
|
|
520
|
+
const candidates = [...comp.ownProps, ...Object.keys(allowed)].filter((p) => !/^(aria|data)-|^on[A-Z]/.test(p) || /^on[A-Z]/.test(prop));
|
|
521
|
+
// A near spelling, else the one prop that ends or starts with it (fit, objectFit).
|
|
522
|
+
const lower = prop.toLowerCase();
|
|
523
|
+
const affixed = candidates.filter((p) => lower.length >= 3 && (p.toLowerCase().endsWith(lower) || p.toLowerCase().startsWith(lower)));
|
|
524
|
+
const near = (affixed.length === 1 ? affixed[0] : null) ?? suggest(prop, candidates);
|
|
525
|
+
ctx.error("unknown-prop", attr,
|
|
526
|
+
`${name} has no ${prop} prop: ` +
|
|
527
|
+
(comp.domProps ? "it reaches the HTML as a stray attribute and changes nothing" : "it changes nothing") +
|
|
528
|
+
(near ? ` (did you mean "${near}"?)` : ""));
|
|
470
529
|
}
|
|
471
530
|
|
|
472
531
|
/* ---- one element: identity, then every attribute ----------------------------- */
|
|
@@ -524,6 +583,7 @@ function analyzeOpening(ctx, node) {
|
|
|
524
583
|
if (comp) for (const g of comp.groups) Object.assign(allowed, ctx.spec.propGroups[g]);
|
|
525
584
|
|
|
526
585
|
let hasSpread = false;
|
|
586
|
+
const open = node.attributes.some((a) => a.type === "JSXSpreadAttribute") || Boolean(findAttribute(node, "as"));
|
|
527
587
|
let hasAlt = false;
|
|
528
588
|
let hasAriaCover = false; // aria-label / aria-labelledby / aria-hidden
|
|
529
589
|
|
|
@@ -541,7 +601,7 @@ function analyzeOpening(ctx, node) {
|
|
|
541
601
|
} else if (prop === "role") checkRole(ctx, attr);
|
|
542
602
|
else if (prop === "tabIndex") checkTabIndex(ctx, attr);
|
|
543
603
|
else if (prop === "alt") hasAlt = true;
|
|
544
|
-
else if (comp) checkComponentProp(ctx, identity, comp, allowed, attr, prop);
|
|
604
|
+
else if (comp) checkComponentProp(ctx, identity, comp, allowed, attr, prop, open);
|
|
545
605
|
}
|
|
546
606
|
|
|
547
607
|
if (identity.specName === "Flex") {
|