@starci/eslint-grammar-core 0.21.31 → 0.21.33
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 +9 -0
- package/dist/choice-controls.d.ts +18 -0
- package/dist/choice-controls.js +59 -0
- package/dist/index.js +2 -0
- package/dist/lib/why.js +5 -0
- package/docs/choice-controls.md +11 -0
- package/package.json +2 -2
- package/runtime/knowledge/hfs/canon-pins.yaml +6 -6
- package/runtime/knowledge/hfs/rules.yaml +18 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.21.33 - 2026-11-05
|
|
4
|
+
|
|
5
|
+
- Changed: version stamp, with `@starci/grammar` 0.21.33; requires `@starci/eslint-canon-fe` 9.13.15. The runtime copy of the canon pins names `@starci/hfs` 5.10.3.
|
|
6
|
+
- Added: `starci-grammar/no-grouped-choice-controls` (R380 `FE_GROUPED_CHOICE_CONTROL`): a `ButtonGroup`, `FilterButtonGroup` or `SegmentedControl` in product source is red and the message names the replacement (separate Buttons or a DropdownMenu, `Tabs kind="filter"`, `ChoiceChips` or `RadioGroup`).
|
|
7
|
+
|
|
8
|
+
## 0.21.32 - 2026-11-05
|
|
9
|
+
|
|
10
|
+
- Changed: version stamp only, with `@starci/grammar` 0.21.32; requires `@starci/eslint-canon-fe` 9.13.14. The runtime copy of R377 accepts a bounded `removeOnFail`, and the runtime copy of the canon pins names `@starci/hfs` 5.10.2.
|
|
11
|
+
|
|
3
12
|
## 0.21.31 - 2026-11-05
|
|
4
13
|
|
|
5
14
|
- Changed: version stamp only, with `@starci/grammar` 0.21.31; requires `@starci/eslint-canon-fe` 9.13.13. The runtime copy of R378 (`HFS_BRANCH_PROFILE_INVALID`) allows a branch pattern that never matches the default branch, and the runtime copy of the canon pins names the Grammar family 0.21.31.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Rule } from "eslint";
|
|
2
|
+
/**
|
|
3
|
+
* The rule that holds the one-way-to-choose law (HFS R380, `FE_GROUPED_CHOICE_CONTROL`): the Grammar draws no group of
|
|
4
|
+
* attached buttons. Choosing among a few is one component by meaning: `Tabs` to switch a view or filter a list, `ChoiceChips`
|
|
5
|
+
* or `RadioGroup` to choose a value of a form, separate `Button`s or a `DropdownMenu` for actions, and the Calendar and
|
|
6
|
+
* `ChoiceChips` for a date and a time.
|
|
7
|
+
*
|
|
8
|
+
* WHAT IT READS. A JSX element named `ButtonGroup`, `FilterButtonGroup` or `SegmentedControl` in product source, written
|
|
9
|
+
* bare or as a member (`Grammar.ButtonGroup`). The components stay exported and deprecated for one release.
|
|
10
|
+
*/
|
|
11
|
+
/** Each banned component with the replacement its message names. */
|
|
12
|
+
export declare const REPLACEMENTS: Readonly<Record<string, string>>;
|
|
13
|
+
/** No ButtonGroup, FilterButtonGroup or SegmentedControl in product source. */
|
|
14
|
+
export declare const noGroupedChoiceControls: Rule.RuleModule;
|
|
15
|
+
/** The rules this law contributes to the plugin. */
|
|
16
|
+
export declare const rules: Record<string, Rule.RuleModule>;
|
|
17
|
+
/** Every rule of this law is an error. */
|
|
18
|
+
export declare const recommended: Record<string, "error">;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
|
|
2
|
+
import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
|
|
3
|
+
/**
|
|
4
|
+
* The rule that holds the one-way-to-choose law (HFS R380, `FE_GROUPED_CHOICE_CONTROL`): the Grammar draws no group of
|
|
5
|
+
* attached buttons. Choosing among a few is one component by meaning: `Tabs` to switch a view or filter a list, `ChoiceChips`
|
|
6
|
+
* or `RadioGroup` to choose a value of a form, separate `Button`s or a `DropdownMenu` for actions, and the Calendar and
|
|
7
|
+
* `ChoiceChips` for a date and a time.
|
|
8
|
+
*
|
|
9
|
+
* WHAT IT READS. A JSX element named `ButtonGroup`, `FilterButtonGroup` or `SegmentedControl` in product source, written
|
|
10
|
+
* bare or as a member (`Grammar.ButtonGroup`). The components stay exported and deprecated for one release.
|
|
11
|
+
*/
|
|
12
|
+
/** Each banned component with the replacement its message names. */
|
|
13
|
+
export const REPLACEMENTS = {
|
|
14
|
+
ButtonGroup: "separate `Button`s (one commit, the rest alternative or dismiss), or a `DropdownMenu` for the overflow",
|
|
15
|
+
FilterButtonGroup: "`Tabs kind=\"filter\"` (compact underline tabs with a `count` each, under the list's search field) to narrow a list that stays in place",
|
|
16
|
+
SegmentedControl: "`ChoiceChips` or `RadioGroup` to choose a value of a form, or `Tabs` only to switch a view",
|
|
17
|
+
};
|
|
18
|
+
/** The element name of a JSX opening element (`ButtonGroup`, or `Grammar.ButtonGroup` as `ButtonGroup`). */
|
|
19
|
+
const elementName = (opening) => {
|
|
20
|
+
const name = opening.name;
|
|
21
|
+
if (name.type === "JSXIdentifier")
|
|
22
|
+
return name.name;
|
|
23
|
+
if (name.type === "JSXMemberExpression")
|
|
24
|
+
return name.property.name;
|
|
25
|
+
return null;
|
|
26
|
+
};
|
|
27
|
+
/** No ButtonGroup, FilterButtonGroup or SegmentedControl in product source. */
|
|
28
|
+
export const noGroupedChoiceControls = defineRule({
|
|
29
|
+
meta: {
|
|
30
|
+
type: "problem",
|
|
31
|
+
docs: { description: "R380: no ButtonGroup, FilterButtonGroup or SegmentedControl; choose by meaning (Tabs, ChoiceChips, RadioGroup, separate Buttons, DropdownMenu)." },
|
|
32
|
+
schema: [],
|
|
33
|
+
messages: {
|
|
34
|
+
grouped: "`{{component}}` is deprecated: the Grammar draws no group of attached buttons, because a few choices have exactly one component by meaning. Use {{replacement}}.",
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
create(context) {
|
|
38
|
+
if (!isProductSource(context))
|
|
39
|
+
return {};
|
|
40
|
+
return {
|
|
41
|
+
JSXOpeningElement(opening) {
|
|
42
|
+
const component = elementName(opening);
|
|
43
|
+
if (component === null)
|
|
44
|
+
return;
|
|
45
|
+
const replacement = REPLACEMENTS[component];
|
|
46
|
+
if (replacement === undefined)
|
|
47
|
+
return;
|
|
48
|
+
context.report({ node: opening, messageId: "grouped", data: { component, replacement } });
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
/** The rules this law contributes to the plugin. */
|
|
54
|
+
export const rules = {
|
|
55
|
+
"no-grouped-choice-controls": noGroupedChoiceControls,
|
|
56
|
+
};
|
|
57
|
+
defineFamilyRules(rules, "knowledge/hfs/rules.yaml#R380");
|
|
58
|
+
/** Every rule of this law is an error. */
|
|
59
|
+
export const recommended = Object.fromEntries(Object.keys(rules).map((name) => [`starci-grammar/${name}`, "error"]));
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import tsParser from "@typescript-eslint/parser";
|
|
|
2
2
|
import { SOURCE_FILES, linterOptions as canonLinterOptions, scopeToPackages } from "@starci/eslint-canon-fe/lib/config.mjs";
|
|
3
3
|
import { rules as appShellRules } from "./app-shell.js";
|
|
4
4
|
import { rules as chipLabelRules } from "./chip-label.js";
|
|
5
|
+
import { rules as choiceControlsRules } from "./choice-controls.js";
|
|
5
6
|
import { rules as drawingRules } from "./drawing.js";
|
|
6
7
|
import { rules as freestyleRules } from "./freestyle.js";
|
|
7
8
|
import { rules as grammarBoundaryRules } from "./grammar-boundary.js";
|
|
@@ -21,6 +22,7 @@ import { why as familyWhy } from "./lib/why.js";
|
|
|
21
22
|
const CONTRIBUTIONS = [
|
|
22
23
|
{ law: "app-shell", rules: appShellRules },
|
|
23
24
|
{ law: "chip-label", rules: chipLabelRules },
|
|
25
|
+
{ law: "choice-controls", rules: choiceControlsRules },
|
|
24
26
|
{ law: "drawing", rules: drawingRules },
|
|
25
27
|
{ law: "freestyle", rules: freestyleRules },
|
|
26
28
|
{ law: "grammar-boundary", rules: grammarBoundaryRules },
|
package/dist/lib/why.js
CHANGED
|
@@ -9,6 +9,11 @@ export const why = {
|
|
|
9
9
|
en: "A StatusDot or Badge label in `<file>` starts with a lowercase letter.",
|
|
10
10
|
fix: "Start the label with an uppercase letter (`Running`, not `running`); the rule fixes a literal label in place.",
|
|
11
11
|
},
|
|
12
|
+
"no-grouped-choice-controls": {
|
|
13
|
+
code: "FE_GROUPED_CHOICE_CONTROL",
|
|
14
|
+
en: "A ButtonGroup, FilterButtonGroup or SegmentedControl in `<file>` draws a group of attached buttons, which the Grammar no longer has.",
|
|
15
|
+
fix: "Use the component of the meaning: Tabs (kind filter for a list) to switch a view or filter, ChoiceChips or RadioGroup to choose a form value, separate Buttons or a DropdownMenu for actions.",
|
|
16
|
+
},
|
|
12
17
|
"generated-art-in-mascot-or-media-frame": {
|
|
13
18
|
code: "FE_GENERATED_ART_OUTSIDE_FRAME",
|
|
14
19
|
en: "Generated art (a `.webp` or `.png` under `/images/`) in `<file>` is drawn outside Grammar's `Mascot` and `MediaFrame`, so it takes whatever box the page gives it.",
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# One way to choose among a few
|
|
2
|
+
|
|
3
|
+
Law module: `choice-controls.ts`. Catalogue: R380 FE_GROUPED_CHOICE_CONTROL.
|
|
4
|
+
|
|
5
|
+
The Grammar draws no group of attached buttons. A choice among a few has one component by meaning: `Tabs` switches a view or filters a list that stays in place (`kind="filter"`: compact underline tabs with a `count` each, in the list pane under its search field), `ChoiceChips` or `RadioGroup` chooses a value of a form (a tablist is not a form field), separate `Button`s or a `DropdownMenu` carry actions, and a date is the `Calendar` with a time as `ChoiceChips`. `ButtonGroup`, `FilterButtonGroup` and `SegmentedControl` stay exported and deprecated for one release so existing screens build; the rule stops new uses.
|
|
6
|
+
|
|
7
|
+
Every rule below is an error in `coreGrammarConfig`; none can be switched off or suppressed inline.
|
|
8
|
+
|
|
9
|
+
## `starci-grammar/no-grouped-choice-controls`
|
|
10
|
+
|
|
11
|
+
A JSX element named `ButtonGroup`, `FilterButtonGroup` or `SegmentedControl` (bare or as a member) in product source is a finding; the message names the replacement for that component.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@starci/eslint-grammar-core",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.33",
|
|
4
4
|
"description": "ESLint rules for the core Grammar's component, token and composition contracts.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"node": ">=22"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"@starci/eslint-canon-fe": "9.13.
|
|
44
|
+
"@starci/eslint-canon-fe": "9.13.15",
|
|
45
45
|
"eslint": ">=9",
|
|
46
46
|
"typescript": ">=5.9"
|
|
47
47
|
},
|
|
@@ -38,7 +38,7 @@ pins:
|
|
|
38
38
|
source: packages/next-data/package.json
|
|
39
39
|
why: 'the SWR data helpers of every front end (fe-stack data, owner:next-data-package): pollingRestart, the viewer and tenant key helpers, viewerSwrConfig and the viewer cache; each operation hook stays in the app and the package holds no component.'
|
|
40
40
|
'@starci/grammar':
|
|
41
|
-
version: 0.21.
|
|
41
|
+
version: 0.21.33
|
|
42
42
|
group: starci
|
|
43
43
|
install: registry
|
|
44
44
|
side: fe
|
|
@@ -52,28 +52,28 @@ pins:
|
|
|
52
52
|
source: packages/next-i18n/package.json
|
|
53
53
|
why: 'the next-intl stack of every front end (fe-stack i18n, owner:next-i18n-package): defineI18n over the locales of the app, the locale-negotiating proxy, the locale-aware navigation, the request config that loads the catalogs of the app and the locale read of the [locale] layout; the app keeps its message catalogs and writes none of the stack.'
|
|
54
54
|
'@starci/eslint-canon-be':
|
|
55
|
-
version: 3.17.
|
|
55
|
+
version: 3.17.3
|
|
56
56
|
group: starci
|
|
57
57
|
install: registry
|
|
58
58
|
side: be
|
|
59
59
|
source: packages/eslint-canon-be/package.json
|
|
60
60
|
why: 'the back-end ESLint canon: `loadHfs(import.meta.url)` of be/eslint.config.mjs finds the app-root hfs.json (kind app) and gives every linted file the view of the be side, and the project graph is built per side; its bundled runtime copies (slots, canon-pins, failure codes, the architecture machine) put .starcistacks and .sops.yaml at the app root; `starciBeConfig({ hfs: loadHfs(import.meta.url) })` is the typed factory and the BE-CONVENTION laws are its rules.'
|
|
61
61
|
'@starci/eslint-canon-fe':
|
|
62
|
-
version: 9.13.
|
|
62
|
+
version: 9.13.15
|
|
63
63
|
group: starci
|
|
64
64
|
install: registry
|
|
65
65
|
side: fe
|
|
66
66
|
source: packages/eslint-canon-fe/package.json
|
|
67
67
|
why: 'the front-end ESLint canon: `loadHfs(import.meta.url)` of fe/eslint.config.mjs finds the app-root hfs.json (kind app) and gives every linted file the view of the fe side, and the project graph is built per side; its bundled runtime copies (slots, canon-pins, failure codes, the architecture machine) put .starcistacks and .sops.yaml at the app root; the front end has no tests (FE_NO_TESTS R97 in hfs) and no-vietnamese-in-source (R91) applies.'
|
|
68
68
|
'@starci/eslint-grammar-core':
|
|
69
|
-
version: 0.21.
|
|
69
|
+
version: 0.21.33
|
|
70
70
|
group: starci
|
|
71
71
|
install: registry
|
|
72
72
|
side: fe
|
|
73
73
|
source: packages/eslint-grammar-core/package.json
|
|
74
74
|
why: 'the StarCi Grammar component API lint, versioned with @starci/grammar; front ends compose this family package with the universal FE canon.'
|
|
75
75
|
'@starci/eslint-grammar-offset-pop':
|
|
76
|
-
version: 0.21.
|
|
76
|
+
version: 0.21.33
|
|
77
77
|
group: starci
|
|
78
78
|
install: registry
|
|
79
79
|
side: fe
|
|
@@ -155,7 +155,7 @@ pins:
|
|
|
155
155
|
source: packages/mail/package.json
|
|
156
156
|
why: 'outgoing mail of a back end: a NestJS module and the Mailer port over SMTP (connect, greeting, socket and total timeouts, STARTTLS required by default, recipient, message and attachment checks, a shared SMTP target policy, coded errors, typed escaping render helpers returning { subject, text, html }), with @starci/mail/testing for its specs; the only importer of nodemailer (R90).'
|
|
157
157
|
'@starci/hfs':
|
|
158
|
-
version: 5.10.
|
|
158
|
+
version: 5.10.3
|
|
159
159
|
group: starci
|
|
160
160
|
install: registry
|
|
161
161
|
side: both
|
|
@@ -6665,7 +6665,7 @@ rules:
|
|
|
6665
6665
|
- {path: packages/hfs/src/hfs-boot-logger.spec.mjs, editions: [lite, full]}
|
|
6666
6666
|
- id: R377
|
|
6667
6667
|
code: "BE_FLOW_FAILURE_SWALLOWED"
|
|
6668
|
-
law: "Every job and saga flow runs itself again after a failure of any kind: a processor, a job step, a saga step or compensation and a message consumer never catch a failure without rethrowing or parking it, and no back-end source sets BullMQ's `removeOnFail
|
|
6668
|
+
law: "Every job and saga flow runs itself again after a failure of any kind: a processor, a job step, a saga step or compensation and a message consumer never catch a failure without rethrowing or parking it, and no back-end source sets BullMQ's `removeOnFail` to delete failed jobs (`true`, a bare count, an unreadable value), while a bounded retention of the broker copy (an object literal naming `age` or `count`), `false` and a type member that only declares the option are accepted, the parked row being the durable failure; the runner classifies the failure (`classifyFailure`), retries a transient one and parks any other as `failed_awaiting_fix` with one alert until a resume, so no flow ends as a silent dead letter."
|
|
6669
6669
|
kinds: [check]
|
|
6670
6670
|
gates: [settle, land, ci]
|
|
6671
6671
|
failureCodes: ["BE_FLOW_FAILURE_SWALLOWED"]
|
|
@@ -6711,3 +6711,20 @@ rules:
|
|
|
6711
6711
|
- {path: packages/hfs/src/branch-profile.spec.mjs, editions: [lite, full]}
|
|
6712
6712
|
witness:
|
|
6713
6713
|
- {path: packages/hfs/src/branch-profile.spec.mjs, editions: [lite, full]}
|
|
6714
|
+
- id: R380
|
|
6715
|
+
code: "FE_GROUPED_CHOICE_CONTROL"
|
|
6716
|
+
law: "The Grammar draws no group of attached buttons: a ButtonGroup, FilterButtonGroup or SegmentedControl in product source is refused and the message names the replacement by meaning, Tabs to switch a view or filter a list (kind filter), ChoiceChips or RadioGroup to choose a value of a form, separate Buttons or a DropdownMenu for actions. The three components stay exported and deprecated for one release."
|
|
6717
|
+
kinds: [lint]
|
|
6718
|
+
gates: [pre-commit, settle, land, ci]
|
|
6719
|
+
failureCodes: ["FE_GROUPED_CHOICE_CONTROL"]
|
|
6720
|
+
enforcers:
|
|
6721
|
+
- {kind: eslint-grammar-core, id: no-grouped-choice-controls}
|
|
6722
|
+
editions: [lite, full]
|
|
6723
|
+
docs: [knowledge/patterns/fe/index.yaml#FE-RULE-OWNERSHIP]
|
|
6724
|
+
templateNa: "A template draws no choice control."
|
|
6725
|
+
proves:
|
|
6726
|
+
- packages/eslint/grammar-core/choice-controls.spec.mjs
|
|
6727
|
+
exemplifiedBy:
|
|
6728
|
+
- {path: packages/eslint/grammar-core/choice-controls.spec.mjs, editions: [lite, full], codes: [FE_GROUPED_CHOICE_CONTROL]}
|
|
6729
|
+
witness:
|
|
6730
|
+
- {path: packages/eslint/grammar-core/choice-controls.spec.mjs, editions: [lite, full], codes: [FE_GROUPED_CHOICE_CONTROL]}
|