@starci/eslint-grammar-core 0.55.0 → 0.58.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
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.58.0 - 2026-11-24
|
|
4
|
+
|
|
5
|
+
- No rule of its own changed: versioned with @starci/grammar 0.58.0.
|
|
6
|
+
|
|
7
|
+
## 0.57.0 - 2026-11-23
|
|
8
|
+
|
|
9
|
+
- Added (`no-raw-spacing-style`, law SPACING-ROLES, owner 2026-11-23): a gap, padding or margin key in a JSX `style` object in product source is reported; the distance is a Grammar spacing role (a Stack, Cluster or Grid `gap`, the inset of a Grammar box). A counting rule at warn until both apps migrate. The class-string half stays the canon's `starci-fe/no-spacing-utility` (R350).
|
|
10
|
+
- Changed (`no-icon-size-class`, wording only; Grammar 0.57.0's icon table): the message names the roles, `control` 16, `row` 20, `head` 24, `text` 1em.
|
|
11
|
+
|
|
12
|
+
## 0.56.0 - 2026-11-23
|
|
13
|
+
|
|
14
|
+
- Changed (`no-icon-size-class`, wording only; Grammar 0.55.1's icon size table, owner 2026-11-23): the message names the table: 24 for a navigation entry or a heading lead (`heading`, `leading`), 20 beside text and in a chip, badge or field (`chip`), 1em of its text for a caret or an inline status mark (`text`). The rule reads the same calls as before.
|
|
15
|
+
|
|
3
16
|
## 0.55.0 - 2026-11-22
|
|
4
17
|
|
|
5
18
|
- Changed (`navbar-control-size`, with Grammar 0.55.0's two round-mark sizes): an `AvatarButton` with no `size` or `size="md"` (40px) has the bar's control height; its `control` size is deleted.
|
package/dist/icon.js
CHANGED
|
@@ -126,10 +126,10 @@ const SIZE_UTILITY = /(?:^|\s)(?:size|w|h|min-w|min-h|max-w|max-h)-\S+/;
|
|
|
126
126
|
export const noIconSizeClass = defineRule({
|
|
127
127
|
meta: {
|
|
128
128
|
type: "problem",
|
|
129
|
-
docs: { description: "A glyph component takes its size from its
|
|
129
|
+
docs: { description: "A glyph component takes its size from its role (the icon table: `control` 16 beside 14px words and in every labelled control, `row` 20 in the 40 tile, `head` 24 in the 48 tile, `text` 1em for a caret or a status glyph), never from a size class at the call site." },
|
|
130
130
|
schema: [],
|
|
131
131
|
messages: {
|
|
132
|
-
size: "`{{cls}}` sizes a glyph at the call site. The size of a glyph is its
|
|
132
|
+
size: "`{{cls}}` sizes a glyph at the call site. The size of a glyph is its role's (`Icon usage` and the Grammar components that draw one; the icon table: `control` 16 beside 14px words and in every labelled control, `row` 20 in the 40 tile, `head` 24 in the 48 tile, `text` 1em of its words for a caret or a status glyph), so the app passes the glyph and no size class; a size written here is a third step nobody applies the same way twice.",
|
|
133
133
|
},
|
|
134
134
|
},
|
|
135
135
|
create(context) {
|
package/dist/index.js
CHANGED
|
@@ -19,6 +19,7 @@ import { rules as mascotRules } from "./mascot.js";
|
|
|
19
19
|
import { rules as mediaRules } from "./media.js";
|
|
20
20
|
import { rules as menuEntriesRules } from "./menu-entries.js";
|
|
21
21
|
import { rules as noRawScrollRules } from "./no-raw-scroll.js";
|
|
22
|
+
import { rules as noRawSpacingStyleRules } from "./no-raw-spacing-style.js";
|
|
22
23
|
import { rules as noRawTypeSizeRules } from "./no-raw-type-size.js";
|
|
23
24
|
import { rules as outlineIconsRules } from "./outline-icons.js";
|
|
24
25
|
import { rules as pageRules } from "./page.js";
|
|
@@ -74,6 +75,7 @@ const DECLARED = [
|
|
|
74
75
|
{ law: "media", rules: mediaRules },
|
|
75
76
|
{ law: "menu-entries", rules: menuEntriesRules },
|
|
76
77
|
{ law: "no-raw-scroll", rules: noRawScrollRules },
|
|
78
|
+
{ law: "no-raw-spacing-style", rules: noRawSpacingStyleRules },
|
|
77
79
|
{ law: "no-raw-type-size", rules: noRawTypeSizeRules },
|
|
78
80
|
{ law: "outline-icons", rules: outlineIconsRules },
|
|
79
81
|
{ law: "page", rules: pageRules },
|
|
@@ -120,6 +122,7 @@ export const rules = Object.fromEntries(CONTRIBUTIONS.flatMap(({ rules }) => Obj
|
|
|
120
122
|
*/
|
|
121
123
|
export const COUNTING = Object.freeze({
|
|
122
124
|
"starci-grammar/no-raw-type-size": { law: "TYPE-ROLES", until: "both apps have moved their raw type sizes onto the type roles" },
|
|
125
|
+
"starci-grammar/no-raw-spacing-style": { law: "SPACING-ROLES", until: "both apps have moved their raw style spacing onto the spacing roles" },
|
|
123
126
|
});
|
|
124
127
|
/** The level of one published rule: warn in the counting cohort, error otherwise. */
|
|
125
128
|
const levelOf = (name) => (`starci-grammar/${name}` in COUNTING ? "warn" : "error");
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Rule } from "eslint";
|
|
2
|
+
/**
|
|
3
|
+
* THE SPACING ROLES (owner, 2026-11-23, SPACING-ROLES; contexts/ui/scale.md "The spacing roles"). A distance between two things an app
|
|
4
|
+
* places is a ROLE the Grammar resolves (`Stack gap`, `Cluster gap`, `Grid`, `PaneSection`, `Page`, the inset of a Grammar box), never
|
|
5
|
+
* a raw value. The class-string half is the canon's `starci-fe/no-spacing-utility` (R350); this rule is the `style` half.
|
|
6
|
+
*
|
|
7
|
+
* WHAT IT READS, in product source: a key of the object a JSX `style` attribute holds that writes a gap, a padding or a margin
|
|
8
|
+
* (`gap`, `rowGap`, `columnGap`, `padding`, `paddingInline`, `paddingTop`, …, `margin`, `marginBlockStart`, …), whatever its value.
|
|
9
|
+
*
|
|
10
|
+
* WHAT IT LEAVES ALONE. Every other style key (a width, a transform, a colour variable), an object that is not a JSX `style` (a chart
|
|
11
|
+
* option, a canvas measure), Freestyle and Fragment regions and non-product source.
|
|
12
|
+
*
|
|
13
|
+
* It is a counting rule (`COUNTING` in index.ts): reported and counted at warn until both apps have moved onto the roles, then blocking.
|
|
14
|
+
*/
|
|
15
|
+
/** A style key that writes a gap, a padding or a margin, on any side or axis. */
|
|
16
|
+
export declare const SPACING_KEY: RegExp;
|
|
17
|
+
/** No raw gap, padding or margin in a JSX `style`: the relation is a Grammar spacing role. */
|
|
18
|
+
export declare const noRawSpacingStyle: Rule.RuleModule;
|
|
19
|
+
/** The rules this law contributes to the plugin. */
|
|
20
|
+
export declare const rules: Record<string, Rule.RuleModule>;
|
|
21
|
+
/** The rule runs in the counting cohort (index.ts `COUNTING`): a warning until both apps migrate. */
|
|
22
|
+
export declare const recommended: Record<string, "warn">;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
|
|
2
|
+
import { defineFamilyRules, defineRule, exemptFreestyle } from "./lib/rule-contract.js";
|
|
3
|
+
/**
|
|
4
|
+
* THE SPACING ROLES (owner, 2026-11-23, SPACING-ROLES; contexts/ui/scale.md "The spacing roles"). A distance between two things an app
|
|
5
|
+
* places is a ROLE the Grammar resolves (`Stack gap`, `Cluster gap`, `Grid`, `PaneSection`, `Page`, the inset of a Grammar box), never
|
|
6
|
+
* a raw value. The class-string half is the canon's `starci-fe/no-spacing-utility` (R350); this rule is the `style` half.
|
|
7
|
+
*
|
|
8
|
+
* WHAT IT READS, in product source: a key of the object a JSX `style` attribute holds that writes a gap, a padding or a margin
|
|
9
|
+
* (`gap`, `rowGap`, `columnGap`, `padding`, `paddingInline`, `paddingTop`, …, `margin`, `marginBlockStart`, …), whatever its value.
|
|
10
|
+
*
|
|
11
|
+
* WHAT IT LEAVES ALONE. Every other style key (a width, a transform, a colour variable), an object that is not a JSX `style` (a chart
|
|
12
|
+
* option, a canvas measure), Freestyle and Fragment regions and non-product source.
|
|
13
|
+
*
|
|
14
|
+
* It is a counting rule (`COUNTING` in index.ts): reported and counted at warn until both apps have moved onto the roles, then blocking.
|
|
15
|
+
*/
|
|
16
|
+
/** A style key that writes a gap, a padding or a margin, on any side or axis. */
|
|
17
|
+
export const SPACING_KEY = /^(?:gap|rowGap|columnGap|row-gap|column-gap|(?:padding|margin)(?:Inline|Block|Top|Bottom|Left|Right)?(?:Start|End)?|(?:padding|margin)(?:-(?:inline|block|top|bottom|left|right)(?:-(?:start|end))?)?)$/;
|
|
18
|
+
const keyName = (node) => {
|
|
19
|
+
if (node.computed)
|
|
20
|
+
return null;
|
|
21
|
+
if (node.key.type === "Identifier")
|
|
22
|
+
return node.key.name;
|
|
23
|
+
return node.key.type === "Literal" && typeof node.key.value === "string" ? node.key.value : null;
|
|
24
|
+
};
|
|
25
|
+
/** The object literal a JSX `style={{ … }}` attribute holds, when the property belongs to it. */
|
|
26
|
+
const inStyleAttribute = (node) => {
|
|
27
|
+
const object = node.parent;
|
|
28
|
+
if (object?.type !== "ObjectExpression")
|
|
29
|
+
return false;
|
|
30
|
+
const container = object.parent;
|
|
31
|
+
if (container?.type !== "JSXExpressionContainer")
|
|
32
|
+
return false;
|
|
33
|
+
const attribute = container.parent;
|
|
34
|
+
return attribute?.type === "JSXAttribute" && attribute.name.type === "JSXIdentifier" && attribute.name.name === "style";
|
|
35
|
+
};
|
|
36
|
+
/** No raw gap, padding or margin in a JSX `style`: the relation is a Grammar spacing role. */
|
|
37
|
+
export const noRawSpacingStyle = exemptFreestyle(defineRule({
|
|
38
|
+
meta: {
|
|
39
|
+
type: "suggestion",
|
|
40
|
+
docs: { description: "SPACING-ROLES: spacing is a Grammar role (Stack or Cluster `gap`, the inset of a Grammar box); no gap, padding or margin in a JSX style." },
|
|
41
|
+
schema: [],
|
|
42
|
+
messages: {
|
|
43
|
+
raw: "`{{key}}` in a style writes a distance the Grammar owns. Name the relation: `gap` on the Stack, Cluster or Grid that holds the siblings (identity 4, inline 8, row 12, section 24, region 32), or the inset of the Grammar box that holds the content (SurfaceCard, PaneSection, Page, Dialog).",
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
create(context) {
|
|
47
|
+
if (!isProductSource(context))
|
|
48
|
+
return {};
|
|
49
|
+
return {
|
|
50
|
+
Property(node) {
|
|
51
|
+
const key = keyName(node);
|
|
52
|
+
if (key === null || !SPACING_KEY.test(key) || !inStyleAttribute(node))
|
|
53
|
+
return;
|
|
54
|
+
context.report({ node: node, messageId: "raw", data: { key } });
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
}));
|
|
59
|
+
/** The rules this law contributes to the plugin. */
|
|
60
|
+
export const rules = {
|
|
61
|
+
"no-raw-spacing-style": noRawSpacingStyle,
|
|
62
|
+
};
|
|
63
|
+
defineFamilyRules(rules, "knowledge/ui/presentation/grammar-laws.yaml#SPACING-ROLES");
|
|
64
|
+
/** The rule runs in the counting cohort (index.ts `COUNTING`): a warning until both apps migrate. */
|
|
65
|
+
export const recommended = { "starci-grammar/no-raw-spacing-style": "warn" };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@starci/eslint-grammar-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.58.0",
|
|
4
4
|
"description": "ESLint rules for the core Grammar's component, token and composition contracts.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -68,6 +68,6 @@
|
|
|
68
68
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
69
69
|
"typescript": "^6.0.3"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
72
|
-
"starciSource": "
|
|
71
|
+
"gitHead": "2a18e73915bf793c34aad4a64dca40fef5ceca07",
|
|
72
|
+
"starciSource": "a346f7e8dd7a3242a1c86916ff284f3f7482aa5b263beb68f9912e7492d81066"
|
|
73
73
|
}
|
|
@@ -320,3 +320,14 @@ rules:
|
|
|
320
320
|
The scroll area is a Grammar scroller (`VerticalScrollRegion`, `HorizontalScrollRegion`, `PaneSection` with `scroll`):
|
|
321
321
|
the scrollbar is hidden, a fading edge (ScrollShadow behaviour) shows where content continues, and wheel, touch and
|
|
322
322
|
keyboard scrolling keep working. An app element with an `overflow-y-auto` or `overflow-auto` class is refused.
|
|
323
|
+
- id: SPACING-ROLES
|
|
324
|
+
title: Spacing is a Grammar role
|
|
325
|
+
governs: The gaps, paddings and margins an app writes.
|
|
326
|
+
cases:
|
|
327
|
+
- id: case-1
|
|
328
|
+
when: An app separates two things it places, or pads content inside a box
|
|
329
|
+
assert: |-
|
|
330
|
+
The distance is a role the Grammar resolves (owner 2026-11-23; contexts/ui/scale.md "The spacing roles"): identity 4, inline 8,
|
|
331
|
+
row 12, section 24 and region 32 on a Stack, Cluster or Grid `gap`, and the inset of the Grammar box that holds the content.
|
|
332
|
+
A spacing utility in a class string is `starci-fe/no-spacing-utility` (R350); a gap, padding or margin key in a JSX `style`
|
|
333
|
+
is reported (`starci-grammar/no-raw-spacing-style`, a counting rule at warn until both apps migrate, then blocking).
|