@polymorphism-tech/morph-spec 10.10.0 → 10.11.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/README.md +2 -2
- package/claude-plugin.json +1 -1
- package/docs/CHEATSHEET.md +1 -1
- package/docs/QUICKSTART.md +1 -1
- package/framework/docs/CLI.md +2 -2
- package/framework/hooks/shared/build-check.js +35 -2
- package/framework/mcp/registry.json +30 -42
- package/framework/rules/nextjs-standards.md +2 -2
- package/framework/rules/ui-design.md +1 -1
- package/framework/skills/core/create-umbraco-lp/SKILL.md +1 -1
- package/framework/skills/core/migrate-lp-to-umbraco/SKILL.md +1 -1
- package/framework/skills/core/morph-apply/SKILL.md +2 -1
- package/framework/skills/core/morph-plan/SKILL.md +1 -1
- package/framework/skills/core/morph-uiux/SKILL.md +5 -3
- package/framework/standards/STANDARDS.json +3 -2
- package/framework/standards/frontend/nextjs/components.md +36 -1
- package/framework/standards/frontend/nextjs/lint.md +23 -1
- package/framework/standards/frontend/nextjs/nextjs-patterns.md +1 -1
- package/framework/templates/docs/ui-mockups.md +5 -1
- package/package.json +1 -1
- package/src/commands/mcp/mcp-setup.js +8 -103
- package/src/commands/project/init.js +1 -21
- package/src/commands/project/update.js +20 -0
- package/src/lib/installers/effects.js +6 -0
- package/src/lib/installers/mcp-installer.js +4 -295
- package/src/lib/installers/stack-tooling.js +53 -0
- package/src/lib/risk-detector.js +8 -0
- package/src/lib/specs/screen-checklist.js +57 -8
- package/src/lib/stack/stack-scan.js +13 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
> Spec-driven development framework for multi-stack projects. Turns feature requests into implementation-ready code through structured, AI-orchestrated phases.
|
|
4
4
|
|
|
5
5
|
**Package:** `@polymorphism-tech/morph-spec`
|
|
6
|
-
**Version:** 10.
|
|
6
|
+
**Version:** 10.11.0
|
|
7
7
|
**Requires:** Node.js 22+, Claude Code
|
|
8
8
|
|
|
9
9
|
---
|
|
@@ -376,4 +376,4 @@ Code generated by morph-spec (contracts, templates, implementation output) belon
|
|
|
376
376
|
|
|
377
377
|
---
|
|
378
378
|
|
|
379
|
-
*morph-spec v10.
|
|
379
|
+
*morph-spec v10.11.0 by [Polymorphism Tech](https://polymorphism.tech)*
|
package/claude-plugin.json
CHANGED
package/docs/CHEATSHEET.md
CHANGED
package/docs/QUICKSTART.md
CHANGED
package/framework/docs/CLI.md
CHANGED
|
@@ -44,7 +44,7 @@ Um stamp de `verification` com status `fail` (último `morph-spec verify` vermel
|
|
|
44
44
|
|
|
45
45
|
**Prova de mídia:** do MESMO relatório e pelo MESMO leitor, o `gate-check` grava `signals.mediaClaims = {section, featureGeneratesMedia}`. `featureGeneratesMedia` é determinístico do disco — o `plan.md` cita `ai-agents-modalities-image-gen`, `ai-agents-media-video` ou `ai-agents-media-pipeline` — pelo id de STANDARDS.json ou pelo caminho, com ou sem `framework/`/`standards/` na frente, porque uma grafia não prevista desarmaria o guardrail sem uma linha de erro (`featureGeneratesMedia`, em `src/lib/plan/media.js`, é onde essa normalização mora e é testada; o `plan-check` recusa o plano que fala em mídia gerada sem a citação). Nessa condição, relatório **sem** a seção `## Mídia gerada` **pausa o Gate 3**: as quatro afirmações de mídia (custo, revisão humana, marcação, hot path não bloqueado) não foram provadas (`framework/evals/review-checklist.md`, "Feature que gera mídia").
|
|
46
46
|
|
|
47
|
-
**Checklist de tela:** na `uiux` e no `review`, o `gate-check` grava `signals.screenChecklist` lido do `1-design/mockups.md` (`mockups`, `legacy`, `screens`, `problems`). Na **uiux**, checklist incompleto **pausa** nomeando a tela e o item, e um mockup sem nenhuma `## Tela:` é o problema "nenhuma tela declarada". Com o checklist completo, cada tela ainda deve o **protótipo** (`prototypes`, só na uiux): a linha `**Protótipo:** 1-design/prototipos/<tela>.html` dentro da `## Tela:`, o HTML e os prints `<tela>-1280.png` e `<tela>-390.png` ao lado dele, e para cada estado que o checklist diz que se aplica (`vazio` e `carregando` pelo item "Estados", `erro` pelo item "Erro"; "não se aplica" dispensa) o `data-estado="<estado>"` no HTML (o seletor de estado) e o print `<tela>-<estado>-390.png`; faltando um, **pausa** nomeando a tela e o arquivo ("protótipo incompleto"), pelo mesmo predicado. No **review**, o que se cobra é o item **devido** — decidido, nem "não se aplica" nem a superfície (`uncovered`): cada um exige uma linha na seção `## Checklist de tela` do `verifier.md`, e a linha que o verificador marca como não verificável conta. Com item devido, relatório sem a seção ou com linha faltando (`section`, `uncovered`) **pausa** o Gate 3 (`evals/review-checklist.md`, "Contrato de tela"); tela toda "não se aplica" não deve nada e não pausa. **Mockup legado** — telas no formato antigo (`## S001: …`) e nenhuma `## Tela:`, o que o template anterior gerava — é **isento nas duas fases**, com a isenção à vista: o sinal grava `exempt: "checklist dispensado: mockup no formato antigo"` e a mesma razão aparece em "risk signals present". Mockup ausente não pausa. `screenChecklist` **não** é sobrescrevível por `--signals`.
|
|
47
|
+
**Checklist de tela:** na `uiux` e no `review`, o `gate-check` grava `signals.screenChecklist` lido do `1-design/mockups.md` (`mockups`, `legacy`, `screens`, `problems`). Na **uiux**, checklist incompleto **pausa** nomeando a tela e o item, e um mockup sem nenhuma `## Tela:` é o problema "nenhuma tela declarada". Com o checklist completo, cada tela deve a **origem dos componentes** (`components`, só na uiux): a tabela `### Componentes` com `Componente | Origem | Fonte ou motivo`, onde a origem é `projeto` (com o caminho), `registry` (com o `@registry/item`) ou `novo` (com o que foi buscado e por que não serve); tela sem a tabela, origem fora dessas três ou fonte vazia **pausa** ("origem de componente sem resposta"). Depois, cada tela ainda deve o **protótipo** (`prototypes`, só na uiux): a linha `**Protótipo:** 1-design/prototipos/<tela>.html` dentro da `## Tela:`, o HTML e os prints `<tela>-1280.png` e `<tela>-390.png` ao lado dele, e para cada estado que o checklist diz que se aplica (`vazio` e `carregando` pelo item "Estados", `erro` pelo item "Erro"; "não se aplica" dispensa) o `data-estado="<estado>"` no HTML (o seletor de estado) e o print `<tela>-<estado>-390.png`; faltando um, **pausa** nomeando a tela e o arquivo ("protótipo incompleto"), pelo mesmo predicado. No **review**, o que se cobra é o item **devido** — decidido, nem "não se aplica" nem a superfície (`uncovered`): cada um exige uma linha na seção `## Checklist de tela` do `verifier.md`, e a linha que o verificador marca como não verificável conta. Com item devido, relatório sem a seção ou com linha faltando (`section`, `uncovered`) **pausa** o Gate 3 (`evals/review-checklist.md`, "Contrato de tela"); tela toda "não se aplica" não deve nada e não pausa. **Mockup legado** — telas no formato antigo (`## S001: …`) e nenhuma `## Tela:`, o que o template anterior gerava — é **isento nas duas fases**, com a isenção à vista: o sinal grava `exempt: "checklist dispensado: mockup no formato antigo"` e a mesma razão aparece em "risk signals present". Mockup ausente não pausa. `screenChecklist` **não** é sobrescrevível por `--signals`.
|
|
48
48
|
|
|
49
49
|
**Por quê.** Fora do review a regra não vale (pausar o Gate 1/2 numa máquina sem docker travaria planejamento legítimo). Feature que não pina standard de mídia é **isenta automaticamente** — a regra não pede cerimônia de quem não gera mídia. `mediaClaims` **não** é sobrescrevível por `--signals`, pela mesma razão anti-spoof dos demais sinais de disco.
|
|
50
50
|
|
|
@@ -798,7 +798,7 @@ Falhas do `--show` saem 1: id inexistente (`Standard "<id>" não existe.` com at
|
|
|
798
798
|
|
|
799
799
|
### update
|
|
800
800
|
|
|
801
|
-
**`morph-spec update [--templates] [--standards] [--dry-run] [--force]`** — reinstala os payloads do framework no projeto (standards, hooks, schemas, evals, `.claude/{commands,rules,skills,agents}`, `.claude/CLAUDE.md`, `.gitignore`/`.gitattributes`, statusline global).
|
|
801
|
+
**`morph-spec update [--templates] [--standards] [--dry-run] [--force]`** — reinstala os payloads do framework no projeto (standards, hooks, schemas, evals, `.claude/{commands,rules,skills,agents}`, `.claude/CLAUDE.md`, `.gitignore`/`.gitattributes`, statusline global). Também traz o que os MCPs do stack precisam, sem passo manual: o servidor de instalação automática que falta entra no `.mcp.json`, a skill que o acompanha é reinstalada (o `update` apaga `.claude/skills/` antes) e os registries do shadcn que faltam entram no `components.json` (o que o projeto já declarou não é sobrescrito). Skill que não instalou (sem rede) vira aviso no fim, nunca falha do `update`.
|
|
802
802
|
|
|
803
803
|
**`--dry-run` prevê sem tocar em nada.** Previsão e execução são o **mesmo percurso**, com os **mesmos filtros** e o **mesmo coletor de efeitos**: em modo normal cada verbo executa *e* registra, em dry apenas registra.
|
|
804
804
|
|
|
@@ -5,6 +5,19 @@ import { join } from 'path';
|
|
|
5
5
|
const DOTNET_BUILD_CMD = 'dotnet build --no-restore --nologo -v q';
|
|
6
6
|
const TSC_BUILD_CMD = 'npx tsc --noEmit';
|
|
7
7
|
const ESLINT_CONFIGS = ['eslint.config.mjs', 'eslint.config.js', 'eslint.config.cjs'];
|
|
8
|
+
const LINT_BATCH_CHARS = 6000;
|
|
9
|
+
|
|
10
|
+
/** HTML que o projeto tem como componente do shadcn: cru, só dentro de `components/ui/`. */
|
|
11
|
+
export const RAW_ELEMENTS = ['button', 'input', 'textarea', 'select', 'table', 'dialog'];
|
|
12
|
+
const RAW_ELEMENTS_RULE = ` --rule "react/forbid-elements: [error, {forbid: [${RAW_ELEMENTS.join(', ')}]}]"`;
|
|
13
|
+
const SHADCN_UI_DIR_RE = /(^|[\\/])components[\\/]ui[\\/]/;
|
|
14
|
+
|
|
15
|
+
// A regra entra pela linha de comando: vale no projeto cujo `eslint.config` ainda não a declara.
|
|
16
|
+
// O plugin `react` vem do eslint-config-next; sem ele o eslint recusaria a regra.
|
|
17
|
+
function cobraElementoCru(frontendDir) {
|
|
18
|
+
return existsSync(join(frontendDir, 'components.json'))
|
|
19
|
+
&& existsSync(join(frontendDir, 'node_modules', 'eslint-config-next'));
|
|
20
|
+
}
|
|
8
21
|
|
|
9
22
|
export function isDotnetStack(s) {
|
|
10
23
|
return s.includes('dotnet') || s.includes('aspnet');
|
|
@@ -41,8 +54,28 @@ export function getBuildSteps(stack, { cwd, frontendPath, backendPath, backendTa
|
|
|
41
54
|
ESLINT_CONFIGS.some((name) => existsSync(join(frontendDir, name))) &&
|
|
42
55
|
existsSync(join(frontendDir, 'node_modules', 'eslint'))
|
|
43
56
|
) {
|
|
44
|
-
|
|
45
|
-
|
|
57
|
+
// cmd.exe caps a command line at 8191 chars: a wide diff is linted in batches.
|
|
58
|
+
const lint = (files, rule) => {
|
|
59
|
+
let batch = [];
|
|
60
|
+
let size = 0;
|
|
61
|
+
const flush = () => {
|
|
62
|
+
if (batch.length > 0) steps.push({ command: `npx eslint --quiet --no-warn-ignored${rule} ${batch.join(' ')}`, cwd: frontendDir });
|
|
63
|
+
batch = [];
|
|
64
|
+
size = 0;
|
|
65
|
+
};
|
|
66
|
+
for (const file of files.map((f) => JSON.stringify(f))) {
|
|
67
|
+
if (size + file.length + 1 > LINT_BATCH_CHARS) flush();
|
|
68
|
+
batch.push(file);
|
|
69
|
+
size += file.length + 1;
|
|
70
|
+
}
|
|
71
|
+
flush();
|
|
72
|
+
};
|
|
73
|
+
if (cobraElementoCru(frontendDir)) {
|
|
74
|
+
lint(lintFiles.filter((f) => !SHADCN_UI_DIR_RE.test(f)), RAW_ELEMENTS_RULE);
|
|
75
|
+
lint(lintFiles.filter((f) => SHADCN_UI_DIR_RE.test(f)), '');
|
|
76
|
+
} else {
|
|
77
|
+
lint(lintFiles, '');
|
|
78
|
+
}
|
|
46
79
|
}
|
|
47
80
|
}
|
|
48
81
|
|
|
@@ -114,57 +114,45 @@
|
|
|
114
114
|
"setupGuide": "Run: claude mcp add --transport http asaas https://docs.asaas.com/mcp"
|
|
115
115
|
}
|
|
116
116
|
},
|
|
117
|
-
"
|
|
118
|
-
"phases": ["uiux"],
|
|
119
|
-
"tools": ["
|
|
120
|
-
"
|
|
121
|
-
"
|
|
122
|
-
"
|
|
117
|
+
"shadcn": {
|
|
118
|
+
"phases": ["uiux", "implement"],
|
|
119
|
+
"tools": ["get_project_registries", "list_items_in_registries", "search_items_in_registries", "view_items_in_registries", "get_item_examples_from_registries", "get_add_command_for_items", "get_audit_checklist"],
|
|
120
|
+
"serverNames": ["shadcn"],
|
|
121
|
+
"detection": "mcpServers includes shadcn",
|
|
122
|
+
"fallback": "The shadcn CLI answers the same questions: `npx shadcn@latest search @shadcn <@registry> -q \"<termo>\"`, `view <@registry>/<item>`, `docs <componente>`, `add <@registry>/<item> --dry-run`",
|
|
123
|
+
"usage": "Catalog of ready-made components and blocks across every registry declared in components.json. Search it BEFORE writing a component: search_items_in_registries (pass `registries` with @shadcn: an unnamed search covers only the ones declared in components.json), then view_items_in_registries or get_item_examples_from_registries, then get_add_command_for_items and run the add command. Read-only server; installing is the CLI. The registries a project may use are listed in the standard frontend-nextjs-components",
|
|
123
124
|
"healthCheck": {
|
|
124
|
-
"toolPattern": "
|
|
125
|
-
"testCall": "Call
|
|
125
|
+
"toolPattern": "shadcn",
|
|
126
|
+
"testCall": "Call get_project_registries",
|
|
126
127
|
"testParams": {},
|
|
127
|
-
"successIndicator": "
|
|
128
|
-
"failureHint": "
|
|
128
|
+
"successIndicator": "Lists the registries configured in components.json",
|
|
129
|
+
"failureHint": "shadcn MCP not responding or no components.json. Run `npx shadcn@latest init` in the frontend folder, then restart Claude Code and check /mcp."
|
|
129
130
|
},
|
|
130
131
|
"install": {
|
|
131
|
-
"
|
|
132
|
-
"autoInstall": false,
|
|
132
|
+
"autoInstall": true,
|
|
133
133
|
"transport": "stdio",
|
|
134
134
|
"config": {
|
|
135
135
|
"type": "stdio",
|
|
136
|
-
"command": "
|
|
137
|
-
"args": ["
|
|
136
|
+
"command": "cmd",
|
|
137
|
+
"args": ["/c", "npx", "-y", "shadcn@latest", "mcp"]
|
|
138
138
|
},
|
|
139
|
-
"credentials": [
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
"
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
"checkCommand": "gcloud --version",
|
|
151
|
-
"installUrl": "https://cloud.google.com/sdk/docs/install"
|
|
152
|
-
}
|
|
153
|
-
],
|
|
154
|
-
"requiredCredentials": ["gcloud-adc"],
|
|
155
|
-
"setupFn": "setupStitch",
|
|
156
|
-
"testCall": "initialize",
|
|
157
|
-
"successIndicator": "protocolVersion",
|
|
158
|
-
"failureHint": "Run: gcloud auth application-default login && gcloud services enable stitch.googleapis.com",
|
|
159
|
-
"stackRelevance": ["nextjs", "nextjs-neon", "vite"],
|
|
160
|
-
"warnings": ["Requires gcloud CLI with application-default credentials. Run 'gcloud auth application-default login' before setup.", "Add .claude/stitch-proxy.cjs to .gitignore (contains your GCP project ID)."],
|
|
161
|
-
"setupGuide": "Run: morph-spec mcp setup stitch (generates OAuth proxy script)"
|
|
139
|
+
"credentials": [],
|
|
140
|
+
"prerequisites": [],
|
|
141
|
+
"stackRelevance": ["next", "nextjs", "nextjs-neon", "react", "vite"],
|
|
142
|
+
"warnings": ["The server reads components.json from the directory Claude Code starts in. In a monorepo where the frontend is a subfolder, the CLI fallback run from that folder is the reliable path."],
|
|
143
|
+
"setupGuide": null
|
|
144
|
+
},
|
|
145
|
+
"projectRegistries": {
|
|
146
|
+
"@reui": "https://reui.io/r/{style}/{name}.json",
|
|
147
|
+
"@magicui": "https://magicui.design/r/{name}",
|
|
148
|
+
"@aceternity": "https://ui.aceternity.com/registry/{name}.json",
|
|
149
|
+
"@react-bits": "https://reactbits.dev/r/{name}.json"
|
|
162
150
|
},
|
|
163
151
|
"companionSkills": {
|
|
164
|
-
"repo": "
|
|
165
|
-
"installCommand": "npx skills add
|
|
166
|
-
"skills": ["
|
|
167
|
-
"description": "Official
|
|
152
|
+
"repo": "shadcn-ui/ui",
|
|
153
|
+
"installCommand": "npx -y skills add shadcn/ui --skill shadcn -a claude-code -y --copy",
|
|
154
|
+
"skills": ["shadcn"],
|
|
155
|
+
"description": "Official shadcn skill: injects the project state (`shadcn info --json`) and makes the agent consult the registries before generating a component"
|
|
168
156
|
}
|
|
169
157
|
},
|
|
170
158
|
"morph-assets": {
|
|
@@ -312,7 +300,7 @@
|
|
|
312
300
|
"_phaseMatrixNote": "Keys must be the v5 phases from framework/phases.json. The v4 keys 'design' and 'tasks' both collapsed into 'plan'; 'review' was absent entirely, so a project in review resolved to undefined. Stack-scoped MCPs (asaas, neon, microsoft-learn) stay out of this matrix on purpose — only universal ones are listed.",
|
|
313
301
|
"phaseMatrix": {
|
|
314
302
|
"plan": ["context7", "graphify"],
|
|
315
|
-
"uiux": ["playwright", "context7", "
|
|
303
|
+
"uiux": ["playwright", "context7", "morph-assets"],
|
|
316
304
|
"implement": ["context7", "playwright", "vercel", "morph-assets", "graphify"],
|
|
317
305
|
"review": ["playwright", "context7", "graphify"]
|
|
318
306
|
}
|
|
@@ -10,11 +10,11 @@ stacks:
|
|
|
10
10
|
|
|
11
11
|
**Ponto de vista:** Next.js App Router idiomático — Server Component por padrão, Client Component só com interação real; Tailwind + shadcn + Motion; tipos por Zod. Tipo local redeclarado em cada arquivo é o defeito mais comum aqui: confira a tabela `## Reuso` do plano antes de criar um tipo.
|
|
12
12
|
|
|
13
|
-
- **frontend-nextjs-lint** (`frontend/nextjs/lint.md`) — O lint cobra o mecânico: `framer-motion`, Zustand/Redux, driver de banco, Form legado, deep import de feature, fronteiras `components`/`features`/`app`/`hooks`, fetch em `useEffect`, `'use client'` no layout raiz, `export default` fora de rota, `any`. O `verify` roda o eslint nos arquivos da feature quando há `eslint.config.*`; sem `eslint.config.mjs`: `morph-spec standards --show frontend-nextjs-lint#files`. Regra mecânica nova vira linha nele, nunca prosa.
|
|
13
|
+
- **frontend-nextjs-lint** (`frontend/nextjs/lint.md`) — O lint cobra o mecânico: `framer-motion`, Zustand/Redux, driver de banco, Form legado, deep import de feature, fronteiras `components`/`features`/`app`/`hooks`, fetch em `useEffect`, elemento cru (`<button>`, `<input>`, `<select>`, `<textarea>`, `<table>`, `<dialog>`) fora de `components/ui/`, `'use client'` no layout raiz, `export default` fora de rota, `any`. O `verify` roda o eslint nos arquivos da feature quando há `eslint.config.*`; sem `eslint.config.mjs`: `morph-spec standards --show frontend-nextjs-lint#files`. Regra mecânica nova vira linha nele, nunca prosa.
|
|
14
14
|
- **frontend-nextjs-naming-conventions** (`frontend/nextjs/naming-conventions.md`) — Arquivo SEMPRE kebab-case (`user-card.tsx`); componente PascalCase. Zod em `.schemas.ts`, tipos em `.types.ts` via `z.infer`. Nunca misture casos na mesma categoria.
|
|
15
15
|
- **frontend-nextjs-project-structure** (`frontend/nextjs/project-structure.md`) — `src/app/` só roteia; a lógica da tela mora em `src/features/{f}/` (`components/`, `hooks/`, `types/`, `index.ts` como API pública). NUNCA uma feature importa outra (extraia para `components/` ou `lib/`); `components/ui/` é shadcn e não se edita.
|
|
16
16
|
- **frontend-nextjs-app-router** (`frontend/nextjs/app-router.md`) — Server Component por padrão; `'use client'` só para interação, browser API ou TanStack Query. `loading.tsx`/`error.tsx` ao lado do `page.tsx`. Server Component chama o .NET com `BACKEND_API_PREFIX`; evite `route.ts`.
|
|
17
|
-
- **frontend-nextjs-components** (`frontend/nextjs/components.md`) — `components/ui/` é saída do shadcn CLI (nunca editar; envolva em `components/`); `components/` sem regra de negócio; `features/*/components/` conhece o domínio e entrega props tipadas, nunca a resposta crua da API.
|
|
17
|
+
- **frontend-nextjs-components** (`frontend/nextjs/components.md`) — Componente se busca antes de se escrever: no projeto (`npx shadcn@latest info --json`), depois nos registries (`npx shadcn@latest search @shadcn @reui -q "<termo>"` para app, `search @shadcn @magicui @aceternity @react-bits -q …` para landing, ou o MCP `shadcn`; sem nomear, o `@shadcn` embutido fica fora da busca), instale com `add @registry/item` e leia o que entrou; escrever é o último passo. A base é a do `style` do projeto (`asChild` no Radix, `render` no Base UI); projeto novo nasce com `init -b radix`. `components/ui/` é saída do shadcn CLI (nunca editar; envolva em `components/`); `components/` sem regra de negócio; `features/*/components/` conhece o domínio e entrega props tipadas, nunca a resposta crua da API.
|
|
18
18
|
- **frontend-nextjs-data-fetching** (`frontend/nextjs/data-fetching.md`) — Server Component com `BACKEND_API_PREFIX`; Client Component só pelo proxy same-origin com `PROXY_API_PREFIX`. TanStack Query 5 com key factory por feature e `invalidateQueries({ queryKey })`; toda resposta passa por Zod. PROIBIDO paginar/filtrar a coleção inteira no browser.
|
|
19
19
|
- **frontend-nextjs-forms** (`frontend/nextjs/forms.md`) — react-hook-form + Zod (`zodResolver`) + Field do shadcn via `Controller`; tipo por `z.infer`; nunca `useState` por campo. Submit por `useMutation`, erro em `root`. Edição reusa o schema de criação (`.partial()`). Zod 4: `z.email()`.
|
|
20
20
|
- **frontend-nextjs-state-management** (`frontend/nextjs/state-management.md`) — Estado de servidor no TanStack Query, nunca copiado para `useState`. Página, ordenação, filtros e aba ativa na URL (`searchParams`). Context só para tema, usuário ou locale.
|
|
@@ -21,7 +21,7 @@ Vale para o desenho na fase uiux e para todo código de UI na implementação.
|
|
|
21
21
|
- **Movimento com intenção:** a ferramenta mais leve que entrega o efeito (CSS transition/`@keyframes` → animação por scroll em CSS → Motion → GSAP com ScrollTrigger). 60 fps, só `transform` e `opacity`. `prefers-reduced-motion` tem versão estática digna, composta, não só a animação desligada.
|
|
22
22
|
- **Acabamento:** camadas, luz (gradiente radial, trama discreta), vidro com moderação, sombra com a cor do tema, ritmo tipográfico (escala modular, tracking negativo no display), microinteração em foco, hover e envio.
|
|
23
23
|
- **Tela de dados:** lista pagina, ordena e filtra no servidor e tem os três estados (vazio, carregando, erro). Uma ação primária por tela; erro diz o que fazer a seguir; conteúdo gerado por IA marcado como tal.
|
|
24
|
-
- **Reuso:** componente se busca antes de se escrever
|
|
24
|
+
- **Reuso:** componente se busca antes de se escrever: `.morph/context/design-system.md` e o código do projeto, depois o catálogo (standard `frontend-nextjs-components`, seção "Catalog First": `npx shadcn@latest search @shadcn …` ou o MCP `shadcn`). A origem de cada um (`projeto`, `registry`, `novo` com o motivo) vai na tabela `### Componentes` do `mockups.md`, que o gate uiux cobra. O bloco pronto é esqueleto: tokens e composição são da direção escolhida. Token novo precisa de justificativa.
|
|
25
25
|
- **Proibido:** número ou dado inventado em tela real, cópia de marca de terceiros, efeito que quebra contraste AA.
|
|
26
26
|
|
|
27
27
|
Standards: `frontend-design-system-art-direction`, `frontend-design-system-premium-finish`, `frontend-design-system-animations`, `frontend-nextjs-motion-patterns`, `frontend-nextjs-testing`. Por superfície (`marketing-site`, `admin-app`, `brand-moment`): `.claude/skills/morph-uiux/surfaces.json`. Texto inteiro: `morph-spec standards --show <id>`.
|
|
@@ -4,7 +4,7 @@ description: Guia a criação de uma landing page nova ponta-a-ponta a partir do
|
|
|
4
4
|
version: core
|
|
5
5
|
when_to_use: Use quando for iniciar um novo projeto de LP com o template Umbraco genérico
|
|
6
6
|
user-invocable: true
|
|
7
|
-
cliVersion: "10.
|
|
7
|
+
cliVersion: "10.11.0"
|
|
8
8
|
stacks:
|
|
9
9
|
- umbraco
|
|
10
10
|
---
|
|
@@ -4,7 +4,7 @@ description: Migra uma landing page existente (React/Vite, Next.js estático ou
|
|
|
4
4
|
version: core
|
|
5
5
|
when_to_use: Use quando o usuário pedir "use /migrate-lp-to-umbraco {projeto}" ou descrever a necessidade de migrar uma LP para Umbraco
|
|
6
6
|
user-invocable: true
|
|
7
|
-
cliVersion: "10.
|
|
7
|
+
cliVersion: "10.11.0"
|
|
8
8
|
stacks:
|
|
9
9
|
- umbraco
|
|
10
10
|
---
|
|
@@ -4,7 +4,7 @@ description: Implementa o plano aprovado de uma feature morph-spec inteiro nesta
|
|
|
4
4
|
version: core
|
|
5
5
|
when_to_use: Use com o gate do plano aprovado ("/morph-apply {feature}", "implementar feature"), em "/morph-review {feature}" (entra no §5), em "/morph-hotfix {feature}" ou incidente de produção (references/hotfix.md), ou quando `morph-spec next` mandar implement, verify, fix, review ou finish
|
|
6
6
|
user-invocable: true
|
|
7
|
-
cliVersion: "10.
|
|
7
|
+
cliVersion: "10.11.0"
|
|
8
8
|
---
|
|
9
9
|
|
|
10
10
|
# morph-apply
|
|
@@ -23,6 +23,7 @@ O plano inteiro, nesta sessão, em sequência. Sem sub-agent para implementar: o
|
|
|
23
23
|
|
|
24
24
|
- As regras de cada domínio (.NET, EF, MAF, Next.js, infra) chegam sozinhas: a rule do stack carrega quando você toca o arquivo. O texto inteiro de um standard: `morph-spec standards --find` → `--show <id>#<âncora>`.
|
|
25
25
|
- Antes de criar um tipo, confira a tabela `## Reuso` e `morph-spec graph explain <nome>` (sem grafo, `grep -rn`).
|
|
26
|
+
- Antes de criar um componente de tela, a origem dele está na tabela `### Componentes` do `1-design/mockups.md`: `registry` → `npx shadcn@latest add <@registry/item>` e leia o que entrou. Sem mockups, busque antes de escrever (`morph-spec standards --show frontend-nextjs-components#catalog-first`).
|
|
26
27
|
- Rode build e teste quando quiser; teste pesado fora do `verify` por `morph-spec heavy run -- <cmd>`. Exit 3 = fila cheia: uma chamada nova no máximo (`references/machine.md`).
|
|
27
28
|
- **Execute antes de marcar `feito`.** `teste`: veja falhar sem a mudança com `morph-spec prove-red {feature} --test "<o teste do Cn, filtrado>" [--files <produção do Cn>]` (devolve a produção à base, roda, restaura; exit 1 = o teste não morde) e cite o resultado na evidência. Soma ou conferência de número: ao menos uma vez sobre dado com a forma do de produção. `e2e` fica para a passada do §3.
|
|
28
29
|
- Ao fechar um `Cn`, atualize a linha dele no `report.md` (`feito` + a evidência: o que você executou e viu, teste, `arquivo:linha`); commite por lote coerente (`feat(<f>): C2-C3 …`; o tipo é o do lote, entre os que o hook `conventional-commit` aceita), não por `Cn`. Decisão ou fato novo → uma linha em `## Notas`.
|
|
@@ -4,7 +4,7 @@ description: Leva um pedido ou o link de uma issue ao plano aprovado — roteia
|
|
|
4
4
|
version: core
|
|
5
5
|
when_to_use: Use quando uma feature, bug ou chore começar ("/morph-plan {feature}", "/morph-plan <link da issue>", "vamos planejar X"), ou ao retomar uma feature cujo gate plan ainda não foi aprovado
|
|
6
6
|
user-invocable: true
|
|
7
|
-
cliVersion: "10.
|
|
7
|
+
cliVersion: "10.11.0"
|
|
8
8
|
---
|
|
9
9
|
|
|
10
10
|
# morph-plan
|
|
@@ -4,7 +4,7 @@ description: Conduz a fase de UI/UX de uma feature com plano aprovado — render
|
|
|
4
4
|
version: core
|
|
5
5
|
when_to_use: Use quando o ramo de design for tomado (morph-spec advance {feature} --design), antes de /morph-apply
|
|
6
6
|
user-invocable: true
|
|
7
|
-
cliVersion: "10.
|
|
7
|
+
cliVersion: "10.11.0"
|
|
8
8
|
---
|
|
9
9
|
|
|
10
10
|
# morph-uiux
|
|
@@ -18,6 +18,7 @@ A régua de sistema e de estética chega sozinha: a rule `ui-design` carrega qua
|
|
|
18
18
|
- `2-plan/plan.md` — problema e cenários de tela, referidos pelo id (`C3`). Esta fase **nunca** edita `plan.md` nem `checks.json`.
|
|
19
19
|
- `.morph/context/design-system.md` — o design system vivo; toda decisão de token ou componente parte dele e dos tokens reais do CSS do projeto.
|
|
20
20
|
- `config.json` → `project.stack` decide a tecnologia (`nextjs` → Tailwind + shadcn + Motion). Nunca suponha Next.js.
|
|
21
|
+
- O catálogo, antes de desenhar: o que o projeto já tem (`npx shadcn@latest info --json`, na pasta do `components.json`) e o que os registries oferecem para cada tela (`npx shadcn@latest search @shadcn <os do components.json> -q "<termo>"`, ou `search_items_in_registries` do MCP `shadcn`; o `@shadcn` embutido só entra na busca se nomeado). Uma direção parte do bloco que existe; o standard `frontend-nextjs-components` ("Catalog First") diz quais registries valem. Sem shadcn no projeto, a busca é no código e no design system.
|
|
21
22
|
- A superfície de cada tela (`marketing-site` | `admin-app` | `brand-moment`, em `surfaces.json`) diz quais standards abrir.
|
|
22
23
|
|
|
23
24
|
## 2. Opções — o usuário escolhe vendo, não lendo
|
|
@@ -48,7 +49,8 @@ O `advance --design` já escreveu `1-design/mockups.md` a partir do template —
|
|
|
48
49
|
|
|
49
50
|
- `**Protótipo:** 1-design/prototipos/{tela}.html` e `**Direção escolhida:**` (qual opção e por quê, numa frase);
|
|
50
51
|
- o `### Checklist de tela` com cada item decidido (`não se aplica` vale se escrito; vazio ou "a definir" reprova);
|
|
51
|
-
- `### Componentes`
|
|
52
|
+
- `### Componentes`: a tabela `Componente | Origem | Fonte ou motivo`, uma linha por componente da tela. Origem `projeto` (o caminho), `registry` (o `@registry/item` que a busca achou) ou `novo` (o que você buscou e por que não serve). O gate cobra a tabela: `novo` sem busca registrada não passa;
|
|
53
|
+
- `### Fluxo` (de onde vem, para onde vai).
|
|
52
54
|
|
|
53
55
|
Sem tela nova ou alterada: apague o `mockups.md` semeado.
|
|
54
56
|
|
|
@@ -68,7 +70,7 @@ Cada ocorrência vai para o `Cn` do plano que já a cobre, para uma exclusão re
|
|
|
68
70
|
|
|
69
71
|
## 7. Gate uiux
|
|
70
72
|
|
|
71
|
-
`morph-spec gate-check {feature} uiux [--json]` cobra por código: tela sem checklist completo, sem `**Protótipo:**`, sem o HTML ou sem os dois prints pausa nomeando o que falta. Complete antes de pedir aprovação.
|
|
73
|
+
`morph-spec gate-check {feature} uiux [--json]` cobra por código: tela sem checklist completo, sem a origem de cada componente, sem `**Protótipo:**`, sem o HTML ou sem os dois prints pausa nomeando o que falta. Complete antes de pedir aprovação.
|
|
72
74
|
|
|
73
75
|
Apresente aberto, não descrito: abra cada protótipo no navegador e cite a direção de cada tela em uma frase. Divergência de design system vista aqui: `--signals '{"designSystemDivergence":true}'`.
|
|
74
76
|
|
|
@@ -1343,10 +1343,11 @@
|
|
|
1343
1343
|
"nextjs"
|
|
1344
1344
|
],
|
|
1345
1345
|
"anchors": {
|
|
1346
|
+
"catalog-first": "#catalog-first",
|
|
1346
1347
|
"patterns": "#three-tier-hierarchy",
|
|
1347
1348
|
"shadcn": "#tier-1--shadcnui-primitives"
|
|
1348
1349
|
},
|
|
1349
|
-
"digest": "Three tiers (Next.js 16 + shadcn 4 CLI): `components/ui/` is shadcn CLI output (add via `npx shadcn@latest add`, NEVER edit because the CLI regenerates it; wrap it in `components/` instead); `components/` holds shared composed components with no business logic (importing `features/` is a lint error, frontend-nextjs-lint); `features/*/components/` is feature-scoped and may know the domain. Add `'use client'` only if the component uses hooks, events or browser APIs (not on every component: unnecessary client JS). Never pass raw API/fetch data as props: the feature maps it to typed props. The shared data table is specified once in `admin-app/data-table.md`: do not write a second `components/data-table.tsx`; a feature list is a Tier 3 component that owns the columns and the URL-to-table mapping."
|
|
1350
|
+
"digest": "Catalog first: a component is searched before it is written. Order: the project (`npx shadcn@latest info --json` lists installed components and paths; `.morph/context/design-system.md`), then the registries (`npx shadcn@latest search @shadcn @reui -q \"<term>\"` or the `shadcn` MCP `search_items_in_registries`; name `@shadcn`, an unnamed search covers only the registries declared in `components.json`; inspect with `view @registry/item` or `add --dry-run`), then `npx shadcn@latest add @registry/item` and read every added file; writing is last, and the `### Componentes` row of `1-design/mockups.md` (origin `novo`) says what was searched. Declared registries: `@shadcn` built in (primitives, blocks, charts), `@reui` for app screens, `@magicui`, `@aceternity`, `@react-bits` for landing pages; any other needs a decision in the plan. A block is the skeleton: tokens and composition follow the chosen direction; a block that brings a second animation or icon library is not installed. Base: `config.style` from `shadcn info --json` (`base-*` = Base UI with `render`, `radix-*`/`new-york`/`default` = Radix with `asChild`); the standards' code is written on Radix, so a new project starts with `npx shadcn@latest init -b radix`. Three tiers (Next.js 16 + shadcn 4 CLI): `components/ui/` is shadcn CLI output (add via `npx shadcn@latest add`, NEVER edit because the CLI regenerates it; wrap it in `components/` instead); `components/` holds shared composed components with no business logic (importing `features/` is a lint error, frontend-nextjs-lint); `features/*/components/` is feature-scoped and may know the domain. Add `'use client'` only if the component uses hooks, events or browser APIs (not on every component: unnecessary client JS). Never pass raw API/fetch data as props: the feature maps it to typed props. The shared data table is specified once in `admin-app/data-table.md`: do not write a second `components/data-table.tsx`; a feature list is a Tier 3 component that owns the columns and the URL-to-table mapping."
|
|
1350
1351
|
},
|
|
1351
1352
|
{
|
|
1352
1353
|
"id": "frontend-nextjs-data-fetching",
|
|
@@ -1914,7 +1915,7 @@
|
|
|
1914
1915
|
"rules": "#o-que-cada-regra-compra",
|
|
1915
1916
|
"not-a-rule": "#o-que-não-é-regra"
|
|
1916
1917
|
},
|
|
1917
|
-
"digest": "Rules with a reason that a machine can see are lint errors, not prose: one eslint.config.mjs at the Next app root, flat config spreading eslint-config-next/core-web-vitals and eslint-config-next/typescript, no new plugin. ESLint 9 (eslint-plugin-import/react peer range; the bundled typescript-eslint wants TypeScript <6.1); Next 16 next build no longer lints; the verify build node runs eslint --quiet on the files the feature changed (legacy lint debt never reddens a feature), from the app root, when eslint.config.* and eslint are present. no-restricted-imports bans framer-motion (one import path, motion/react), zustand/redux/@reduxjs/toolkit (server state is TanStack Query, page and filters in the URL), DB drivers pg/@neondatabase/serverless/@prisma/client/drizzle-orm/postgres (Next never touches the database; the .NET API does), the legacy shadcn @/components/ui/form, and @/features/*/* deep imports outside src/features (use the feature index.ts). import/no-restricted-paths: src/components never imports src/features, src/features never imports src/app, src/hooks never imports the API client (lib/api-client.ts, lib/api). no-restricted-syntax: fetch or apiClient called inside useEffect, and 'use client' in the root app/layout.tsx. import/no-default-export except Next convention files (page, layout, loading, error, not-found, template, default, route, sitemap, robots, icons, OG images) and *.config.*. @typescript-eslint/no-explicit-any error, no-console warn. A new restriction is one line in this file with the reason in its message; a one-off exception is eslint-disable-next-line with the reason. CSS class naming, animation class catalogs, optional className, Zod on props, motion counts and offsets, QueryClient defaults and prop-drilling depth are taste: neither prose nor lint."
|
|
1918
|
+
"digest": "Rules with a reason that a machine can see are lint errors, not prose: one eslint.config.mjs at the Next app root, flat config spreading eslint-config-next/core-web-vitals and eslint-config-next/typescript, no new plugin. ESLint 9 (eslint-plugin-import/react peer range; the bundled typescript-eslint wants TypeScript <6.1); Next 16 next build no longer lints; the verify build node runs eslint --quiet on the files the feature changed (legacy lint debt never reddens a feature), from the app root, when eslint.config.* and eslint are present. no-restricted-imports bans framer-motion (one import path, motion/react), zustand/redux/@reduxjs/toolkit (server state is TanStack Query, page and filters in the URL), DB drivers pg/@neondatabase/serverless/@prisma/client/drizzle-orm/postgres (Next never touches the database; the .NET API does), the legacy shadcn @/components/ui/form, and @/features/*/* deep imports outside src/features (use the feature index.ts). import/no-restricted-paths: src/components never imports src/features, src/features never imports src/app, src/hooks never imports the API client (lib/api-client.ts, lib/api). no-restricted-syntax: fetch or apiClient called inside useEffect, and 'use client' in the root app/layout.tsx. react/forbid-elements (from the eslint-plugin-react that eslint-config-next installs): raw button, input, textarea, select, table and dialog are errors in every .tsx outside components/ui/ (use the shadcn component; `npx shadcn@latest add` when it is missing). import/no-default-export except Next convention files (page, layout, loading, error, not-found, template, default, route, sitemap, robots, icons, OG images) and *.config.*. @typescript-eslint/no-explicit-any error, no-console warn. A new restriction is one line in this file with the reason in its message; a one-off exception is eslint-disable-next-line with the reason. CSS class naming, animation class catalogs, optional className, Zod on props, motion counts and offsets, QueryClient defaults and prop-drilling depth are taste: neither prose nor lint."
|
|
1918
1919
|
},
|
|
1919
1920
|
{
|
|
1920
1921
|
"id": "architecture-stack-baseline",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> **Scope:** frontend/nextjs/components
|
|
4
4
|
> **Layer:** 2 (on keyword)
|
|
5
|
-
> **Keywords:** component, shadcn, reusable, shared, ui, three-tier
|
|
5
|
+
> **Keywords:** component, shadcn, reusable, shared, ui, three-tier, registry, registries, catalog, block, blocks, components.json, magicui, aceternity, reui, coss, react-bits, base ui, radix
|
|
6
6
|
> **Load When:** creating or editing React components
|
|
7
7
|
|
|
8
8
|
**Verified against:** Next.js 16 + shadcn 4 CLI (the code blocks typecheck under `tsc --strict`). Last-verified: 2026-09-24.
|
|
@@ -19,6 +19,40 @@ Three-tier component hierarchy. `components/ui/` is shadcn primitives (never edi
|
|
|
19
19
|
- NEVER pass raw API data directly to a component — transform to props first
|
|
20
20
|
- `components/` importing `features/` and the legacy `@/components/ui/form` are lint errors (`frontend-nextjs-lint`)
|
|
21
21
|
|
|
22
|
+
## Catalog First
|
|
23
|
+
|
|
24
|
+
A component is searched before it is written. The order, cheapest first:
|
|
25
|
+
|
|
26
|
+
1. **The project.** `npx shadcn@latest info --json` lists what is installed (`components`) and where (`resolvedPaths`); `components/` and the feature folder hold what was composed. `.morph/context/design-system.md` names the shared ones.
|
|
27
|
+
2. **The registries.** `npx shadcn@latest search @shadcn @reui -q "<what the screen needs>"` for an app screen, `search @shadcn @magicui @aceternity @react-bits -q "…"` for a landing page (same answer from the `shadcn` MCP: `search_items_in_registries` with `registries`). Name `@shadcn`: without a registry name the search covers only the ones declared in `components.json`, and the built-in one is not among them. A registry reported as skipped did not answer: search it again by name before concluding it has nothing. Read the hit before installing: `npx shadcn@latest view @registry/item`, or `add @registry/item --dry-run`.
|
|
28
|
+
3. **Install, then read.** `npx shadcn@latest add @registry/item`. Third-party code lands in your tree: read every added file, and fix imports, tokens and `'use client'` to the project's rules before using it.
|
|
29
|
+
4. **Write it** only when 1 and 2 came back empty, and say what was searched: the `### Componentes` row of `1-design/mockups.md` (origin `novo`) carries the reason, and the uiux gate reads it.
|
|
30
|
+
|
|
31
|
+
The registries a project declares — and no other without a decision recorded in the plan (URLs as published in the shadcn registry index, https://ui.shadcn.com/r/registries.json, read on 2026-11-15):
|
|
32
|
+
|
|
33
|
+
```json
|
|
34
|
+
{
|
|
35
|
+
"registries": {
|
|
36
|
+
"@reui": "https://reui.io/r/{style}/{name}.json",
|
|
37
|
+
"@magicui": "https://magicui.design/r/{name}",
|
|
38
|
+
"@aceternity": "https://ui.aceternity.com/registry/{name}.json",
|
|
39
|
+
"@react-bits": "https://reactbits.dev/r/{name}.json"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
| Registry | Reach for it when | Mind |
|
|
45
|
+
|---|---|---|
|
|
46
|
+
| `@shadcn` (built in, no entry needed) | primitives, **blocks** (sidebar, login, dashboard shell) and **charts** (Recharts) | first stop for any admin screen |
|
|
47
|
+
| `@reui` | data grid, filters, kanban, date and file inputs for back office | serves per `style`; blocks marked Pro are paid |
|
|
48
|
+
| `@magicui` | marketing sections and animated accents (marquee, bento, number ticker) | depends on `motion` |
|
|
49
|
+
| `@aceternity` | heavy hero and background effects for a landing page | one per page; check the frame budget on a phone |
|
|
50
|
+
| `@react-bits` | animated text and backgrounds | pick the `-TS-TW` variant; the license is MIT + Commons Clause, not plain MIT |
|
|
51
|
+
|
|
52
|
+
A registry item never replaces the direction: the block is the skeleton, the tokens and the composition are the project's (`frontend-design-system-art-direction`). Two rules keep the tree clean: an installed block is moved out of `components/ui/` into `components/` or the feature when it is edited, and a block that brings a second animation or icon library is not installed — find another or write it.
|
|
53
|
+
|
|
54
|
+
**Base.** `shadcn info --json` → `config.style` says which primitives the project runs on: a `base-*` style is Base UI (`render={<Button />}`), `radix-*`, `new-york` and `default` are Radix (`asChild`). Write for the base the project has. The code blocks of these standards are written and typechecked on Radix, so a new project starts with `npx shadcn@latest init -b radix` (without `-b` the CLI now picks Base UI); a registry built only for Base UI is not declared.
|
|
55
|
+
|
|
22
56
|
## Three-Tier Hierarchy
|
|
23
57
|
|
|
24
58
|
```
|
|
@@ -93,6 +127,7 @@ A feature **list** is a Tier 3 component too: the feature owns the columns and t
|
|
|
93
127
|
|
|
94
128
|
| Wrong | Right | Why |
|
|
95
129
|
|-------|-------|-----|
|
|
130
|
+
| Hand-write a sidebar, data grid or hero | `shadcn search`, then `add @registry/item` | The block already carries focus, states and responsive behavior |
|
|
96
131
|
| Edit `components/ui/button.tsx` | Wrap in `components/action-button.tsx` | shadcn CLI overwrites it |
|
|
97
132
|
| `'use client'` on all components | Only on interactive ones | Unnecessary client JS |
|
|
98
133
|
| Pass raw fetch response as prop | Map it to typed props in the feature | The component stops depending on the API shape |
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> **Scope:** nextjs
|
|
4
4
|
> **Layer:** 0 (resumo injetado pela rule `nextjs-standards` (`**/*.ts`, `**/*.tsx`); o `stack-scan` acusa o projeto sem este arquivo)
|
|
5
|
-
> **Keywords:** eslint, lint, eslint.config.mjs, no-restricted-imports, no-restricted-paths, no-restricted-syntax, no-default-export, no-explicit-any, framer-motion, zustand
|
|
5
|
+
> **Keywords:** eslint, lint, eslint.config.mjs, no-restricted-imports, no-restricted-paths, no-restricted-syntax, no-default-export, no-explicit-any, forbid-elements, elemento cru, framer-motion, zustand
|
|
6
6
|
> **Load When:** projeto Next.js sem `eslint.config.mjs` com `no-restricted-imports`, ou o lint acusou uma destas regras
|
|
7
7
|
|
|
8
8
|
**Verified against:** eslint 9.39.5, eslint-config-next 16.4.2 (typescript-eslint 8.71.2, eslint-plugin-import 2.32.0), next 16.4.2, typescript 6.0.3 (sonda: um arquivo ruim por regra → erro da regra esperada, `no-console` → aviso, arquivos conformes e o scaffold `morph-spec scaffold nextjs` → 0 problemas). Last-verified: 2026-10-18.
|
|
@@ -53,6 +53,15 @@ const restrictedImports = (...extraPatterns) => ['error', {
|
|
|
53
53
|
],
|
|
54
54
|
}]
|
|
55
55
|
|
|
56
|
+
const RAW_ELEMENTS = [
|
|
57
|
+
['button', 'Button de @/components/ui/button'],
|
|
58
|
+
['input', 'Input de @/components/ui/input (dentro de um Field)'],
|
|
59
|
+
['textarea', 'Textarea de @/components/ui/textarea'],
|
|
60
|
+
['select', 'Select de @/components/ui/select'],
|
|
61
|
+
['table', 'a tabela compartilhada (frontend-admin-app-data-table) ou Table de @/components/ui/table'],
|
|
62
|
+
['dialog', 'Dialog ou AlertDialog de @/components/ui'],
|
|
63
|
+
].map(([element, use]) => ({ element, message: `Elemento cru: use ${use}. Falta o componente? npx shadcn@latest add.` }))
|
|
64
|
+
|
|
56
65
|
const FETCH_IN_EFFECT = {
|
|
57
66
|
selector:
|
|
58
67
|
"CallExpression[callee.name='useEffect'] CallExpression:matches([callee.name='fetch'], [callee.name='apiClient'], [callee.object.name='apiClient'])",
|
|
@@ -83,6 +92,11 @@ export default defineConfig([
|
|
|
83
92
|
files: ['src/features/**'],
|
|
84
93
|
rules: { 'no-restricted-imports': restrictedImports() },
|
|
85
94
|
},
|
|
95
|
+
{
|
|
96
|
+
files: ['**/*.tsx'],
|
|
97
|
+
ignores: ['**/components/ui/**'],
|
|
98
|
+
rules: { 'react/forbid-elements': ['error', { forbid: RAW_ELEMENTS }] },
|
|
99
|
+
},
|
|
86
100
|
{
|
|
87
101
|
files: ['app/layout.tsx', 'src/app/layout.tsx'],
|
|
88
102
|
rules: {
|
|
@@ -119,12 +133,20 @@ repete os pacotes banidos.
|
|
|
119
133
|
| `import/no-restricted-paths` `src/components` ↛ `src/features` | componente compartilhado que conhece domínio | ele deixa de ser compartilhável e cria ciclo feature → components → feature |
|
|
120
134
|
| `import/no-restricted-paths` `src/features` ↛ `src/app` | feature importando rota | a dependência é de mão única: a rota compõe a feature |
|
|
121
135
|
| `import/no-restricted-paths` `src/hooks` ↛ cliente da API | hook compartilhado chamando o backend | chamada à API é de feature, com a key factory dela; hook compartilhado é só de UI |
|
|
136
|
+
| `react/forbid-elements` `button`, `input`, `textarea`, `select`, `table`, `dialog` (fora de `components/ui/`) | elemento HTML cru onde o projeto tem componente | o primitivo do shadcn já carrega foco, estados, tema e acessibilidade; recriá-lo por tela é o que faz duas telas do mesmo app parecerem de apps diferentes |
|
|
122
137
|
| `no-restricted-syntax` fetch/`apiClient` dentro de `useEffect` | busca de dado no efeito | sem cache, sem dedup, corrida entre requisições e cascata de render; Server Component ou TanStack Query resolvem |
|
|
123
138
|
| `no-restricted-syntax` `'use client'` em `app/layout.tsx` | layout raiz no cliente | perde `metadata` e manda a árvore inteira para o bundle do cliente |
|
|
124
139
|
| `import/no-default-export` (exceto arquivos de rota e `*.config.*`) | `export default` em componente e hook | nome único em todo import: busca e rename acham todos os usos; o Next exige `default` só nos arquivos de convenção |
|
|
125
140
|
| `@typescript-eslint/no-explicit-any` | `any` | desliga o tipo no ponto onde o dado da API entra; o certo é schema Zod + `z.infer` |
|
|
126
141
|
| `no-console` (aviso) | `console.log` esquecido | ruído no console do usuário e dado vazando; aviso, porque o diagnóstico local é legítimo |
|
|
127
142
|
|
|
143
|
+
O `verify` aplica a `react/forbid-elements` pela linha de comando em todo projeto com
|
|
144
|
+
`components.json`, mesmo que o `eslint.config` ainda não a declare: declará-la aqui é o que leva o
|
|
145
|
+
erro ao editor, com a mensagem que nomeia o componente. A regra vem do eslint-plugin-react que o `eslint-config-next` instala (sondada com
|
|
146
|
+
o 7.37.5 do eslint-config-next 16.4.6: `<button>`, `<input>` e `<table>` em `features/` → erro; o
|
|
147
|
+
wrapper em `components/ui/` → 0 problemas). `<input type="file">` ou `type="hidden"` sem componente
|
|
148
|
+
equivalente é a exceção pontual abaixo, com o motivo.
|
|
149
|
+
|
|
128
150
|
Restrição nova entra como linha neste arquivo, com o porquê na `message`. Nunca uma regra nova
|
|
129
151
|
em prosa. Exceção pontual é `// eslint-disable-next-line <regra> -- <motivo>` na linha, nunca o
|
|
130
152
|
desligamento da regra no projeto.
|
|
@@ -188,7 +188,7 @@ export function DocumentForm() {
|
|
|
188
188
|
|
|
189
189
|
## shadcn/ui
|
|
190
190
|
|
|
191
|
-
Install: `npx shadcn@latest init` then `npx shadcn@latest add button input card dialog field`.
|
|
191
|
+
Install: `npx shadcn@latest init -b radix` (`frontend-nextjs-components`, "Catalog First", says why Radix) then `npx shadcn@latest add button input card dialog field`.
|
|
192
192
|
Components are copied to `components/ui/` -- NOT an npm dependency, your code to customize.
|
|
193
193
|
|
|
194
194
|
## TypeScript Strict Patterns
|
|
@@ -24,7 +24,11 @@ Troque cada `…` pela decisão. "Não se aplica" vale se escrito; `…`, vazio
|
|
|
24
24
|
|
|
25
25
|
### Componentes
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
Uma linha por componente da tela, depois de buscar no projeto e nos registries. Origem: `projeto` (o caminho), `registry` (o `@registry/item`) ou `novo` (o que foi buscado e por que não serve). Linha com `…` reprova o Gate uiux.
|
|
28
|
+
|
|
29
|
+
| Componente | Origem | Fonte ou motivo |
|
|
30
|
+
|---|---|---|
|
|
31
|
+
| … | … | … |
|
|
28
32
|
|
|
29
33
|
### Fluxo
|
|
30
34
|
|