@cubocicloide/stack-react-fastapi 13.0.6
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/LICENSE +33 -0
- package/README.md +66 -0
- package/dist/commands/lint/checks/BE/001.d.ts +6 -0
- package/dist/commands/lint/checks/BE/001.js +95 -0
- package/dist/commands/lint/checks/BE/001.js.map +1 -0
- package/dist/commands/lint/checks/BE/002.d.ts +6 -0
- package/dist/commands/lint/checks/BE/002.js +30 -0
- package/dist/commands/lint/checks/BE/002.js.map +1 -0
- package/dist/commands/lint/checks/BE/003.d.ts +11 -0
- package/dist/commands/lint/checks/BE/003.js +46 -0
- package/dist/commands/lint/checks/BE/003.js.map +1 -0
- package/dist/commands/lint/checks/BE/004.d.ts +6 -0
- package/dist/commands/lint/checks/BE/004.js +27 -0
- package/dist/commands/lint/checks/BE/004.js.map +1 -0
- package/dist/commands/lint/checks/BE/005.d.ts +6 -0
- package/dist/commands/lint/checks/BE/005.js +107 -0
- package/dist/commands/lint/checks/BE/005.js.map +1 -0
- package/dist/commands/lint/checks/BE/006.d.ts +6 -0
- package/dist/commands/lint/checks/BE/006.js +27 -0
- package/dist/commands/lint/checks/BE/006.js.map +1 -0
- package/dist/commands/lint/checks/BE/007.d.ts +31 -0
- package/dist/commands/lint/checks/BE/007.js +109 -0
- package/dist/commands/lint/checks/BE/007.js.map +1 -0
- package/dist/commands/lint/checks/BE/008.d.ts +12 -0
- package/dist/commands/lint/checks/BE/008.js +57 -0
- package/dist/commands/lint/checks/BE/008.js.map +1 -0
- package/dist/commands/lint/checks/BE/009.d.ts +12 -0
- package/dist/commands/lint/checks/BE/009.js +104 -0
- package/dist/commands/lint/checks/BE/009.js.map +1 -0
- package/dist/commands/lint/checks/BE/010.d.ts +12 -0
- package/dist/commands/lint/checks/BE/010.js +54 -0
- package/dist/commands/lint/checks/BE/010.js.map +1 -0
- package/dist/commands/lint/checks/BE/011.d.ts +16 -0
- package/dist/commands/lint/checks/BE/011.js +46 -0
- package/dist/commands/lint/checks/BE/011.js.map +1 -0
- package/dist/commands/lint/checks/E2E/001.d.ts +6 -0
- package/dist/commands/lint/checks/E2E/001.js +35 -0
- package/dist/commands/lint/checks/E2E/001.js.map +1 -0
- package/dist/commands/lint/checks/E2E/002.d.ts +6 -0
- package/dist/commands/lint/checks/E2E/002.js +37 -0
- package/dist/commands/lint/checks/E2E/002.js.map +1 -0
- package/dist/commands/lint/checks/E2E/003.d.ts +6 -0
- package/dist/commands/lint/checks/E2E/003.js +42 -0
- package/dist/commands/lint/checks/E2E/003.js.map +1 -0
- package/dist/commands/lint/checks/E2E/004.d.ts +6 -0
- package/dist/commands/lint/checks/E2E/004.js +37 -0
- package/dist/commands/lint/checks/E2E/004.js.map +1 -0
- package/dist/commands/lint/checks/E2E/005.d.ts +6 -0
- package/dist/commands/lint/checks/E2E/005.js +47 -0
- package/dist/commands/lint/checks/E2E/005.js.map +1 -0
- package/dist/commands/lint/checks/E2E/006.d.ts +6 -0
- package/dist/commands/lint/checks/E2E/006.js +28 -0
- package/dist/commands/lint/checks/E2E/006.js.map +1 -0
- package/dist/commands/lint/checks/E2E/007.d.ts +6 -0
- package/dist/commands/lint/checks/E2E/007.js +47 -0
- package/dist/commands/lint/checks/E2E/007.js.map +1 -0
- package/dist/commands/lint/checks/FE/001.d.ts +6 -0
- package/dist/commands/lint/checks/FE/001.js +56 -0
- package/dist/commands/lint/checks/FE/001.js.map +1 -0
- package/dist/commands/lint/checks/FE/002.d.ts +6 -0
- package/dist/commands/lint/checks/FE/002.js +80 -0
- package/dist/commands/lint/checks/FE/002.js.map +1 -0
- package/dist/commands/lint/checks/FE/003.d.ts +6 -0
- package/dist/commands/lint/checks/FE/003.js +65 -0
- package/dist/commands/lint/checks/FE/003.js.map +1 -0
- package/dist/commands/lint/checks/FE/004.d.ts +6 -0
- package/dist/commands/lint/checks/FE/004.js +72 -0
- package/dist/commands/lint/checks/FE/004.js.map +1 -0
- package/dist/commands/lint/checks/FE/005.d.ts +6 -0
- package/dist/commands/lint/checks/FE/005.js +103 -0
- package/dist/commands/lint/checks/FE/005.js.map +1 -0
- package/dist/commands/lint/checks/FE/006.d.ts +6 -0
- package/dist/commands/lint/checks/FE/006.js +102 -0
- package/dist/commands/lint/checks/FE/006.js.map +1 -0
- package/dist/commands/lint/checks/FE/007.d.ts +6 -0
- package/dist/commands/lint/checks/FE/007.js +60 -0
- package/dist/commands/lint/checks/FE/007.js.map +1 -0
- package/dist/commands/lint/checks/FE/008.d.ts +6 -0
- package/dist/commands/lint/checks/FE/008.js +115 -0
- package/dist/commands/lint/checks/FE/008.js.map +1 -0
- package/dist/commands/lint/checks/FE/009.d.ts +6 -0
- package/dist/commands/lint/checks/FE/009.js +83 -0
- package/dist/commands/lint/checks/FE/009.js.map +1 -0
- package/dist/commands/lint/checks/FE/010.d.ts +6 -0
- package/dist/commands/lint/checks/FE/010.js +105 -0
- package/dist/commands/lint/checks/FE/010.js.map +1 -0
- package/dist/commands/lint/checks/FE/011.d.ts +6 -0
- package/dist/commands/lint/checks/FE/011.js +43 -0
- package/dist/commands/lint/checks/FE/011.js.map +1 -0
- package/dist/commands/lint/checks/FE/012.d.ts +6 -0
- package/dist/commands/lint/checks/FE/012.js +150 -0
- package/dist/commands/lint/checks/FE/012.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +3491 -0
- package/dist/index.js.map +1 -0
- package/dude.stack.json +7 -0
- package/package.json +43 -0
- package/templates/aws-eks/backend/Dockerfile.prod.hbs +22 -0
- package/templates/aws-eks/docs/docs/deploy.md.hbs +159 -0
- package/templates/aws-eks/frontend/Dockerfile.prod +28 -0
- package/templates/aws-eks/frontend/nginx.conf +19 -0
- package/templates/aws-eks/iac/README.md.hbs +311 -0
- package/templates/aws-eks/iac/_gitignore +24 -0
- package/templates/aws-eks/iac/helm/app/.helmignore +7 -0
- package/templates/aws-eks/iac/helm/app/Chart.yaml.hbs +6 -0
- package/templates/aws-eks/iac/helm/app/templates/NOTES.txt +23 -0
- package/templates/aws-eks/iac/helm/app/templates/backend-deployment.yaml +44 -0
- package/templates/aws-eks/iac/helm/app/templates/backend-service.yaml +16 -0
- package/templates/aws-eks/iac/helm/app/templates/celery-beat-deployment.yaml +34 -0
- package/templates/aws-eks/iac/helm/app/templates/celery-worker-deployment.yaml +31 -0
- package/templates/aws-eks/iac/helm/app/templates/configmap.yaml +15 -0
- package/templates/aws-eks/iac/helm/app/templates/flower-deployment.yaml +28 -0
- package/templates/aws-eks/iac/helm/app/templates/flower-service.yaml +19 -0
- package/templates/aws-eks/iac/helm/app/templates/frontend-deployment.yaml +34 -0
- package/templates/aws-eks/iac/helm/app/templates/frontend-service.yaml +16 -0
- package/templates/aws-eks/iac/helm/app/templates/helpers.tpl +90 -0
- package/templates/aws-eks/iac/helm/app/templates/hpa.yaml +23 -0
- package/templates/aws-eks/iac/helm/app/templates/ingress.yaml +30 -0
- package/templates/aws-eks/iac/helm/app/templates/migration-job.yaml +38 -0
- package/templates/aws-eks/iac/helm/app/templates/redis-deployment.yaml +33 -0
- package/templates/aws-eks/iac/helm/app/templates/redis-service.yaml +18 -0
- package/templates/aws-eks/iac/helm/app/templates/secret.yaml +17 -0
- package/templates/aws-eks/iac/helm/app/templates/serviceaccount.yaml +12 -0
- package/templates/aws-eks/iac/helm/app/values-dev.yaml.hbs +35 -0
- package/templates/aws-eks/iac/helm/app/values.yaml.hbs +130 -0
- package/templates/aws-eks/iac/runner/Dockerfile +53 -0
- package/templates/aws-eks/iac/terraform/bootstrap/main.tf.hbs +101 -0
- package/templates/aws-eks/iac/terraform/bootstrap/outputs.tf +19 -0
- package/templates/aws-eks/iac/terraform/bootstrap/variables.tf.hbs +17 -0
- package/templates/aws-eks/iac/terraform/environments/dev/backend.hcl.hbs +12 -0
- package/templates/aws-eks/iac/terraform/environments/dev/terraform.tfvars.hbs +32 -0
- package/templates/aws-eks/iac/terraform/main.tf.hbs +305 -0
- package/templates/aws-eks/iac/terraform/outputs.tf.hbs +52 -0
- package/templates/aws-eks/iac/terraform/providers.tf +47 -0
- package/templates/aws-eks/iac/terraform/variables.tf.hbs +181 -0
- package/templates/aws-eks/iac/terraform/versions.tf +27 -0
- package/templates/base/.claude/agents/issue-fixer.md +190 -0
- package/templates/base/.claude/agents/security-fixer.md +250 -0
- package/templates/base/.claude/rules/BE/001.md +25 -0
- package/templates/base/.claude/rules/BE/002.md +15 -0
- package/templates/base/.claude/rules/BE/003.md +18 -0
- package/templates/base/.claude/rules/BE/004.md +14 -0
- package/templates/base/.claude/rules/BE/005.md +15 -0
- package/templates/base/.claude/rules/BE/006.md +17 -0
- package/templates/base/.claude/rules/BE/007.md +21 -0
- package/templates/base/.claude/rules/BE/008.md +19 -0
- package/templates/base/.claude/rules/BE/009.md +27 -0
- package/templates/base/.claude/rules/BE/010.md +16 -0
- package/templates/base/.claude/rules/BE/011.md +15 -0
- package/templates/base/.claude/rules/E2E/001.md +13 -0
- package/templates/base/.claude/rules/E2E/002.md +14 -0
- package/templates/base/.claude/rules/E2E/003.md +10 -0
- package/templates/base/.claude/rules/E2E/004.md +23 -0
- package/templates/base/.claude/rules/E2E/005.md +15 -0
- package/templates/base/.claude/rules/E2E/006.md +13 -0
- package/templates/base/.claude/rules/E2E/007.md +18 -0
- package/templates/base/.claude/rules/FE/001.md +22 -0
- package/templates/base/.claude/rules/FE/002.md +39 -0
- package/templates/base/.claude/rules/FE/003.md +19 -0
- package/templates/base/.claude/rules/FE/004.md +21 -0
- package/templates/base/.claude/rules/FE/005.md +33 -0
- package/templates/base/.claude/rules/FE/006.md +24 -0
- package/templates/base/.claude/rules/FE/007.md +19 -0
- package/templates/base/.claude/rules/FE/008.md +26 -0
- package/templates/base/.claude/rules/FE/009.md +30 -0
- package/templates/base/.claude/rules/FE/010.md +25 -0
- package/templates/base/.claude/rules/FE/011.md +22 -0
- package/templates/base/.claude/rules/FE/012.md +32 -0
- package/templates/base/.claude/settings.json +53 -0
- package/templates/base/.claude/skills/clean-branches/SKILL.md +100 -0
- package/templates/base/.claude/skills/create/SKILL.md +47 -0
- package/templates/base/.claude/skills/create-jira-issue/SKILL.md +174 -0
- package/templates/base/.claude/skills/create-page/SKILL.md +195 -0
- package/templates/base/.claude/skills/create-route/SKILL.md +199 -0
- package/templates/base/.claude/skills/draft-email/SKILL.md +104 -0
- package/templates/base/.claude/skills/fix-issues/SKILL.md +238 -0
- package/templates/base/.claude/skills/security-scan/SKILL.md +297 -0
- package/templates/base/.claude/skills/verify-security-fixes/SKILL.md +180 -0
- package/templates/base/.dude/commands/README.md +85 -0
- package/templates/base/.dude/commands/hello.ts +34 -0
- package/templates/base/.dude/lint/checks/PRJ/001.ts +26 -0
- package/templates/base/.dude/lint/checks/README.md +69 -0
- package/templates/base/.vscode/tasks.json +44 -0
- package/templates/base/.worktreeinclude +2 -0
- package/templates/base/CLAUDE.md.hbs +364 -0
- package/templates/base/README.md.hbs +187 -0
- package/templates/base/_env.example.hbs +29 -0
- package/templates/base/_env.hbs +25 -0
- package/templates/base/_gitignore +31 -0
- package/templates/base/_npmrc +2 -0
- package/templates/base/backend/Dockerfile.hbs +22 -0
- package/templates/base/backend/README.md.hbs +74 -0
- package/templates/base/backend/_dockerignore +11 -0
- package/templates/base/backend/app/__init__.py +1 -0
- package/templates/base/backend/app/core/__init__.py +0 -0
- package/templates/base/backend/app/core/config.py.hbs +23 -0
- package/templates/base/backend/app/fixtures/__init__.py +0 -0
- package/templates/base/backend/app/main.py.hbs +41 -0
- package/templates/base/backend/app/management/__init__.py +0 -0
- package/templates/base/backend/app/models/__init__.py +0 -0
- package/templates/base/backend/app/queries/__init__.py +0 -0
- package/templates/base/backend/app/routers/__init__.py +0 -0
- package/templates/base/backend/app/routers/health.py +13 -0
- package/templates/base/backend/app/schemas/__init__.py +0 -0
- package/templates/base/backend/app/schemas/health.py +7 -0
- package/templates/base/backend/app/tasks/__init__.py +1 -0
- package/templates/base/backend/app/tests/__init__.py +0 -0
- package/templates/base/backend/app/tests/conftest.py +13 -0
- package/templates/base/backend/app/tests/models/__init__.py +0 -0
- package/templates/base/backend/app/tests/queries/__init__.py +0 -0
- package/templates/base/backend/app/tests/routers/__init__.py +0 -0
- package/templates/base/backend/app/tests/routers/test_health.py +10 -0
- package/templates/base/backend/app/tests/tasks/__init__.py +1 -0
- package/templates/base/backend/app/tests/utils/__init__.py +0 -0
- package/templates/base/backend/app/utils/__init__.py +0 -0
- package/templates/base/backend/pyproject.toml.hbs +40 -0
- package/templates/base/docker-compose.yml.hbs +128 -0
- package/templates/base/docs/docs/api.md +21 -0
- package/templates/base/docs/docs/dude.md.hbs +316 -0
- package/templates/base/docs/docs/index.md.hbs +100 -0
- package/templates/base/docs/docs/mkdocs.md +238 -0
- package/templates/base/docs/mkdocs.yml.hbs +52 -0
- package/templates/base/e2e/.prettierrc.json +1 -0
- package/templates/base/e2e/_prettierignore +3 -0
- package/templates/base/e2e/cucumber.js +21 -0
- package/templates/base/e2e/eslint.config.mjs +14 -0
- package/templates/base/e2e/features/example.feature +13 -0
- package/templates/base/e2e/package.json.hbs +30 -0
- package/templates/base/e2e/pages/ExamplePage.ts +16 -0
- package/templates/base/e2e/playwright.config.ts +27 -0
- package/templates/base/e2e/steps/common.steps.ts +32 -0
- package/templates/base/e2e/steps/example.steps.ts +4 -0
- package/templates/base/e2e/support/hooks.ts +72 -0
- package/templates/base/e2e/support/world.ts +24 -0
- package/templates/base/e2e/tsconfig.json +22 -0
- package/templates/base/frontend/.prettierrc.json +6 -0
- package/templates/base/frontend/Dockerfile +10 -0
- package/templates/base/frontend/_dockerignore +4 -0
- package/templates/base/frontend/eslint.config.js +32 -0
- package/templates/base/frontend/index.html.hbs +13 -0
- package/templates/base/frontend/package.json.hbs +38 -0
- package/templates/base/frontend/public/favicon.svg +5 -0
- package/templates/base/frontend/src/$components/Layout/$assets/logo.svg +5 -0
- package/templates/base/frontend/src/$components/Layout/constants.tsx.hbs +10 -0
- package/templates/base/frontend/src/$components/Layout/index.tsx +80 -0
- package/templates/base/frontend/src/$components/Layout/types.tsx +9 -0
- package/templates/base/frontend/src/$components/index.tsx +1 -0
- package/templates/base/frontend/src/$hooks/index.tsx +2 -0
- package/templates/base/frontend/src/$hooks/useCounterStore/index.tsx +28 -0
- package/templates/base/frontend/src/$hooks/useCounterStore/types.tsx +7 -0
- package/templates/base/frontend/src/$hooks/usePageTitle/index.tsx +21 -0
- package/templates/base/frontend/src/$types/vite-env.d.ts +10 -0
- package/templates/base/frontend/src/App.tsx.hbs +40 -0
- package/templates/base/frontend/src/main.tsx +10 -0
- package/templates/base/frontend/src/openapi/utils/openapi.yaml.hbs +28 -0
- package/templates/base/frontend/src/pages/constants.tsx +31 -0
- package/templates/base/frontend/src/pages/index.tsx +192 -0
- package/templates/base/frontend/src/pages/types.tsx +6 -0
- package/templates/base/frontend/src/styles.module.css +7 -0
- package/templates/base/frontend/src/utils/constants.tsx +11 -0
- package/templates/base/frontend/src/utils/formatters/index.tsx +49 -0
- package/templates/base/frontend/src/utils/functions.tsx +70 -0
- package/templates/base/frontend/src/utils/index.tsx +3 -0
- package/templates/base/frontend/tsconfig.json +24 -0
- package/templates/base/frontend/vite.config.ts +20 -0
- package/templates/base/package.json.hbs +11 -0
- package/templates/base/security/baseline.json +4 -0
- package/templates/celery/backend/app/tasks/__init__.py +1 -0
- package/templates/celery/backend/app/tasks/example.py +21 -0
- package/templates/celery/backend/app/tests/tasks/test_example.py +7 -0
- package/templates/celery/backend/app/worker.py.hbs +33 -0
- package/templates/celerybeat/backend/app/tasks/scheduled.py +16 -0
- package/templates/celerybeat/backend/app/tests/tasks/test_scheduled.py +7 -0
- package/templates/postgres/.dude/commands/reset.ts +76 -0
- package/templates/postgres/backend/alembic/env.py +55 -0
- package/templates/postgres/backend/alembic/script.py.mako +27 -0
- package/templates/postgres/backend/alembic/versions/0001_create_user_table.py +38 -0
- package/templates/postgres/backend/alembic.ini +42 -0
- package/templates/postgres/backend/app/core/database.py +15 -0
- package/templates/postgres/backend/app/models/__init__.py +5 -0
- package/templates/postgres/backend/app/models/user.py +15 -0
- package/templates/postgres/backend/app/queries/__init__.py +5 -0
- package/templates/postgres/backend/app/queries/users.py +18 -0
- package/templates/postgres/backend/app/routers/users.py +19 -0
- package/templates/postgres/backend/app/routers/users__id.py +20 -0
- package/templates/postgres/backend/app/tests/conftest.py +33 -0
- package/templates/postgres/backend/app/tests/models/test_user.py +12 -0
- package/templates/postgres/backend/app/tests/queries/test_users.py +12 -0
- package/templates/postgres/backend/app/tests/routers/test_users.py +10 -0
- package/templates/postgres/backend/app/tests/routers/test_users__id.py +9 -0
- package/templates/postgres/backend/start.sh +32 -0
- package/templates/postgres/frontend/src/openapi/utils/openapi.yaml.hbs +138 -0
- package/templates/postgres/frontend/src/pages/users/[id]/index.tsx +51 -0
- package/templates/postgres/frontend/src/pages/users/index.tsx +54 -0
- package/templates/postgres/frontend/src/pages/users/types.tsx +4 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "backend/app/schemas/**"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# BE003 — Schema class conventions
|
|
7
|
+
|
|
8
|
+
Every class in `backend/app/schemas/foo.py` must:
|
|
9
|
+
|
|
10
|
+
1. **Extend `BaseModel` or `SQLModel`** — only Pydantic/SQLModel schemas are allowed in `schemas/`.
|
|
11
|
+
2. **Be named with the PascalCase prefix** from the filename.
|
|
12
|
+
|
|
13
|
+
| File | Valid class names |
|
|
14
|
+
|------|------------------|
|
|
15
|
+
| `schemas/todo.py` | `Todo`, `TodoCreate`, `TodoUpdate`, `TodoRead` |
|
|
16
|
+
| `schemas/user_profile.py` | `UserProfile`, `UserProfileCreate`, … |
|
|
17
|
+
|
|
18
|
+
Helper classes (enums, mixins) belong in `utils/`, not in `schemas/`.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "backend/app/routers/**"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# BE004 — Router definition
|
|
7
|
+
|
|
8
|
+
Every file in `backend/app/routers/` (except `__init__.py`) must define a module-level router:
|
|
9
|
+
|
|
10
|
+
```python
|
|
11
|
+
router = APIRouter(...)
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
The variable must be named `router` exactly.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "backend/app/main.py"
|
|
4
|
+
- "backend/app/routers/**"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# BE005 — Router registration in `main.py`
|
|
8
|
+
|
|
9
|
+
`backend/app/main.py` must import and register **every** module in `routers/` — and **only** those modules.
|
|
10
|
+
|
|
11
|
+
- Import form: `from app.routers import foo, bar`
|
|
12
|
+
- Registration form: `app.include_router(foo.router, ...)`
|
|
13
|
+
|
|
14
|
+
Adding a router file → update `main.py` in the same PR.
|
|
15
|
+
Removing a router file → remove its import and `include_router` call.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "backend/app/routers/**"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# BE006 — Router filename convention
|
|
7
|
+
|
|
8
|
+
Router filenames must follow: `{resource}[_{sub}][__{param}].py`
|
|
9
|
+
|
|
10
|
+
- Segments are **lowercase alphanumeric**, separated by `_` (sub-resource) or `__` (path parameter).
|
|
11
|
+
|
|
12
|
+
| Filename | Maps to path prefix |
|
|
13
|
+
|----------|---------------------|
|
|
14
|
+
| `todos.py` | `/todos` |
|
|
15
|
+
| `todos__id.py` | `/todos/{id}` |
|
|
16
|
+
| `users_me.py` | `/users/me` |
|
|
17
|
+
| `keycloak_token.py` | `/keycloak/token` |
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "backend/app/routers/**"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# BE007 — Router file contents & path consistency
|
|
7
|
+
|
|
8
|
+
A router file may contain **only** `@router.METHOD`-decorated async functions. No helpers, no classes, no utilities — put those in `utils/`.
|
|
9
|
+
|
|
10
|
+
Each route's path must match the path derived from the filename (BE006 rules):
|
|
11
|
+
|
|
12
|
+
```python
|
|
13
|
+
# File: routers/todos__id.py → expected prefix: /todos/{id}
|
|
14
|
+
@router.get("/{id}") # ✓
|
|
15
|
+
@router.get("/todos/{id}") # ✗ — prefix is set by include_router in main.py
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Path derivation:
|
|
19
|
+
- `__param` → `/{param}` (path parameter)
|
|
20
|
+
- `_segment` → `/segment` (literal segment)
|
|
21
|
+
- All functions in the file share this base prefix.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "backend/app/**"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# BE008 — 1-to-1 test coverage
|
|
7
|
+
|
|
8
|
+
Every source file in `models/`, `queries/`, `routers/`, `tasks/`, `utils/` must have a corresponding test file, and vice-versa.
|
|
9
|
+
|
|
10
|
+
| Source | Expected test |
|
|
11
|
+
|--------|---------------|
|
|
12
|
+
| `models/todo.py` | `tests/models/test_todo.py` |
|
|
13
|
+
| `routers/todos.py` | `tests/routers/test_todos.py` |
|
|
14
|
+
| `tasks/example.py` | `tests/tasks/test_example.py` |
|
|
15
|
+
|
|
16
|
+
- **Warning**: source exists, test is missing → add the test.
|
|
17
|
+
- **Error**: test exists, source is missing → orphaned test; remove it or create the source.
|
|
18
|
+
|
|
19
|
+
Adding a source file → create the test file in the same PR.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "backend/**"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# BE009 — Centralised environment variables
|
|
7
|
+
|
|
8
|
+
All env vars must be read **exclusively** in `backend/app/core/config.py` via a `BaseSettings` subclass. Using `os.getenv` or `os.environ` anywhere else is an error.
|
|
9
|
+
|
|
10
|
+
```python
|
|
11
|
+
# core/config.py — correct
|
|
12
|
+
class Settings(BaseSettings):
|
|
13
|
+
DATABASE_URL: str
|
|
14
|
+
SECRET_KEY: str
|
|
15
|
+
|
|
16
|
+
settings = Settings()
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
# routers/todos.py — wrong
|
|
21
|
+
import os
|
|
22
|
+
db_url = os.getenv("DATABASE_URL") # BE009 error
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**Additional rule**: fields in `Settings` must be declared in **alphabetical order**.
|
|
26
|
+
|
|
27
|
+
To add an env var: add it to `Settings` in `core/config.py`, then reference it as `settings.MY_VAR`.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "backend/app/models/**"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# BE010 — One model class per file
|
|
7
|
+
|
|
8
|
+
Each file in `backend/app/models/` must define **exactly one** class, named after the file (snake_case → PascalCase).
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
models/todo.py → class Todo ✓
|
|
12
|
+
models/todo.py → class Todo, Meta ✗ BE010 — two classes
|
|
13
|
+
models/todo.py → class Task ✗ BE010 — wrong name
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
If you need helper types, put them in `schemas/` or `utils/`.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "backend/app/queries/**"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# BE011 — Query class naming
|
|
7
|
+
|
|
8
|
+
Every class in `backend/app/queries/foo.py` must be named with the PascalCase prefix derived from the filename. Multiple classes per file are allowed (one per operation is the norm).
|
|
9
|
+
|
|
10
|
+
| File | Valid class names |
|
|
11
|
+
|------|------------------|
|
|
12
|
+
| `queries/todos.py` | `Todos`, `TodosList`, `TodosCreate`, `TodosById`, … |
|
|
13
|
+
| `queries/users.py` | `Users`, `UsersMe`, `UsersDelete`, … |
|
|
14
|
+
|
|
15
|
+
A file with no classes at all is an error.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "e2e/features/**"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# ET001 — Feature file naming
|
|
7
|
+
|
|
8
|
+
Feature files must be `snake_case.feature`.
|
|
9
|
+
|
|
10
|
+
| Valid | Invalid |
|
|
11
|
+
|-------|---------|
|
|
12
|
+
| `user_login.feature` | `UserLogin.feature` |
|
|
13
|
+
| `todo_creation.feature` | `todoCreation.feature` |
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "e2e/**"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# ET002 — Feature → step definition pairing
|
|
7
|
+
|
|
8
|
+
Every `.feature` file must have a matching step definitions file:
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
e2e/features/user_login.feature → e2e/steps/user_login.steps.ts
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Adding a new user flow = create **both** files in the same PR.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "e2e/steps/**"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# ET003 — Step file → feature pairing (no orphans)
|
|
7
|
+
|
|
8
|
+
Every `*.steps.ts` file must have a matching `.feature` file. Exception: `common.steps.ts` is exempt (it holds shared steps).
|
|
9
|
+
|
|
10
|
+
An orphaned step file without a corresponding feature is an error.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "e2e/pages/**"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# ET004 — Page object naming
|
|
7
|
+
|
|
8
|
+
Page object files must follow the `*Page.ts` convention (PascalCase + `Page` suffix). The class name must match the filename.
|
|
9
|
+
|
|
10
|
+
| Valid | Invalid |
|
|
11
|
+
|-------|---------|
|
|
12
|
+
| `LoginPage.ts` | `login-page.ts` |
|
|
13
|
+
| `TodoDetailPage.ts` | `todoDetail.ts` |
|
|
14
|
+
|
|
15
|
+
One class per file.
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
// e2e/pages/LoginPage.ts
|
|
19
|
+
export class LoginPage {
|
|
20
|
+
constructor(private readonly page: Page) {}
|
|
21
|
+
// ...
|
|
22
|
+
}
|
|
23
|
+
```
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "e2e/steps/**"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# ET005 — Page object imports must resolve
|
|
7
|
+
|
|
8
|
+
Every page object imported in a step file must exist under `e2e/pages/`.
|
|
9
|
+
|
|
10
|
+
```typescript
|
|
11
|
+
// e2e/steps/user_login.steps.ts
|
|
12
|
+
import { LoginPage } from '../pages/LoginPage'; // → e2e/pages/LoginPage.ts must exist
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
If the file is absent, that is an error.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "e2e/**"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# ET006 — Required e2e config files
|
|
7
|
+
|
|
8
|
+
The following files must be present in `e2e/`:
|
|
9
|
+
|
|
10
|
+
| File | Purpose |
|
|
11
|
+
|------|---------|
|
|
12
|
+
| `playwright.config.ts` | Playwright configuration |
|
|
13
|
+
| `cucumber.js` | Cucumber runner configuration |
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "e2e/steps/**"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# ET007 — No hardcoded URLs
|
|
7
|
+
|
|
8
|
+
Step files must not contain `http://` or `https://` literals. Always use `this.baseUrl` from `CustomWorld`:
|
|
9
|
+
|
|
10
|
+
```typescript
|
|
11
|
+
// Wrong
|
|
12
|
+
await this.page.goto("http://localhost:5173/todos");
|
|
13
|
+
|
|
14
|
+
// Correct
|
|
15
|
+
await this.page.goto(`${this.baseUrl}/todos`);
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
`this.baseUrl` is set once in `CustomWorld` from the environment; step files must never assume a specific host or port.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "frontend/src/**/$components/**"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# FE001 — Component directory naming
|
|
7
|
+
|
|
8
|
+
Every direct child directory of any `$components/` folder (top-level, page-local, or nested inside another component) must be PascalCase: `^[A-Z][a-zA-Z0-9]+$`.
|
|
9
|
+
|
|
10
|
+
| Valid | Invalid |
|
|
11
|
+
|-------|---------|
|
|
12
|
+
| `UserCard/` | `userCard/` |
|
|
13
|
+
| `TodoTable/` | `todo-table/` |
|
|
14
|
+
|
|
15
|
+
Privileged `$`-folders (`$assets`, `$hooks`, `$misc`, …) are **not** allowed directly inside a `$components/` folder — they belong **inside** a component directory:
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
$components/
|
|
19
|
+
$assets/ ← FE001 error (no owner)
|
|
20
|
+
UserCard/
|
|
21
|
+
$assets/ ✅ owned by UserCard
|
|
22
|
+
```
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "frontend/src/**/$components/**"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# FE002 — Allowed contents of a component directory
|
|
7
|
+
|
|
8
|
+
A component directory may contain **only**:
|
|
9
|
+
|
|
10
|
+
| Item | Required? |
|
|
11
|
+
|------|-----------|
|
|
12
|
+
| `index.tsx` | **Mandatory** (error if missing) |
|
|
13
|
+
| `styles.module.css` | Optional |
|
|
14
|
+
| `types.tsx` | Optional |
|
|
15
|
+
| `constants.tsx` | Optional |
|
|
16
|
+
| `functions.tsx` | Optional |
|
|
17
|
+
| `$components/` | Optional — nested sub-components (same rules apply recursively) |
|
|
18
|
+
| `$hooks/` | Optional — hooks used only by this component |
|
|
19
|
+
| `$assets/` | Optional — static files used only by this component |
|
|
20
|
+
| `$misc/` | Escape hatch — always warned (FE011) |
|
|
21
|
+
|
|
22
|
+
Any other file or subdirectory is an error.
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
UserCard/
|
|
26
|
+
index.tsx
|
|
27
|
+
styles.module.css
|
|
28
|
+
constants.tsx
|
|
29
|
+
$components/
|
|
30
|
+
Avatar/
|
|
31
|
+
index.tsx
|
|
32
|
+
$assets/
|
|
33
|
+
placeholder.png
|
|
34
|
+
|
|
35
|
+
UserCard/
|
|
36
|
+
index.tsx
|
|
37
|
+
utils.ts ← FE002 error → move to functions.tsx
|
|
38
|
+
components/ ← FE002 error → use $components/
|
|
39
|
+
```
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "frontend/src/**/$components/**"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# FE003 — $components barrel file
|
|
7
|
+
|
|
8
|
+
Every `$components/` folder that contains at least one component must have an `index.tsx` barrel that re-exports **all** PascalCase child directories:
|
|
9
|
+
|
|
10
|
+
```tsx
|
|
11
|
+
export { default as TodoTable } from './TodoTable'
|
|
12
|
+
export { default as UserCard } from './UserCard'
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
- One `export { default as X }` line per component, no other code.
|
|
16
|
+
- Keep entries in alphabetical order.
|
|
17
|
+
- A missing barrel is an error; a missing export is an error.
|
|
18
|
+
- **Adding a new component = add its export to the barrel in the same PR.**
|
|
19
|
+
- Applies at every nesting level (matrioska): a `$components/` inside `UserCard/` needs its own barrel.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "frontend/src/App.tsx"
|
|
4
|
+
- "frontend/src/pages/**"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# FE004 — Route ↔ page node 1-to-1
|
|
8
|
+
|
|
9
|
+
A **page node** is any directory under `frontend/src/pages/` (including the root) whose `index.tsx` renders a route. Every `@/pages/...` import in `App.tsx` must have a matching page node, and vice-versa.
|
|
10
|
+
|
|
11
|
+
| Import in App.tsx | Page node on disk |
|
|
12
|
+
|-------------------|-------------------|
|
|
13
|
+
| `@/pages` | `pages/index.tsx` |
|
|
14
|
+
| `@/pages/users` | `pages/users/index.tsx` |
|
|
15
|
+
| `@/pages/users/[id]` | `pages/users/[id]/index.tsx` |
|
|
16
|
+
|
|
17
|
+
- **Error**: `App.tsx` imports a page whose `index.tsx` does not exist on disk.
|
|
18
|
+
- **Warning**: a page node exists but is not imported in `App.tsx`.
|
|
19
|
+
- `$`-prefixed folders (`$components/`, `$hooks/`, …) are structural — they are never route segments.
|
|
20
|
+
|
|
21
|
+
Adding a new page → create the directory **and** add the import + `<Route>` in `App.tsx` in the same PR. A `[param]` directory maps to a `:param` route path (`pages/users/[id]` → `<Route path="/users/:id">`).
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "frontend/src/pages/**"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# FE005 — Page directory structure and route naming
|
|
7
|
+
|
|
8
|
+
Every page directory (including `pages/` itself) may contain **only**:
|
|
9
|
+
|
|
10
|
+
| Item | Meaning |
|
|
11
|
+
|------|---------|
|
|
12
|
+
| `index.tsx` | The page component (route leaf) |
|
|
13
|
+
| `styles.module.css`, `types.tsx`, `constants.tsx`, `functions.tsx` | Page-scoped files |
|
|
14
|
+
| `$components/` | Page-local components |
|
|
15
|
+
| `$hooks/` | Page-local hooks |
|
|
16
|
+
| `$assets/` | Page-local static files |
|
|
17
|
+
| `$misc/` | Escape hatch — always warned (FE011) |
|
|
18
|
+
| any other directory | A **route segment** |
|
|
19
|
+
|
|
20
|
+
Route segments must be **kebab-case** (`user-settings`) or a **dynamic param** in brackets (`[id]`, `[userId]`); anything else is an error. The names `components`, `hooks`, `assets`, `misc` are reserved (error) — use the `$`-prefixed folder instead. That is exactly why the `$` prefix exists: a privileged folder can never be confused with a piece of the route path.
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
pages/
|
|
24
|
+
index.tsx → route "/"
|
|
25
|
+
users/
|
|
26
|
+
index.tsx → route "/users"
|
|
27
|
+
$components/
|
|
28
|
+
UserTable/index.tsx (not a route — structural)
|
|
29
|
+
[id]/
|
|
30
|
+
index.tsx → route "/users/:id"
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
A route directory with no `index.tsx` and no nested route is warned (dead directory). Arbitrary files (`helpers.ts`, …) are an error — put shared logic in `functions.tsx` or `frontend/src/utils/`.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "frontend/src/**/$hooks/**"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# FE006 — Hook directory naming and contents
|
|
7
|
+
|
|
8
|
+
Direct children of any `$hooks/` folder must be hook directories matching `^use[A-Z][a-zA-Z0-9]*$`.
|
|
9
|
+
|
|
10
|
+
| Valid | Invalid |
|
|
11
|
+
|-------|---------|
|
|
12
|
+
| `useAttachments/` | `useattachments/` |
|
|
13
|
+
| `useTodoList/` | `todo-list/` |
|
|
14
|
+
|
|
15
|
+
A hook directory may contain **only**:
|
|
16
|
+
|
|
17
|
+
| Item | Required? |
|
|
18
|
+
|------|-----------|
|
|
19
|
+
| `index.tsx` | **Mandatory** (error if missing) |
|
|
20
|
+
| `styles.module.css`, `types.tsx`, `constants.tsx`, `functions.tsx` | Optional |
|
|
21
|
+
| `$assets/` | Optional |
|
|
22
|
+
| `$misc/` | Escape hatch — always warned (FE011) |
|
|
23
|
+
|
|
24
|
+
Any other file or directory (e.g. `$components/` — a hook should not own components) is an error. Privileged folders are not allowed directly inside `$hooks/` (they belong inside a hook directory). `$hooks/` folders exist at the top level (`src/$hooks/`) and locally inside components and pages.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "frontend/src/**/$hooks/**"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# FE007 — $hooks barrel file
|
|
7
|
+
|
|
8
|
+
Every `$hooks/` folder that contains at least one hook must have an `index.tsx` barrel that re-exports **all** `use*` directories:
|
|
9
|
+
|
|
10
|
+
```tsx
|
|
11
|
+
export { default as useCounterStore } from './useCounterStore'
|
|
12
|
+
export { default as usePageTitle } from './usePageTitle'
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
- The alias name must exactly match the directory name.
|
|
16
|
+
- A missing barrel is an error; a missing export is an error.
|
|
17
|
+
- **Adding a new hook = update the barrel in the same PR.**
|
|
18
|
+
- No named re-exports, no `export *`, no JSX.
|
|
19
|
+
- Applies to every `$hooks/` folder, including page-local and component-local ones.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "frontend/src/**"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# FE008 — Static assets live in $assets/ folders
|
|
7
|
+
|
|
8
|
+
Static assets never float around the tree: each one lives in the `$assets/` folder of the scope that uses it (component, hook, page, or utils domain).
|
|
9
|
+
|
|
10
|
+
**Covered extensions:** `.svg` `.png` `.jpg` `.jpeg` `.gif` `.webp` `.avif` `.ico` `.pdf` `.json` `.txt` `.csv` `.mp4` `.webm` `.mp3` `.wav` `.ogg` `.woff` `.woff2` `.ttf` `.otf` `.eot`
|
|
11
|
+
|
|
12
|
+
Rules:
|
|
13
|
+
|
|
14
|
+
1. **An asset outside a `$assets/` folder is an error.**
|
|
15
|
+
2. **`$assets/` may only contain assets** — files with no code in them (images, fonts, media, documents, data). A `.ts`/`.tsx`/`.css` file inside `$assets/` is an error.
|
|
16
|
+
3. **Naming**: asset filenames are kebab-case with a lowercase extension — `user-guide.pdf`, `logo-dark.svg`, `empty-state.png` (warning otherwise). Subdirectories inside `$assets/` are kebab-case too.
|
|
17
|
+
|
|
18
|
+
```tsx
|
|
19
|
+
// ✅ correct — asset owned by the component that uses it
|
|
20
|
+
import logo from './$assets/logo.svg'
|
|
21
|
+
|
|
22
|
+
// ❌ wrong — asset dropped next to the code
|
|
23
|
+
import logo from './Logo.svg'
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
If an asset is shared by several scopes, attach it to their closest common ancestor scope (e.g. the page's `$assets/` when two page-local components use it).
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "frontend/src/utils/**"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# FE009 — Utils domain structure
|
|
7
|
+
|
|
8
|
+
`frontend/src/utils/` is organised in **domains**: one kebab-case directory per topic, each with the same scope files as any other structured directory.
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
utils/
|
|
12
|
+
index.tsx ← barrel re-exporting the root modules + domains
|
|
13
|
+
constants.tsx ← app-wide constants
|
|
14
|
+
functions.tsx ← generic helpers
|
|
15
|
+
formatters/ ← a domain
|
|
16
|
+
index.tsx ← mandatory public surface of the domain
|
|
17
|
+
types.tsx
|
|
18
|
+
$assets/
|
|
19
|
+
$misc/ ← escape hatch — always warned (FE011)
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Rules:
|
|
23
|
+
|
|
24
|
+
- **Domain naming**: kebab-case (`date-helpers`, `formatters`) — error otherwise.
|
|
25
|
+
- **Every domain has an `index.tsx`** (its public surface) — error if missing.
|
|
26
|
+
- Allowed files in `utils/` and in each domain: `index.tsx`, `styles.module.css`, `types.tsx`, `constants.tsx`, `functions.tsx` (error otherwise).
|
|
27
|
+
- Allowed directories: nested domains, `$assets/`, `$misc/`. No `$components/` or `$hooks/` in utils — anything rendering or stateful is not a util.
|
|
28
|
+
- Domains may nest (matrioska): `utils/dates/parsing/index.tsx` is fine.
|
|
29
|
+
|
|
30
|
+
To add a new util: pick (or create) the domain, implement in the domain's `functions.tsx`, re-export from its `index.tsx`.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "frontend/src/**"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# FE010 — src root layout and $types
|
|
7
|
+
|
|
8
|
+
The root of `frontend/src/` is fixed:
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
src/
|
|
12
|
+
App.tsx ← routes + providers
|
|
13
|
+
main.tsx ← entry point
|
|
14
|
+
styles.module.css ← global styles (use :global(...) selectors)
|
|
15
|
+
$types/ ← ALL *.d.ts ambient declarations (e.g. vite-env.d.ts)
|
|
16
|
+
$components/ ← shared components
|
|
17
|
+
$hooks/ ← shared hooks (incl. zustand stores)
|
|
18
|
+
openapi/ ← generated API client (dude api sync)
|
|
19
|
+
pages/ ← route tree
|
|
20
|
+
utils/ ← pure helpers, by domain
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
- Legacy entries are **errors** with a migration hint: `components/` → `$components/`, `hooks/` → `$hooks/`, `assets/` → per-scope `$assets/`, `index.css` → `styles.module.css`, `vite-env.d.ts` → `$types/vite-env.d.ts`.
|
|
24
|
+
- Any other file/directory at the src root is an error.
|
|
25
|
+
- `$types/` may **only** contain `*.d.ts` files, and every `*.d.ts` under `src/` must live there (both errors).
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "frontend/src/**"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# FE011 — $misc is a temporary escape hatch
|
|
7
|
+
|
|
8
|
+
Any scope (component, hook, page, utils domain) may contain a `$misc/` folder. Its content is **exempt from all structure checks** — when you genuinely don't know where something belongs yet, park it there instead of violating the structure.
|
|
9
|
+
|
|
10
|
+
But every `$misc/` raises a **warning**, always. Treat it as a to-do: empty it as soon as you know better.
|
|
11
|
+
|
|
12
|
+
| What's in $misc | Where it belongs |
|
|
13
|
+
|-----------------|------------------|
|
|
14
|
+
| A component | Its own directory under the scope's `$components/` |
|
|
15
|
+
| A hook / store | Its own directory under a `$hooks/` |
|
|
16
|
+
| Shared types | The scope's `types.tsx` |
|
|
17
|
+
| Pure functions | The scope's `functions.tsx` |
|
|
18
|
+
| Constants | The scope's `constants.tsx` |
|
|
19
|
+
| Static files | The scope's `$assets/` |
|
|
20
|
+
| Cross-cutting helpers | A domain in `frontend/src/utils/` |
|
|
21
|
+
|
|
22
|
+
Never let `$misc/` accumulate: the warning stays until the folder is gone.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "frontend/src/**"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# FE012 — index.tsx hygiene
|
|
7
|
+
|
|
8
|
+
The `index.tsx` of a component, hook, or page should contain **that one thing** and nothing else. Everything else has a canonical home in the same scope, and FE012 warns until it is moved there:
|
|
9
|
+
|
|
10
|
+
| Found in index.tsx | Move it to |
|
|
11
|
+
|--------------------|-----------|
|
|
12
|
+
| `interface` / `type` declarations | `types.tsx` |
|
|
13
|
+
| A second component | Its own directory under `$components/` |
|
|
14
|
+
| A `use*` hook (in a component/page) | Its own directory under `$hooks/` |
|
|
15
|
+
| A component (in a hook) | A `$components/` scope — hooks must not render |
|
|
16
|
+
| Top-level helper functions / arrow consts | `functions.tsx` |
|
|
17
|
+
|
|
18
|
+
```tsx
|
|
19
|
+
// ❌ pages/users/index.tsx
|
|
20
|
+
interface Row { … } // → types.tsx
|
|
21
|
+
const toLabel = (u: User) => … // → functions.tsx
|
|
22
|
+
function UserBadge() { … } // → $components/UserBadge/
|
|
23
|
+
export default function UsersPage() { … }
|
|
24
|
+
|
|
25
|
+
// ✅ pages/users/index.tsx
|
|
26
|
+
import type { Row } from './types'
|
|
27
|
+
import { toLabel } from './functions'
|
|
28
|
+
import { UserBadge } from './$components'
|
|
29
|
+
export default function UsersPage() { … }
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Only **top-level** declarations count — helpers defined inside the component body are fine. The check is heuristic and warning-only, but keeping `index.tsx` thin is what makes the matrioska structure navigable.
|