From c166cec66e1242a1387bdc89620923ab235e8615 Mon Sep 17 00:00:00 2001 From: HerbertJulio Date: Mon, 6 Jul 2026 14:21:16 -0300 Subject: [PATCH] [NO-ISSUE] docs: add webkit guardrails coverage guide A single reference for what webkit enforces and where: the lint coverage (internal contributor + consumer toolkit), the spec contract + rules + hooks + pipeline for creating new components, editing/migrating existing ones, and using webkit in other projects via the adoption toolkit (catalog + FORCE + GUIDE). --- docs/webkit-guardrails.md | 109 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 docs/webkit-guardrails.md diff --git a/docs/webkit-guardrails.md b/docs/webkit-guardrails.md new file mode 100644 index 000000000..85b3ee7ed --- /dev/null +++ b/docs/webkit-guardrails.md @@ -0,0 +1,109 @@ +# Webkit guardrails — what we cover, and where + +Webkit protects **two frontiers** with the same principle — *correct by construction*: + +1. **Building** components inside the design system (internal / contributor). +2. **Consuming** webkit correctly in other projects (the adoption toolkit). + +In both, the developer (and the AI) fall into the correct path without memorising rules — a rule is only useful if something *enforces* it. This doc maps exactly what is covered, by which mechanism, and where the boundaries are. + +--- + +## 1. Lint coverage + +### 1a. Internal — contributor editing webkit + +Runs at CI and, for component files, via a Claude Code authoring hook. + +- **`eslint.config.js`** (flat, repo root; `packages/webkit/eslint.config.js` re-exports it): Vue correctness (`vue/*`), accessibility (`vuejs-accessibility/*`), `@typescript-eslint/no-explicit-any`, import sorting (`simple-import-sort`), `no-console` / `no-debugger`, `prefer-const`. +- **`.stylelintrc.json`** (repo root): kebab-case class names, no ID selectors, alphabetised properties, no duplicates (extends `stylelint-config-standard-scss` + `-recommended-vue`). +- **`.claude/hooks/validate-tokens.mjs`** (PreToolUse on `packages/webkit/src/components/**`, excludes `wip/`): blocks **newly introduced** hex/rgb/hsl colors, Tailwind palette classes, raw text sizes, raw typography (`leading-*`, `tracking-*`, `font-*`), PrimeVue color utilities, `class` in `defineProps`, `any`, and `@ts-ignore`. + +### 1b. Consumer — using webkit in another project (the adoption toolkit) + +Everything reads the **version-locked `catalog.json`** shipped inside the installed webkit (resolved from `@aziontech/webkit` or `@aziontech/webkit.dev`), so what's enforced always matches the installed version. If no catalog resolves, the rules disable themselves **and log a one-line warning** — never silently. + +**`@aziontech/eslint-plugin-webkit`** — presets `recommended` / `strict` / `performance`: + +| Rule | Blocks | Autofix | +|---|---|---| +| `valid-import-path` | An import subpath that isn't a published export of the installed version | ✅ when exactly one close candidate exists (else suggestions) | +| `no-deep-internal-import` | `@aziontech/webkit/src/**` or paths deeper than a published entry | ✅ to the nearest published entry | +| `no-barrel-import` | Barrel import / `export … from` / dynamic `import()` of the bare package | Suggestion only, and only when every split subpath is a real export | +| `no-whole-icon-set-import` | A default/namespace binding of the `@aziontech/icons` **font** (use a side-effect import + CSS classes) | — | +| `no-hardcoded-color` | Hardcoded color / raw palette / raw typography in class & style strings (short hex in anchors/ids is not flagged) | — | +| `prefer-tree-shakeable-root` | Importing a compound entry when only the root is used → prefer `-root` | Suggestion only (a `warn` preference) | + +**`@aziontech/stylelint-config-webkit`** — token discipline in CSS / SCSS / `.vue` `