@starci/eslint-grammar-core 0.0.0-stage → 0.14.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 +73 -0
- package/LICENSE +21 -0
- package/README.md +53 -2
- package/dist/app-shell.d.ts +15 -0
- package/dist/app-shell.js +224 -0
- package/dist/chip-label.d.ts +14 -0
- package/dist/chip-label.js +117 -0
- package/dist/drawing.d.ts +8 -0
- package/dist/drawing.js +59 -0
- package/dist/grammar-boundary.d.ts +12 -0
- package/dist/grammar-boundary.js +88 -0
- package/dist/icon.d.ts +27 -0
- package/dist/icon.js +293 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.js +73 -0
- package/dist/lib/app-shell-cluster.d.ts +6 -0
- package/dist/lib/app-shell-cluster.js +75 -0
- package/dist/lib/app-shell-create.d.ts +5 -0
- package/dist/lib/app-shell-create.js +37 -0
- package/dist/lib/app-shell-owner-source.d.ts +11 -0
- package/dist/lib/app-shell-owner-source.js +159 -0
- package/dist/lib/app-shell-owner.d.ts +7 -0
- package/dist/lib/app-shell-owner.js +97 -0
- package/dist/lib/app-shell-scope.d.ts +13 -0
- package/dist/lib/app-shell-scope.js +93 -0
- package/dist/lib/app-shell-visible.d.ts +13 -0
- package/dist/lib/app-shell-visible.js +117 -0
- package/dist/lib/app-shell.d.ts +27 -0
- package/dist/lib/app-shell.js +185 -0
- package/dist/lib/rule-contract.d.ts +12 -0
- package/dist/lib/rule-contract.js +23 -0
- package/dist/lib/status-tones.generated.d.ts +2 -0
- package/dist/lib/status-tones.generated.js +8 -0
- package/dist/lib/types.d.ts +113 -0
- package/dist/lib/types.js +2 -0
- package/dist/lib/why.d.ts +8 -0
- package/dist/lib/why.js +42 -0
- package/dist/menu-entries.d.ts +27 -0
- package/dist/menu-entries.js +142 -0
- package/dist/status-colors.d.ts +13 -0
- package/dist/status-colors.js +143 -0
- package/dist/tokens.d.ts +11 -0
- package/dist/tokens.js +166 -0
- package/dist/typography.d.ts +13 -0
- package/dist/typography.js +72 -0
- package/dist/vendor-boundary.d.ts +5 -0
- package/dist/vendor-boundary.js +25 -0
- package/docs/app-shell.md +52 -0
- package/docs/chip-label.md +30 -0
- package/docs/grammar-boundary.md +37 -0
- package/docs/status-colors.md +34 -0
- package/package.json +67 -4
- package/runtime/engine/by-code-unit.mjs +12 -0
- package/runtime/engine/config.mjs +461 -0
- package/runtime/engine/invalid-config.mjs +15 -0
- package/runtime/engine/model-config.mjs +90 -0
- package/runtime/engine/orca-config.mjs +29 -0
- package/runtime/engine/plain-object.mjs +5 -0
- package/runtime/engine/release-config.mjs +28 -0
- package/runtime/engine/removed-vocabulary.mjs +26 -0
- package/runtime/engine/resources-config.mjs +52 -0
- package/runtime/engine/runtime-root.mjs +54 -0
- package/runtime/engine/secrets.mjs +134 -0
- package/runtime/engine/sonar-config.mjs +21 -0
- package/runtime/engine/yaml.mjs +161 -0
- package/runtime/knowledge/grammars/core/playbook.yaml +1214 -0
- package/runtime/knowledge/grammars/index.yaml +102 -0
- package/runtime/knowledge/hfs/canon-pins.yaml +616 -0
- package/runtime/knowledge/hfs/rules.yaml +5689 -0
- package/runtime/knowledge/hfs/slots.yaml +2570 -0
- package/runtime/knowledge/patterns/fe/index.yaml +213 -0
- package/runtime/knowledge/patterns/fe/ui.yaml +85 -0
- package/runtime/knowledge/ui/composition/app-shell.yaml +182 -0
- package/runtime/knowledge/ui/presentation/font.yaml +101 -0
- package/runtime/knowledge/ui/presentation/padding.yaml +217 -0
- package/runtime/knowledge/ui/proof/anatomy-source.yaml +198 -0
- package/runtime/modules/goal/source-phrases.yaml +95 -0
- package/runtime/modules/kernel/removed-vocabulary.yaml +458 -0
- package/runtime/modules/models/registry.yaml +221 -0
- package/runtime/modules/models/runtimes.yaml +556 -0
- package/runtime/modules/models/tiers.yaml +66 -0
- package/runtime/scripts/hfs/allows.mjs +57 -0
- package/runtime/scripts/hfs/architecture/config.mjs +349 -0
- package/runtime/scripts/hfs/architecture/side-boundary.mjs +16 -0
- package/runtime/scripts/hfs/architecture/type-context.mjs +300 -0
- package/runtime/scripts/hfs/architecture/typescript.mjs +417 -0
- package/runtime/scripts/hfs/declaration-shape.mjs +157 -0
- package/runtime/scripts/hfs/declaration-slots.mjs +86 -0
- package/runtime/scripts/hfs/edition-slots.mjs +77 -0
- package/runtime/scripts/hfs/manifest-shape.mjs +435 -0
- package/runtime/scripts/hfs/param-names.mjs +18 -0
- package/runtime/scripts/hfs/rule-catalog.mjs +362 -0
- package/runtime/scripts/hfs/rule-params-shape.mjs +80 -0
- package/runtime/scripts/hfs/slot-app-view.mjs +102 -0
- package/runtime/scripts/hfs/slot-classify.mjs +65 -0
- package/runtime/scripts/hfs/slot-errors.mjs +11 -0
- package/runtime/scripts/hfs/slot-imports.mjs +91 -0
- package/runtime/scripts/hfs/slot-manifest-shape.mjs +73 -0
- package/runtime/scripts/hfs/slot-match.mjs +153 -0
- package/runtime/scripts/hfs/slot-path.mjs +8 -0
- package/runtime/scripts/hfs/slot-required.mjs +89 -0
- package/runtime/scripts/hfs/slot-semantic-problems.mjs +149 -0
- package/runtime/scripts/hfs/slot-side-problems.mjs +28 -0
- package/runtime/scripts/hfs/slots.mjs +259 -0
- package/runtime/scripts/hfs/typescript-programs.mjs +98 -0
- package/runtime/scripts/hfs/view.mjs +73 -0
- package/runtime/scripts/lib/glob.mjs +23 -0
- package/runtime/scripts/lib/grammar-lint.mjs +61 -0
- package/runtime/scripts/lib/i18n.mjs +85 -0
- package/runtime/scripts/lib/json-clone.mjs +61 -0
- package/runtime/scripts/lib/json.mjs +32 -0
- package/runtime/scripts/lib/list.mjs +31 -0
- package/runtime/scripts/lib/path-key.mjs +109 -0
- package/runtime/scripts/lib/read-text.mjs +34 -0
- package/runtime/scripts/lib/regex.mjs +4 -0
- package/runtime/scripts/lib/source-phrases.mjs +34 -0
- package/runtime/scripts/lib/ts-analysis.mjs +37 -0
- package/runtime/scripts/lib/ts-ast.mjs +69 -0
- package/runtime/scripts/lib/walk.mjs +39 -0
- package/runtime/scripts/lib/yaml-cached.mjs +14 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## Unreleased (0.15.0 with the Grammar family)
|
|
4
|
+
|
|
5
|
+
- Unreleased: the Grammar family (`grammar`, `eslint-grammar-core`, `eslint-grammar-offset-pop`) keeps one version and `packages/grammar` is outside this lane, so the minor bump to 0.15.0 lands with the family's release; the package stays 0.14.0 until then.
|
|
6
|
+
- Changed: the source is TypeScript in `src/`, built to `dist/` (`npm run build`; `prepack` builds); the package ships `dist/`, `runtime/` and `docs/` and no hand-written JavaScript or `index.d.ts` (the build emits the declarations, with the same public types). No rule or behaviour changed; the exports and specifiers (`.` and the default plugin) are unchanged.
|
|
7
|
+
- Changed: the specs are `src/*.spec.ts`, typechecked first by `npm test`.
|
|
8
|
+
|
|
9
|
+
## 0.14.0 - 2026-10-27
|
|
10
|
+
|
|
11
|
+
- Changed: versioned together with Grammar 0.14.0; the bundled canon pins name the 0.14.0 Grammar family.
|
|
12
|
+
- Added: `starci-grammar/chip-label-starts-uppercase` (R322 `FE_CHIP_LABEL_CASE`): a literal `StatusDot` or `Badge` label starts with an uppercase letter, Vietnamese included; the fix uppercases it in place.
|
|
13
|
+
- Changed: `@starci/eslint-canon-fe` 9.3.0 is the peer dependency; the bundled canon pins name `starci-harness` 1.1.0-alpha.1 (`source: cli/package.json`) in place of the retired `@starci/cli`, the one command line a product installs for `starci app`, and follow hfs 4.9.0, canon-fe 9.3.0 and canon-be 3.5.0. No rule changes.
|
|
14
|
+
|
|
15
|
+
## 0.13.0 - 2026-10-27
|
|
16
|
+
|
|
17
|
+
- Changed: `@starci/eslint-canon-fe` is a peer dependency (9.2.0), installed by the app beside this package, instead of a nested dependency.
|
|
18
|
+
- Changed: the package lives in github.com/starci183/starci-harness under `packages/` and publishes from there; its bundled `runtime/` is committed source, edited in place (no generator, no `prepack`/`pretest` hook).
|
|
19
|
+
- Changed: owner ruling: there are exactly two Grammar families, `core` and `offset-pop`. This package is renamed from
|
|
20
|
+
`@starci/eslint-grammar-starci` to `@starci/eslint-grammar-core`, and its factory from `starciGrammarConfig` to
|
|
21
|
+
`coreGrammarConfig`, which loads for `sides.fe.grammar: core`.
|
|
22
|
+
- Removed: the ids `starci` and `starci-core` are not families and have no alias; an app that names them is refused.
|
|
23
|
+
Migrate: `sides.fe.grammar: core`, depend on `@starci/eslint-grammar-core`, call `coreGrammarConfig`.
|
|
24
|
+
|
|
25
|
+
## 0.12.14 - 2026-10-27
|
|
26
|
+
|
|
27
|
+
- Changed: versioned together with Grammar 0.12.14; bundled canon pins moved.
|
|
28
|
+
|
|
29
|
+
## 0.12.13 - 2026-10-26
|
|
30
|
+
|
|
31
|
+
- Changed: versioned together with Grammar 0.12.13 (control height 40, shared scroll carets).
|
|
32
|
+
|
|
33
|
+
## 0.12.12 - 2026-10-26
|
|
34
|
+
|
|
35
|
+
- Changed: versioned with Grammar 0.12.12 (the family equality spec); the bundled canon pins and runtime copies follow the final package versions. No rule changes.
|
|
36
|
+
|
|
37
|
+
## 0.12.11 - 2026-10-26
|
|
38
|
+
|
|
39
|
+
- Changed: versioned with the other lint families; depends on the exact front-end canon 9.1.7; the alpha.31.1 round folded into alpha.31; the bundled canon pins and runtime copies follow the final package versions. No rule changes.
|
|
40
|
+
|
|
41
|
+
## 0.12.10 - 2026-10-26
|
|
42
|
+
|
|
43
|
+
- Changed: versioned with Grammar 0.12.10; depends on the exact canon-fe 9.1.6; the bundled canon pins follow the new package pins. No rule changes.
|
|
44
|
+
|
|
45
|
+
## 0.12.9 - 2026-10-26
|
|
46
|
+
|
|
47
|
+
- Changed: versioned with Grammar 0.12.9; depends on the exact canon-fe 9.1.5; the bundled canon pins follow the new package pins. No rule changes.
|
|
48
|
+
|
|
49
|
+
## 0.12.8 - 2026-10-26
|
|
50
|
+
|
|
51
|
+
- Changed: versioned with Grammar 0.12.8; depends on the exact canon-fe 9.1.4; the bundled canon pins follow the new package pins. No rule changes.
|
|
52
|
+
|
|
53
|
+
## 0.12.7 - 2026-10-26
|
|
54
|
+
|
|
55
|
+
- Changed: versioned with Grammar 0.12.7; depends on the exact canon-fe 9.1.3; the bundled canon pins follow the new package pins. No rule changes.
|
|
56
|
+
|
|
57
|
+
## 0.12.6 - 2026-10-26
|
|
58
|
+
|
|
59
|
+
- Changed: versioned with Grammar 0.12.6; depends on @starci/eslint-canon-fe 9.1.2; the bundled runtime copies follow the new sources. No rule changes.
|
|
60
|
+
|
|
61
|
+
## 0.12.5 - 2026-10-26
|
|
62
|
+
|
|
63
|
+
- Changed: versioned with Grammar 0.12.5; depends on @starci/eslint-canon-fe 9.1.1; the bundled canon pins follow the new package pins. No rule changes.
|
|
64
|
+
|
|
65
|
+
## 0.12.4 - 2026-10-26
|
|
66
|
+
|
|
67
|
+
- Changed: versioned with Grammar 0.12.4; no rule changes beyond the version pin.
|
|
68
|
+
|
|
69
|
+
## 0.12.3 - 2026-10-26
|
|
70
|
+
|
|
71
|
+
- Added: the StarCi Grammar lint package, released with Grammar 0.12.3. Concrete family laws move from the universal FE canon with their rule IDs and behavioral specs, including the Grammar 0.12.3 lane's `no-icon-size-class` and `destructive-menu-entry-needs-danger-tone` in their latest form. The R318 surface composition rules stay in the universal canon.
|
|
72
|
+
- Added: the `starciGrammarConfig` flat-config factory, complete error-level recommendations, ownership citations and a generated runtime closure.
|
|
73
|
+
- Shared: generic lint readers are imported from `@starci/eslint-canon-fe` 9.0.0.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) StarCi contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,54 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @starci/eslint-grammar-core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Concrete StarCi Grammar component, prop, variant and token contracts belong here under
|
|
4
|
+
[FE-RULE-OWNERSHIP](../../contexts/code/fe/README.md#the-placement-test-fe-rule-ownership).
|
|
5
|
+
The package version follows `@starci/grammar`; universal FE laws remain in `@starci/eslint-canon-fe`.
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
import { loadHfs, starciFeConfig } from "@starci/eslint-canon-fe"
|
|
9
|
+
import { coreGrammarConfig } from "@starci/eslint-grammar-core"
|
|
10
|
+
|
|
11
|
+
const hfs = loadHfs(import.meta.url)
|
|
12
|
+
export default [...starciFeConfig({ hfs }), ...coreGrammarConfig({ hfs })]
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Every rule uses the `starci-grammar` namespace and runs at error. The factory checks the selected
|
|
16
|
+
Grammar and covers the same source files as the universal factory. Shared AST, type, slot and
|
|
17
|
+
binding readers are imported from the universal package's explicit infrastructure exports.
|
|
18
|
+
Family helpers and the generated runtime closure belong to this package.
|
|
19
|
+
|
|
20
|
+
The rule IDs remain stable when their namespace moves. Laws cover the fixed app shell and navbar,
|
|
21
|
+
Grammar-owned structural elements, glyphs and icon sizes, destructive menu entries, status inks,
|
|
22
|
+
chip labels that start uppercase, heading and token scales, vendor ownership and slot-status composition. Each rule's metadata cites
|
|
23
|
+
its behavioral knowledge source and the governing ownership test. The R318 surface composition
|
|
24
|
+
rules (nested control variants, panel-list alignment, layout-only CSS) stay in the universal canon.
|
|
25
|
+
|
|
26
|
+
## Migrating from @starci/eslint-canon-fe 8.x
|
|
27
|
+
|
|
28
|
+
The pinned canon-fe release moved twenty rules here. Their IDs, finding codes and error severity are unchanged;
|
|
29
|
+
only the namespace changes from `starci-fe/` to `starci-grammar/`: `app-shell-frame`,
|
|
30
|
+
`no-shell-bottom-tabs`, `navbar-control-size`, `navbar-cluster`, `no-navbar-create`,
|
|
31
|
+
`no-raw-structural-element`, `no-heading-tag-outside-heading-component`,
|
|
32
|
+
`status-text-uses-soft-foreground`, `vendor-primitive-has-named-owner`,
|
|
33
|
+
`no-vendor-icon-outside-icon-leaf`, `heroicons-is-the-glyph-vendor`, `no-off-scale-glyph-size`,
|
|
34
|
+
`no-icon-size-class`, `destructive-menu-entry-needs-danger-tone`,
|
|
35
|
+
`no-decorative-icon-in-metric-cell`, `no-inline-svg-outside-brand-mark-leaf`, `no-fractional-step`,
|
|
36
|
+
`no-hand-rolled-heading`, `no-unresolved-token-class` and `slot-status-through-slotview`.
|
|
37
|
+
|
|
38
|
+
1. Set `sides.fe.grammar` to `core` in `hfs.json`; no family is inferred.
|
|
39
|
+
2. Install this package at its canon-pins version beside `@starci/eslint-canon-fe` 9 in the app
|
|
40
|
+
root `devDependencies`. `starci app check` refuses canon-fe 9 without it
|
|
41
|
+
(`FE_STACK_FAMILY_LINT_MISSING`), so the rules cannot be lost silently.
|
|
42
|
+
3. Compose the universal factory first and this one second, with the same HFS view (the block
|
|
43
|
+
above). `starci app sync` renders that managed `fe/eslint.config.mjs`.
|
|
44
|
+
4. Rename references to the moved rules from `starci-fe/` to `starci-grammar/`.
|
|
45
|
+
|
|
46
|
+
Consuming apps migrate in their own release.
|
|
47
|
+
|
|
48
|
+
Offset Pop inherits the Common component contract through `@starci/eslint-grammar-offset-pop`.
|
|
49
|
+
Its own adapter selects that family and reuses these implementations.
|
|
50
|
+
|
|
51
|
+
Regression checks live in this ESLint package. The Grammar and consuming app front ends carry no specs.
|
|
52
|
+
|
|
53
|
+
The source is TypeScript in `src/` (`src/lib/` holds the shared readers, `src/vendor.d.ts` types the untyped canon and runtime
|
|
54
|
+
JavaScript it imports); `npm run build` emits `dist/`, which is what the package ships beside `runtime/` and `docs/`.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Rule } from "eslint";
|
|
2
|
+
/** The app frame is the fixed-viewport Grammar shell; hand-written frame landmarks are rejected. */
|
|
3
|
+
export declare const appShellFrame: Rule.RuleModule;
|
|
4
|
+
/** Bottom navigation is not an alternative compact app-shell frame. */
|
|
5
|
+
export declare const noShellBottomTabs: Rule.RuleModule;
|
|
6
|
+
/** Every visible control in a navbar band uses the shared control size. */
|
|
7
|
+
export declare const navbarControlSize: Rule.RuleModule;
|
|
8
|
+
/** The right cluster is checked at the bar's actions composition, in visual source order. */
|
|
9
|
+
export declare const navbarCluster: Rule.RuleModule;
|
|
10
|
+
/** Creation belongs to its page, never to the global app bar. */
|
|
11
|
+
export declare const noNavbarCreate: Rule.RuleModule;
|
|
12
|
+
/** Every app-shell enforcer is gathered into the ordinary FE lint and gate path. */
|
|
13
|
+
export declare const rules: Record<string, Rule.RuleModule>;
|
|
14
|
+
/** Every rule is mandatory. */
|
|
15
|
+
export declare const recommended: Record<string, "error">;
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
|
|
2
|
+
/** FE-APP-SHELL-1..5: static app-frame and visible navbar composition from the UI canon. */
|
|
3
|
+
import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
|
|
4
|
+
import { grammarName, isBarControl, propOf, resolveLocal, semanticText, textProp } from "./lib/app-shell.js";
|
|
5
|
+
import { appBarOpenings, isAppBar, isAppShell, isNavigationDrawer, ownsAppFrame } from "./lib/app-shell-scope.js";
|
|
6
|
+
import { visitVisible } from "./lib/app-shell-visible.js";
|
|
7
|
+
import { clusterAlternatives } from "./lib/app-shell-cluster.js";
|
|
8
|
+
import { isCreateAction, menuHasCreate } from "./lib/app-shell-create.js";
|
|
9
|
+
import { provesImportedBar, provesNavigationOpener } from "./lib/app-shell-owner.js";
|
|
10
|
+
import { variableOf } from "@starci/eslint-canon-fe/lib/bindings.mjs";
|
|
11
|
+
import { walk } from "@starci/eslint-canon-fe/lib/ast.mjs";
|
|
12
|
+
const CANON = "knowledge/ui/composition/app-shell.yaml";
|
|
13
|
+
const BOTTOM_TABS = /^(?:BottomNav|BottomNavigation|BottomTabBar|MobileBottomNav|MobileTabBar)$/;
|
|
14
|
+
const EXPECTED_CLUSTER = ["language:IconButton", "theme:Switch", "notifications:IconButton", "account:AvatarButton"];
|
|
15
|
+
const meta = (code, description, messages) => ({
|
|
16
|
+
type: "problem",
|
|
17
|
+
docs: { description: `${code}: ${description}`, url: CANON },
|
|
18
|
+
schema: [],
|
|
19
|
+
messages,
|
|
20
|
+
});
|
|
21
|
+
/** Whether a slot is present; unknown spreads do not prove either presence or absence. */
|
|
22
|
+
const slotPresence = (context, opening, name) => {
|
|
23
|
+
const prop = propOf(context, opening, name);
|
|
24
|
+
if (!prop.known)
|
|
25
|
+
return null;
|
|
26
|
+
const value = resolveLocal(context, prop.value);
|
|
27
|
+
if (value === null || value === undefined || value.type === "Literal" && (value.value == null || value.value === false))
|
|
28
|
+
return false;
|
|
29
|
+
return !(value.type === "Identifier" && value.name === "undefined" && !variableOf(context, value)?.defs.length);
|
|
30
|
+
};
|
|
31
|
+
/** Resolve constants and require every possible conditional value to prove the slot contract. */
|
|
32
|
+
const everyValue = (context, expression, proves, seen = new Set()) => {
|
|
33
|
+
const node = resolveLocal(context, expression);
|
|
34
|
+
if (!node || seen.has(node))
|
|
35
|
+
return false;
|
|
36
|
+
if (node.type !== "ConditionalExpression")
|
|
37
|
+
return proves(node);
|
|
38
|
+
const visited = new Set(seen).add(node);
|
|
39
|
+
return [node.consequent, node.alternate].every((branch) => everyValue(context, branch, proves, visited));
|
|
40
|
+
};
|
|
41
|
+
const hasMobileNavigation = (context, opening) => {
|
|
42
|
+
const drawerProp = propOf(context, opening, "navigationDrawer");
|
|
43
|
+
const drawer = drawerProp.known && everyValue(context, drawerProp.value, (value) => value.type === "ObjectExpression");
|
|
44
|
+
const opener = drawer || provesNavigationOpener(context, propOf(context, opening, "compactHeader").value);
|
|
45
|
+
const visibility = propOf(context, opening, "navigationVisibility");
|
|
46
|
+
const defaultsWide = opener && visibility.known && slotPresence(context, opening, "navigationVisibility") === false;
|
|
47
|
+
if (!defaultsWide && (!visibility.known || !everyValue(context, visibility.value, (value) => value.type === "Literal" && value.value === "wide")))
|
|
48
|
+
return false;
|
|
49
|
+
return opener;
|
|
50
|
+
};
|
|
51
|
+
/** App-owned tab names count only in a frame owner or a shell's rendered slots. */
|
|
52
|
+
const visibleFromShell = (context, target) => {
|
|
53
|
+
let visible = false;
|
|
54
|
+
walk(context.sourceCode, context.sourceCode.ast, (node) => {
|
|
55
|
+
if (node.type !== "JSXOpeningElement" || !isAppShell(context, node))
|
|
56
|
+
return;
|
|
57
|
+
const inspect = (opening) => { if (opening === target)
|
|
58
|
+
visible = true; };
|
|
59
|
+
for (const slot of ["header", "compactHeader", "navigation", "primary", "floatingLayer", "compactNavigation"])
|
|
60
|
+
visitVisible(context, propOf(context, node, slot).value, inspect);
|
|
61
|
+
for (const child of node.parent.children)
|
|
62
|
+
visitVisible(context, child, inspect);
|
|
63
|
+
});
|
|
64
|
+
return visible;
|
|
65
|
+
};
|
|
66
|
+
/** The app frame is the fixed-viewport Grammar shell; hand-written frame landmarks are rejected. */
|
|
67
|
+
export const appShellFrame = defineRule({
|
|
68
|
+
meta: meta("FE_APP_SHELL_FRAME", "FE-APP-SHELL-1 uses WorkspaceShell viewport=fixed.", {
|
|
69
|
+
frame: "FE_APP_SHELL_FRAME: compose the app frame with WorkspaceShell viewport=\"fixed\"; navigation must resolve to navigationVisibility=\"wide\" and have navigationDrawer or a compactHeader with a left Drawer containing Sidebar presentation=\"drawer\". Grammar owns its header, navigation and independent scroll regions.",
|
|
70
|
+
}),
|
|
71
|
+
create(context) {
|
|
72
|
+
if (!isProductSource(context))
|
|
73
|
+
return {};
|
|
74
|
+
return { JSXOpeningElement(node) {
|
|
75
|
+
const shell = isAppShell(context, node);
|
|
76
|
+
const wrongViewport = shell && textProp(context, node, "viewport") !== "fixed";
|
|
77
|
+
const missingVisibility = shell && slotPresence(context, node, "navigation") !== false && !hasMobileNavigation(context, node);
|
|
78
|
+
const handFrame = ownsAppFrame(context, node) && (node.name.type === "JSXIdentifier" && ["header", "nav", "main"].includes(node.name.name) || isAppBar(context, node) && !appBarOpenings(context).has(node));
|
|
79
|
+
if (wrongViewport || missingVisibility || handFrame) {
|
|
80
|
+
context.report({ node, messageId: "frame" });
|
|
81
|
+
}
|
|
82
|
+
} };
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
/** Bottom navigation is not an alternative compact app-shell frame. */
|
|
86
|
+
export const noShellBottomTabs = defineRule({
|
|
87
|
+
meta: meta("FE_APP_SHELL_BOTTOM_TABS", "FE-APP-SHELL-4 keeps mobile navigation in the sidebar drawer.", {
|
|
88
|
+
bottom: "FE_APP_SHELL_BOTTOM_TABS: the app shell uses a mobile subnav opener and Sidebar drawer. Remove bottom tab navigation and WorkspaceShell compactNavigation.",
|
|
89
|
+
}),
|
|
90
|
+
create(context) {
|
|
91
|
+
if (!isProductSource(context))
|
|
92
|
+
return {};
|
|
93
|
+
return { JSXOpeningElement(node) {
|
|
94
|
+
const name = grammarName(context, node);
|
|
95
|
+
const appTab = name === null && node.name.type === "JSXIdentifier" && BOTTOM_TABS.test(node.name.name) && (ownsAppFrame(context, node) || visibleFromShell(context, node));
|
|
96
|
+
const compact = name === "WorkspaceShell" ? propOf(context, node, "compactNavigation") : null;
|
|
97
|
+
const value = compact ? resolveLocal(context, compact.value) : null;
|
|
98
|
+
const absent = value?.type === "Identifier" && value.name === "undefined" && !variableOf(context, value)?.defs.length;
|
|
99
|
+
if (BOTTOM_TABS.test(name ?? "") || appTab || compact && !absent && (!compact.known || compact.value !== null || compact.present))
|
|
100
|
+
context.report({ node, messageId: "bottom" });
|
|
101
|
+
} };
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
const visitBar = (context, node, visit) => {
|
|
105
|
+
const name = grammarName(context, node);
|
|
106
|
+
if (name === "WorkspaceShell" && isAppShell(context, node)) {
|
|
107
|
+
for (const slot of ["header", "compactHeader"])
|
|
108
|
+
visitVisible(context, propOf(context, node, slot).value, visit);
|
|
109
|
+
}
|
|
110
|
+
else if (isAppBar(context, node)) {
|
|
111
|
+
visitVisible(context, node.parent, visit);
|
|
112
|
+
}
|
|
113
|
+
else if (isNavigationDrawer(context, node)) {
|
|
114
|
+
visitVisible(context, propOf(context, node, "trigger").value, visit);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
const delegatesImportedBar = (context, expression) => {
|
|
118
|
+
let imported = false;
|
|
119
|
+
let controls = false;
|
|
120
|
+
let unknown = false;
|
|
121
|
+
visitVisible(context, expression, (opening, name) => {
|
|
122
|
+
if (isBarControl(context, opening, name))
|
|
123
|
+
controls = true;
|
|
124
|
+
if (name !== null)
|
|
125
|
+
return;
|
|
126
|
+
const proof = provesImportedBar(context, opening);
|
|
127
|
+
if (proof === true)
|
|
128
|
+
imported = true;
|
|
129
|
+
if (proof === false)
|
|
130
|
+
unknown = true;
|
|
131
|
+
});
|
|
132
|
+
return imported && !controls && !unknown;
|
|
133
|
+
};
|
|
134
|
+
/** Every visible control in a navbar band uses the shared control size. */
|
|
135
|
+
export const navbarControlSize = defineRule({
|
|
136
|
+
meta: meta("FE_NAVBAR_CONTROL_SIZE", "FE-APP-SHELL-2 requires size=control on bar controls.", {
|
|
137
|
+
control: "FE_NAVBAR_CONTROL_SIZE: {{name}} in the navbar band needs size=\"control\" so every bar control shares Grammar's control height.",
|
|
138
|
+
}),
|
|
139
|
+
create(context) {
|
|
140
|
+
if (!isProductSource(context))
|
|
141
|
+
return {};
|
|
142
|
+
const reported = new Set();
|
|
143
|
+
return { JSXOpeningElement(node) {
|
|
144
|
+
visitBar(context, node, (control, name) => {
|
|
145
|
+
if (!isBarControl(context, control, name) || textProp(context, control, "size") === "control" || reported.has(control))
|
|
146
|
+
return;
|
|
147
|
+
reported.add(control);
|
|
148
|
+
context.report({ node: control, messageId: "control", data: { name } });
|
|
149
|
+
});
|
|
150
|
+
} };
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
/** The right cluster is checked at the bar's actions composition, in visual source order. */
|
|
154
|
+
export const navbarCluster = defineRule({
|
|
155
|
+
meta: meta("FE_NAVBAR_CLUSTER", "FE-APP-SHELL-3 fixes navbar action kinds and order.", {
|
|
156
|
+
cluster: "FE_NAVBAR_CLUSTER: navbar actions must be a tertiary Language IconButton in DropdownMenu, theme Switch, notification IconButton in Popover, account AvatarButton in DropdownMenu, in that order. Mobile retains notifications then account and moves language/theme into the drawer.",
|
|
157
|
+
}),
|
|
158
|
+
create(context) {
|
|
159
|
+
if (!isProductSource(context))
|
|
160
|
+
return {};
|
|
161
|
+
return { JSXOpeningElement(node) {
|
|
162
|
+
const name = grammarName(context, node);
|
|
163
|
+
if (!isAppShell(context, node) && !isAppBar(context, node))
|
|
164
|
+
return;
|
|
165
|
+
const shellHeader = name === "WorkspaceShell";
|
|
166
|
+
const actions = propOf(context, node, shellHeader ? "header" : "actions");
|
|
167
|
+
const { alternatives, ownsBar } = clusterAlternatives(context, actions.value, shellHeader);
|
|
168
|
+
if (ownsBar)
|
|
169
|
+
return;
|
|
170
|
+
if (shellHeader && delegatesImportedBar(context, actions.value))
|
|
171
|
+
return;
|
|
172
|
+
const desktop = EXPECTED_CLUSTER.join("|");
|
|
173
|
+
const mobile = EXPECTED_CLUSTER.slice(2).join("|");
|
|
174
|
+
const sequences = alternatives.map((sequence) => sequence.join("|"));
|
|
175
|
+
if (!sequences.includes(desktop) || sequences.some((sequence) => sequence !== desktop && sequence !== mobile))
|
|
176
|
+
context.report({ node, messageId: "cluster" });
|
|
177
|
+
} };
|
|
178
|
+
},
|
|
179
|
+
});
|
|
180
|
+
/** Creation belongs to its page, never to the global app bar. */
|
|
181
|
+
export const noNavbarCreate = defineRule({
|
|
182
|
+
meta: meta("FE_NAVBAR_CREATE", "FE-APP-SHELL-5 keeps create actions on pages.", {
|
|
183
|
+
create: "FE_NAVBAR_CREATE: move this create action from the navbar to its page.",
|
|
184
|
+
}),
|
|
185
|
+
create(context) {
|
|
186
|
+
if (!isProductSource(context))
|
|
187
|
+
return {};
|
|
188
|
+
const reported = new Set();
|
|
189
|
+
const report = (node) => {
|
|
190
|
+
if (reported.has(node))
|
|
191
|
+
return;
|
|
192
|
+
reported.add(node);
|
|
193
|
+
context.report({ node, messageId: "create" });
|
|
194
|
+
};
|
|
195
|
+
const inspect = (control, name) => {
|
|
196
|
+
if (name === "DropdownMenu" || name === "Popover") {
|
|
197
|
+
if (["entries", "items", "sections"].some((slot) => menuHasCreate(context, propOf(context, control, slot).value)))
|
|
198
|
+
report(control);
|
|
199
|
+
visitVisible(context, propOf(context, control, "content").value, inspect);
|
|
200
|
+
for (const child of control.parent.children)
|
|
201
|
+
visitVisible(context, child, inspect);
|
|
202
|
+
}
|
|
203
|
+
if (!isBarControl(context, control, name) || reported.has(control))
|
|
204
|
+
return;
|
|
205
|
+
const text = `${semanticText(context, control)} ${control.parent.children.map((child) => context.sourceCode.getText(child)).join(" ")}`;
|
|
206
|
+
if (isCreateAction(text))
|
|
207
|
+
report(control);
|
|
208
|
+
};
|
|
209
|
+
return { JSXOpeningElement(node) {
|
|
210
|
+
visitBar(context, node, inspect);
|
|
211
|
+
} };
|
|
212
|
+
},
|
|
213
|
+
});
|
|
214
|
+
/** Every app-shell enforcer is gathered into the ordinary FE lint and gate path. */
|
|
215
|
+
export const rules = {
|
|
216
|
+
"app-shell-frame": appShellFrame,
|
|
217
|
+
"no-shell-bottom-tabs": noShellBottomTabs,
|
|
218
|
+
"navbar-control-size": navbarControlSize,
|
|
219
|
+
"navbar-cluster": navbarCluster,
|
|
220
|
+
"no-navbar-create": noNavbarCreate,
|
|
221
|
+
};
|
|
222
|
+
defineFamilyRules(rules, "knowledge/ui/composition/app-shell.yaml");
|
|
223
|
+
/** Every rule is mandatory. */
|
|
224
|
+
export const recommended = Object.fromEntries(Object.keys(rules).map((name) => [`starci-grammar/${name}`, "error"]));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Rule } from "eslint";
|
|
2
|
+
/** The first character of a trimmed label, and its offset in the raw source text, or null when the label is empty. */
|
|
3
|
+
export declare const firstCharacter: (text: string) => {
|
|
4
|
+
char: string;
|
|
5
|
+
offset: number;
|
|
6
|
+
} | null;
|
|
7
|
+
/** True when a label's first character is a lowercase letter. */
|
|
8
|
+
export declare const startsLowercase: (text: string) => boolean;
|
|
9
|
+
/** A chip label (`StatusDot` text, `Badge`) starts with an uppercase letter. */
|
|
10
|
+
export declare const chipLabelStartsUppercase: Rule.RuleModule;
|
|
11
|
+
/** The rules this law contributes to the plugin. */
|
|
12
|
+
export declare const rules: Record<string, Rule.RuleModule>;
|
|
13
|
+
/** Every rule of this law is an error. */
|
|
14
|
+
export declare const recommended: Record<string, "error">;
|
|
@@ -0,0 +1,117 @@
|
|
|
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 chip label law (HFS R322, `FE_CHIP_LABEL_CASE`): a chip label starts with an uppercase
|
|
5
|
+
* letter. A status chip (`StatusDot` with text, a `Badge`, dot or not) is a label read at a glance beside the thing it
|
|
6
|
+
* qualifies; "running" beside "Failed" in one table reads as two vocabularies.
|
|
7
|
+
*
|
|
8
|
+
* WHAT IT READS. The children of a `StatusDot` or `Badge` element that the source states literally: JSX text, a string
|
|
9
|
+
* literal or a template literal with no expression in a `{...}`, and every branch of a conditional or logical expression
|
|
10
|
+
* made of them. The first character of the trimmed text is judged: a lowercase letter is a finding, and the fix
|
|
11
|
+
* uppercases it in place.
|
|
12
|
+
*
|
|
13
|
+
* WHAT IT LEAVES ALONE: text the source cannot show (a translation call, a variable, a template with an expression), a
|
|
14
|
+
* label that starts with a digit or a symbol, and an uncased script.
|
|
15
|
+
*/
|
|
16
|
+
/** The components whose children are a chip label. */
|
|
17
|
+
const CHIP_COMPONENTS = new Set(["StatusDot", "Badge"]);
|
|
18
|
+
/** The first character of a trimmed label, and its offset in the raw source text, or null when the label is empty. */
|
|
19
|
+
export const firstCharacter = (text) => {
|
|
20
|
+
const offset = text.search(/\S/u);
|
|
21
|
+
if (offset < 0)
|
|
22
|
+
return null;
|
|
23
|
+
const char = String.fromCodePoint(text.codePointAt(offset) ?? 0);
|
|
24
|
+
return { char, offset };
|
|
25
|
+
};
|
|
26
|
+
/** True when a label's first character is a lowercase letter. */
|
|
27
|
+
export const startsLowercase = (text) => {
|
|
28
|
+
const first = firstCharacter(text);
|
|
29
|
+
return first !== null && /^\p{Ll}$/u.test(first.char);
|
|
30
|
+
};
|
|
31
|
+
/** The literal text nodes a JSX child carries: `{ node, text, quoteOffset }`, the offset of the text inside the node's source. */
|
|
32
|
+
function* literalTexts(node) {
|
|
33
|
+
if (!node || typeof node.type !== "string")
|
|
34
|
+
return;
|
|
35
|
+
switch (node.type) {
|
|
36
|
+
case "JSXText":
|
|
37
|
+
yield { node, text: node.value, quoteOffset: 0 };
|
|
38
|
+
return;
|
|
39
|
+
case "JSXExpressionContainer":
|
|
40
|
+
yield* literalTexts(node.expression);
|
|
41
|
+
return;
|
|
42
|
+
case "Literal":
|
|
43
|
+
if (typeof node.value === "string")
|
|
44
|
+
yield { node, text: node.value, quoteOffset: 1 };
|
|
45
|
+
return;
|
|
46
|
+
case "TemplateLiteral":
|
|
47
|
+
if (node.expressions.length === 0)
|
|
48
|
+
yield { node, text: node.quasis[0]?.value.cooked ?? "", quoteOffset: 1 };
|
|
49
|
+
return;
|
|
50
|
+
case "ConditionalExpression":
|
|
51
|
+
yield* literalTexts(node.consequent);
|
|
52
|
+
yield* literalTexts(node.alternate);
|
|
53
|
+
return;
|
|
54
|
+
case "LogicalExpression":
|
|
55
|
+
yield* literalTexts(node.right);
|
|
56
|
+
return;
|
|
57
|
+
default:
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/** The element name of a JSX opening element (`Badge`, or `Grammar.Badge` as `Badge`). */
|
|
61
|
+
const elementName = (opening) => {
|
|
62
|
+
const name = opening.name;
|
|
63
|
+
if (name.type === "JSXIdentifier")
|
|
64
|
+
return name.name;
|
|
65
|
+
if (name.type === "JSXMemberExpression")
|
|
66
|
+
return name.property.name;
|
|
67
|
+
return null;
|
|
68
|
+
};
|
|
69
|
+
/** The first non-blank child of an element: the one that starts the visible label. */
|
|
70
|
+
const leadingChild = (children) => children.find((child) => child.type !== "JSXText" || child.value.trim() !== "") ?? null;
|
|
71
|
+
/** A chip label (`StatusDot` text, `Badge`) starts with an uppercase letter. */
|
|
72
|
+
export const chipLabelStartsUppercase = defineRule({
|
|
73
|
+
meta: {
|
|
74
|
+
type: "problem",
|
|
75
|
+
fixable: "code",
|
|
76
|
+
docs: { description: "R322: the label of a StatusDot or Badge chip starts with an uppercase letter." },
|
|
77
|
+
schema: [],
|
|
78
|
+
messages: {
|
|
79
|
+
lowercase: "The {{component}} label `{{text}}` starts with a lowercase letter. A chip label is read at a glance beside the thing it qualifies, and every chip of the app starts uppercase, so one table never mixes `running` with `Failed`. Write `{{fixed}}`.",
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
create(context) {
|
|
83
|
+
if (!isProductSource(context))
|
|
84
|
+
return {};
|
|
85
|
+
const source = context.sourceCode;
|
|
86
|
+
return {
|
|
87
|
+
JSXElement(element) {
|
|
88
|
+
const component = elementName(element.openingElement);
|
|
89
|
+
if (component === null || !CHIP_COMPONENTS.has(component))
|
|
90
|
+
return;
|
|
91
|
+
const child = leadingChild(element.children);
|
|
92
|
+
for (const { node, text, quoteOffset } of literalTexts(child)) {
|
|
93
|
+
const first = firstCharacter(text);
|
|
94
|
+
if (!startsLowercase(text) || first === null)
|
|
95
|
+
continue;
|
|
96
|
+
const trimmed = text.trim();
|
|
97
|
+
const fixed = first.char.toLocaleUpperCase() + trimmed.slice(first.char.length);
|
|
98
|
+
const raw = source.getText(node);
|
|
99
|
+
const at = node.range[0] + quoteOffset + raw.slice(quoteOffset).indexOf(first.char);
|
|
100
|
+
context.report({
|
|
101
|
+
node,
|
|
102
|
+
messageId: "lowercase",
|
|
103
|
+
data: { component, text: trimmed, fixed },
|
|
104
|
+
fix: (fixer) => fixer.replaceTextRange([at, at + first.char.length], first.char.toLocaleUpperCase()),
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
/** The rules this law contributes to the plugin. */
|
|
112
|
+
export const rules = {
|
|
113
|
+
"chip-label-starts-uppercase": chipLabelStartsUppercase,
|
|
114
|
+
};
|
|
115
|
+
defineFamilyRules(rules, "knowledge/hfs/rules.yaml#R322");
|
|
116
|
+
/** Every rule of this law is an error. */
|
|
117
|
+
export const recommended = Object.fromEntries(Object.keys(rules).map((name) => [`starci-grammar/${name}`, "error"]));
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** StarCi per-slot status composition, governed by FE-RULE-OWNERSHIP. */
|
|
2
|
+
import type { Rule } from "eslint";
|
|
3
|
+
/** A block's pure half never branches on a data status itself. */
|
|
4
|
+
export declare const slotStatusThroughSlotView: Rule.RuleModule;
|
|
5
|
+
/** The family status recipe retains its published rule ID. */
|
|
6
|
+
export declare const rules: Record<string, Rule.RuleModule>;
|
|
7
|
+
/** Every family composition rule is mandatory. */
|
|
8
|
+
export declare const recommended: Record<string, "error">;
|
package/dist/drawing.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { pureHalf } from "@starci/eslint-canon-fe/lib/drawing-scope.mjs";
|
|
2
|
+
import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
|
|
3
|
+
// -- DRAWING-4 ----------------------------------------------------------------------------------
|
|
4
|
+
/** Flags that are a slot's data status. */
|
|
5
|
+
const STATUS_FLAG = /^(?:isLoading|isError|isForbidden|isPending|isValidating|isEmpty)$/;
|
|
6
|
+
/** The name a test expression reads, if it is a status flag. */
|
|
7
|
+
const statusFlagOf = (node) => {
|
|
8
|
+
if (!node)
|
|
9
|
+
return null;
|
|
10
|
+
if (node.type === "UnaryExpression")
|
|
11
|
+
return statusFlagOf(node.argument);
|
|
12
|
+
if (node.type === "ChainExpression")
|
|
13
|
+
return statusFlagOf(node.expression);
|
|
14
|
+
if (node.type === "Identifier" && STATUS_FLAG.test(node.name))
|
|
15
|
+
return node.name;
|
|
16
|
+
if (node.type === "MemberExpression" && node.property?.type === "Identifier" && STATUS_FLAG.test(node.property.name)) {
|
|
17
|
+
return node.property.name;
|
|
18
|
+
}
|
|
19
|
+
if (node.type === "LogicalExpression" || node.type === "BinaryExpression")
|
|
20
|
+
return statusFlagOf(node.left) ?? statusFlagOf(node.right);
|
|
21
|
+
return null;
|
|
22
|
+
};
|
|
23
|
+
/** A block's pure half never branches on a data status itself. */
|
|
24
|
+
export const slotStatusThroughSlotView = defineRule({
|
|
25
|
+
meta: {
|
|
26
|
+
type: "problem",
|
|
27
|
+
docs: { description: "A block's pure half renders data status through `SlotView`, never its own branch." },
|
|
28
|
+
schema: [],
|
|
29
|
+
messages: {
|
|
30
|
+
branch: "This branches on `{{flag}}` by hand. Every slot renders its status through `SlotView`, the one recipe: a second branch drifts from it and becomes one more variant somebody draws.",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
create(context) {
|
|
34
|
+
if (pureHalf(context) !== "blocks")
|
|
35
|
+
return {};
|
|
36
|
+
const check = (node, test) => {
|
|
37
|
+
const flag = statusFlagOf(test);
|
|
38
|
+
if (flag)
|
|
39
|
+
context.report({ node, messageId: "branch", data: { flag } });
|
|
40
|
+
};
|
|
41
|
+
return {
|
|
42
|
+
ConditionalExpression(node) {
|
|
43
|
+
check(node, node.test);
|
|
44
|
+
},
|
|
45
|
+
IfStatement(node) {
|
|
46
|
+
check(node, node.test);
|
|
47
|
+
},
|
|
48
|
+
LogicalExpression(node) {
|
|
49
|
+
if (node.operator === "&&" && node.parent?.type === "JSXExpressionContainer")
|
|
50
|
+
check(node, node.left);
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
/** The family status recipe retains its published rule ID. */
|
|
56
|
+
export const rules = { "slot-status-through-slotview": slotStatusThroughSlotView };
|
|
57
|
+
defineFamilyRules(rules, "knowledge/grammars/core/playbook.yaml#state-recipes");
|
|
58
|
+
/** Every family composition rule is mandatory. */
|
|
59
|
+
export const recommended = Object.fromEntries(Object.keys(rules).map((name) => [`starci-grammar/${name}`, "error"]));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Rule } from "eslint";
|
|
2
|
+
/**
|
|
3
|
+
* The intrinsic elements of page structure and text, each with the grammar components that render it.
|
|
4
|
+
* Read against packages/grammar/src (`export const <Component>`); `grammar-boundary.spec.ts` fails when one is not exported.
|
|
5
|
+
*/
|
|
6
|
+
export declare const GRAMMAR_OWNERS: Readonly<Record<string, string>>;
|
|
7
|
+
/** No raw structural or text element in app source or in a package that composes the grammar. */
|
|
8
|
+
export declare const noRawStructuralElement: Rule.RuleModule;
|
|
9
|
+
/** The rules this law contributes to the plugin. */
|
|
10
|
+
export declare const rules: Record<string, Rule.RuleModule>;
|
|
11
|
+
/** Every rule is an error. */
|
|
12
|
+
export declare const recommended: Record<string, "error">;
|