@cubocicloide/stack-react-django 3.0.4
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 +94 -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 +136 -0
- package/dist/commands/lint/checks/BE/002.js.map +1 -0
- package/dist/commands/lint/checks/BE/003.d.ts +6 -0
- package/dist/commands/lint/checks/BE/003.js +89 -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 +68 -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 +55 -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 +95 -0
- package/dist/commands/lint/checks/BE/006.js.map +1 -0
- package/dist/commands/lint/checks/BE/007.d.ts +6 -0
- package/dist/commands/lint/checks/BE/007.js +53 -0
- package/dist/commands/lint/checks/BE/007.js.map +1 -0
- package/dist/commands/lint/checks/BE/008.d.ts +6 -0
- package/dist/commands/lint/checks/BE/008.js +70 -0
- package/dist/commands/lint/checks/BE/008.js.map +1 -0
- package/dist/commands/lint/checks/BE/009.d.ts +6 -0
- package/dist/commands/lint/checks/BE/009.js +112 -0
- package/dist/commands/lint/checks/BE/009.js.map +1 -0
- package/dist/commands/lint/checks/BE/010.d.ts +6 -0
- package/dist/commands/lint/checks/BE/010.js +76 -0
- package/dist/commands/lint/checks/BE/010.js.map +1 -0
- package/dist/commands/lint/checks/BE/011.d.ts +6 -0
- package/dist/commands/lint/checks/BE/011.js +76 -0
- package/dist/commands/lint/checks/BE/011.js.map +1 -0
- package/dist/commands/lint/checks/BE/012.d.ts +6 -0
- package/dist/commands/lint/checks/BE/012.js +61 -0
- package/dist/commands/lint/checks/BE/012.js.map +1 -0
- package/dist/commands/lint/checks/BE/013.d.ts +6 -0
- package/dist/commands/lint/checks/BE/013.js +98 -0
- package/dist/commands/lint/checks/BE/013.js.map +1 -0
- package/dist/commands/lint/checks/BE/014.d.ts +6 -0
- package/dist/commands/lint/checks/BE/014.js +64 -0
- package/dist/commands/lint/checks/BE/014.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 +3436 -0
- package/dist/index.js.map +1 -0
- package/dude.stack.json +13 -0
- package/package.json +43 -0
- package/templates/aws-ecs/backend/Dockerfile.prod +34 -0
- package/templates/aws-ecs/docs/docs/deploy.md.hbs +54 -0
- package/templates/aws-ecs/frontend/Dockerfile.prod +28 -0
- package/templates/aws-ecs/frontend/nginx.conf +21 -0
- package/templates/aws-ecs/iac/README.md.hbs +75 -0
- package/templates/aws-ecs/iac/_gitignore +14 -0
- package/templates/aws-ecs/iac/runner/Dockerfile +35 -0
- package/templates/aws-ecs/iac/terraform/bootstrap/main.tf.hbs +102 -0
- package/templates/aws-ecs/iac/terraform/bootstrap/outputs.tf +19 -0
- package/templates/aws-ecs/iac/terraform/bootstrap/variables.tf.hbs +17 -0
- package/templates/aws-ecs/iac/terraform/environments/dev/backend.hcl.hbs +12 -0
- package/templates/aws-ecs/iac/terraform/environments/dev/terraform.tfvars.hbs +43 -0
- package/templates/aws-ecs/iac/terraform/main.tf.hbs +949 -0
- package/templates/aws-ecs/iac/terraform/outputs.tf.hbs +71 -0
- package/templates/aws-ecs/iac/terraform/providers.tf +19 -0
- package/templates/aws-ecs/iac/terraform/variables.tf.hbs +113 -0
- package/templates/aws-ecs/iac/terraform/versions.tf +19 -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 +19 -0
- package/templates/base/.claude/rules/BE/002.md +21 -0
- package/templates/base/.claude/rules/BE/003.md +19 -0
- package/templates/base/.claude/rules/BE/004.md +16 -0
- package/templates/base/.claude/rules/BE/005.md +23 -0
- package/templates/base/.claude/rules/BE/006.md +13 -0
- package/templates/base/.claude/rules/BE/007.md +24 -0
- package/templates/base/.claude/rules/BE/008.md +19 -0
- package/templates/base/.claude/rules/BE/009.md +18 -0
- package/templates/base/.claude/rules/BE/010.md +15 -0
- package/templates/base/.claude/rules/BE/011.md +17 -0
- package/templates/base/.claude/rules/BE/012.md +18 -0
- package/templates/base/.claude/rules/BE/013.md +22 -0
- package/templates/base/.claude/rules/BE/014.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 +156 -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 +391 -0
- package/templates/base/README.md.hbs +188 -0
- package/templates/base/_env.example.hbs +39 -0
- package/templates/base/_env.hbs +35 -0
- package/templates/base/_gitignore +31 -0
- package/templates/base/_npmrc +2 -0
- package/templates/base/backend/Dockerfile +16 -0
- package/templates/base/backend/README.md.hbs +90 -0
- package/templates/base/backend/_dockerignore +12 -0
- package/templates/base/backend/apps/__init__.py +0 -0
- package/templates/base/backend/apps/core/__init__.py +0 -0
- package/templates/base/backend/apps/core/apps.py +6 -0
- package/templates/base/backend/apps/core/serializers.py +7 -0
- package/templates/base/backend/apps/core/tests/__init__.py +0 -0
- package/templates/base/backend/apps/core/tests/test_views.py +16 -0
- package/templates/base/backend/apps/core/urls.py +9 -0
- package/templates/base/backend/apps/core/views.py +24 -0
- package/templates/base/backend/apps/users/__init__.py +0 -0
- package/templates/base/backend/apps/users/admin.py +6 -0
- package/templates/base/backend/apps/users/apps.py +6 -0
- package/templates/base/backend/apps/users/migrations/0001_initial.py +41 -0
- package/templates/base/backend/apps/users/migrations/__init__.py +0 -0
- package/templates/base/backend/apps/users/models.py +15 -0
- package/templates/base/backend/apps/users/serializers.py +16 -0
- package/templates/base/backend/apps/users/services.py +25 -0
- package/templates/base/backend/apps/users/tests/__init__.py +0 -0
- package/templates/base/backend/apps/users/tests/test_models.py +30 -0
- package/templates/base/backend/apps/users/tests/test_views.py +55 -0
- package/templates/base/backend/apps/users/urls.py +10 -0
- package/templates/base/backend/apps/users/views.py +20 -0
- package/templates/base/backend/config/__init__.py.hbs +5 -0
- package/templates/base/backend/config/asgi.py +9 -0
- package/templates/base/backend/config/settings/__init__.py +0 -0
- package/templates/base/backend/config/settings/base.py.hbs +197 -0
- package/templates/base/backend/config/settings/local.py +31 -0
- package/templates/base/backend/config/settings/production.py.hbs +37 -0
- package/templates/base/backend/config/urls.py.hbs +22 -0
- package/templates/base/backend/config/wsgi.py +9 -0
- package/templates/base/backend/manage.py +23 -0
- package/templates/base/backend/pyproject.toml.hbs +48 -0
- package/templates/base/backend/start.sh +5 -0
- package/templates/base/docker-compose.yml.hbs +196 -0
- package/templates/base/docs/docs/api.md +21 -0
- package/templates/base/docs/docs/dude.md.hbs +305 -0
- package/templates/base/docs/docs/index.md.hbs +92 -0
- package/templates/base/docs/docs/mkdocs.md +231 -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 +8 -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 +36 -0
- package/templates/base/frontend/src/main.tsx +10 -0
- package/templates/base/frontend/src/openapi/utils/openapi.yaml.hbs +129 -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/pages/users/[id]/index.tsx +53 -0
- package/templates/base/frontend/src/pages/users/index.tsx +57 -0
- package/templates/base/frontend/src/pages/users/types.tsx +4 -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/apps/core/tasks.py +14 -0
- package/templates/celery/backend/apps/core/tests/test_tasks.py +6 -0
- package/templates/celery/backend/config/celery.py.hbs +26 -0
- package/templates/celerybeat/backend/apps/core/tasks_scheduled.py +18 -0
- package/templates/celerybeat/backend/apps/core/tests/test_tasks_scheduled.py +6 -0
- package/templates/postgres/.dude/commands/reset.ts +83 -0
- package/templates/s3/backend/apps/files/__init__.py +0 -0
- package/templates/s3/backend/apps/files/admin.py +9 -0
- package/templates/s3/backend/apps/files/apps.py +6 -0
- package/templates/s3/backend/apps/files/migrations/0001_initial.py +29 -0
- package/templates/s3/backend/apps/files/migrations/__init__.py +0 -0
- package/templates/s3/backend/apps/files/models.py +21 -0
- package/templates/s3/backend/apps/files/serializers.py +27 -0
- package/templates/s3/backend/apps/files/services.py +19 -0
- package/templates/s3/backend/apps/files/tests/__init__.py +0 -0
- package/templates/s3/backend/apps/files/tests/test_models.py +10 -0
- package/templates/s3/backend/apps/files/tests/test_views.py +32 -0
- package/templates/s3/backend/apps/files/urls.py +10 -0
- package/templates/s3/backend/apps/files/views.py +29 -0
- package/templates/s3/frontend/src/openapi/utils/openapi.yaml.hbs +253 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# BE002 — Explicit serializer fields (error)
|
|
2
|
+
|
|
3
|
+
`ModelSerializer.Meta` must list its fields explicitly. `fields = "__all__"` and `exclude = (...)` are forbidden: they silently expose every new model column — adding `password_reset_token` to the model would leak it through the API without any diff to the serializer.
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
# ✅
|
|
7
|
+
class UserSerializer(serializers.ModelSerializer):
|
|
8
|
+
class Meta:
|
|
9
|
+
model = User
|
|
10
|
+
fields = ("id", "username", "email")
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
# ❌
|
|
15
|
+
class UserSerializer(serializers.ModelSerializer):
|
|
16
|
+
class Meta:
|
|
17
|
+
model = User
|
|
18
|
+
fields = "__all__" # or: exclude = ("password",)
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**Fix**: enumerate exactly the fields the endpoint should expose.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# BE003 — Explicit permission_classes (error)
|
|
2
|
+
|
|
3
|
+
Every DRF view class (`APIView`, `GenericAPIView`, any `*ViewSet`, `generics.*`) must declare `permission_classes` in its body. Relying on the project-wide default hides the endpoint's real exposure from reviewers; the intent must be visible at the view.
|
|
4
|
+
|
|
5
|
+
The project default (`DEFAULT_PERMISSION_CLASSES = IsAuthenticated`) is a safety net, not a substitute for the declaration.
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
# ✅
|
|
9
|
+
class UserViewSet(ReadOnlyModelViewSet):
|
|
10
|
+
permission_classes = [IsAuthenticated]
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
# ❌ — who can call this? You can't tell from the code.
|
|
15
|
+
class UserViewSet(ReadOnlyModelViewSet):
|
|
16
|
+
queryset = User.objects.all()
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
**Fix**: add an explicit `permission_classes = [...]` to the view class.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# BE004 — No raw SQL (error)
|
|
2
|
+
|
|
3
|
+
`Model.objects.raw(...)`, `cursor.execute(...)`, `RawSQL(...)` and `connection.cursor()` are forbidden in application code. Raw SQL bypasses the ORM's parameter escaping (injection risk), model-layer validation, and database portability.
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
# ✅
|
|
7
|
+
User.objects.filter(is_active=True).order_by("-date_joined")
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
```python
|
|
11
|
+
# ❌
|
|
12
|
+
User.objects.raw("SELECT * FROM users WHERE active = 1")
|
|
13
|
+
cursor.execute(f"DELETE FROM users WHERE id = {user_id}")
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
**Fix**: express the query through the ORM (`filter`, `annotate`, `aggregate`, `Subquery`, …). If a query genuinely cannot be expressed with the ORM, isolate it and get it reviewed — do not scatter raw SQL through app code.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# BE005 — No ORM writes in views (error)
|
|
2
|
+
|
|
3
|
+
`views.py` must not perform write operations on the ORM (`objects.create/update_or_create/get_or_create/bulk_*`, queryset `.update(...)` / `.delete()`). Views orchestrate: they validate input via serializers and delegate writes to the app's `services.py` (or the serializer's `create`/`update`).
|
|
4
|
+
|
|
5
|
+
Keeping writes in one layer makes business rules testable without HTTP, reusable from Celery tasks and management commands, and keeps views trivially thin.
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
# ✅ views.py
|
|
9
|
+
class UserViewSet(ReadOnlyModelViewSet):
|
|
10
|
+
queryset = User.objects.all() # read-only queryset attr is fine
|
|
11
|
+
|
|
12
|
+
# ✅ services.py
|
|
13
|
+
def create_user(*, username: str, email: str) -> User:
|
|
14
|
+
return User.objects.create(username=username, email=email)
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
# ❌ views.py
|
|
19
|
+
def post(self, request):
|
|
20
|
+
User.objects.create(**request.data)
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**Fix**: move the write into `apps/<app>/services.py` (or the serializer) and call it from the view.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# BE006 — Models require migrations (error)
|
|
2
|
+
|
|
3
|
+
Every app whose `models.py` defines a model class must ship a `migrations/` package with at least one migration file. Un-migrated models mean the code and the database schema have silently diverged — the next `migrate` on a fresh environment breaks.
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
apps/users/
|
|
7
|
+
├── models.py # defines User
|
|
8
|
+
└── migrations/
|
|
9
|
+
├── __init__.py
|
|
10
|
+
└── 0001_initial.py # ✅ committed alongside the model
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
**Fix**: run `dude db makemigration --app <app>` (or `python manage.py makemigrations <app>`) and commit the generated file. Migrations are code — always committed, never regenerated on the fly in production.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# BE007 — Settings hygiene (error)
|
|
2
|
+
|
|
3
|
+
In every settings module except `local.py`:
|
|
4
|
+
|
|
5
|
+
1. `SECRET_KEY` must not be a hard-coded string literal — it comes from the environment (`env("DJANGO_SECRET_KEY")`). A committed secret is a leaked secret.
|
|
6
|
+
2. `DEBUG = True` must not appear — debug mode exposes stack traces, settings and SQL to the world. Only `local.py` (development) may enable it.
|
|
7
|
+
|
|
8
|
+
```python
|
|
9
|
+
# ✅ production.py
|
|
10
|
+
SECRET_KEY = env("DJANGO_SECRET_KEY") # required, no default
|
|
11
|
+
DEBUG = False
|
|
12
|
+
|
|
13
|
+
# ✅ local.py — development only
|
|
14
|
+
SECRET_KEY = env("DJANGO_SECRET_KEY", default="dev-insecure-key")
|
|
15
|
+
DEBUG = True
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
```python
|
|
19
|
+
# ❌ base.py / production.py
|
|
20
|
+
SECRET_KEY = "django-insecure-abc123"
|
|
21
|
+
DEBUG = True
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
**Fix**: read the value from the environment; keep permissive defaults confined to `local.py`.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# BE008 — URL structure (error)
|
|
2
|
+
|
|
3
|
+
Two invariants keep routing predictable:
|
|
4
|
+
|
|
5
|
+
1. Every `apps/<app>/urls.py` defines `app_name = "<app>"` — URL namespacing makes `reverse("users:users-list")` unambiguous as apps multiply.
|
|
6
|
+
2. `config/urls.py` mounts each app's URLconf under the `api/` prefix via `include("apps.<app>.urls")` — one place to see the whole API surface, and the ALB/edge router can path-route `/api/*` as a unit.
|
|
7
|
+
|
|
8
|
+
```python
|
|
9
|
+
# ✅ apps/users/urls.py
|
|
10
|
+
app_name = "users"
|
|
11
|
+
router = DefaultRouter()
|
|
12
|
+
router.register("users", UserViewSet, basename="users")
|
|
13
|
+
urlpatterns = router.urls
|
|
14
|
+
|
|
15
|
+
# ✅ config/urls.py
|
|
16
|
+
path("api/", include("apps.users.urls")),
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
**Fix**: add the missing `app_name` and/or the `include(...)` line in `config/urls.py`.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# BE009 — Model `__str__` and `Meta.ordering` (warning)
|
|
2
|
+
|
|
3
|
+
Every model should define:
|
|
4
|
+
|
|
5
|
+
- `__str__` — otherwise the admin, shell and logs show `User object (42)`.
|
|
6
|
+
- `Meta.ordering` — DRF's `PageNumberPagination` over an unordered queryset is non-deterministic: rows can repeat or vanish across pages.
|
|
7
|
+
|
|
8
|
+
```python
|
|
9
|
+
# ✅
|
|
10
|
+
class User(AbstractUser):
|
|
11
|
+
class Meta:
|
|
12
|
+
ordering = ("id",)
|
|
13
|
+
|
|
14
|
+
def __str__(self) -> str:
|
|
15
|
+
return self.username
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
**Fix**: add both members. Choose an ordering backed by an index (usually the pk or a timestamp).
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# BE010 — No `null=True` on Char/Text fields (warning)
|
|
2
|
+
|
|
3
|
+
`CharField`/`TextField` with `null=True` creates **two** "empty" states — `NULL` and `""` — so every consumer must check both. Django's convention: text-like fields are never nullable; use `blank=True` with `default=""`.
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
# ✅
|
|
7
|
+
nickname = models.CharField(max_length=50, blank=True, default="")
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
```python
|
|
11
|
+
# ❌
|
|
12
|
+
nickname = models.CharField(max_length=50, null=True)
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
**Fix**: drop `null=True`, add `blank=True, default=""`, and write a data migration normalising existing `NULL`s if the column already exists. (Exception: `unique=True` text columns that must allow multiple empties genuinely need `null=True` — document it with a comment.)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# BE011 — Explicit `related_name` on relations (warning)
|
|
2
|
+
|
|
3
|
+
`ForeignKey`, `OneToOneField` and `ManyToManyField` should pass an explicit `related_name`. The implicit `<model>_set` reverse accessor is brittle (renaming the model silently renames the accessor) and unreadable at call sites.
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
# ✅
|
|
7
|
+
owner = models.ForeignKey(User, on_delete=models.CASCADE, related_name="uploads")
|
|
8
|
+
# user.uploads.all()
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```python
|
|
12
|
+
# ❌
|
|
13
|
+
owner = models.ForeignKey(User, on_delete=models.CASCADE)
|
|
14
|
+
# user.fileupload_set.all() ← what is this?
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
**Fix**: name the reverse relation after what the collection *is* from the other side (use `related_name="+"` when the reverse accessor is intentionally unwanted).
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# BE012 — No `print()` — use logging (warning)
|
|
2
|
+
|
|
3
|
+
`print()` in app/config code bypasses log levels, formatting and routing. Containers forward stdout, but only the logging module gives you severity filtering, structured context and per-logger control (see `LOGGING` in `base.py`).
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
# ✅
|
|
7
|
+
import logging
|
|
8
|
+
|
|
9
|
+
logger = logging.getLogger(__name__)
|
|
10
|
+
logger.info("user created: %s", user.pk)
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
# ❌
|
|
15
|
+
print(f"user created: {user.pk}")
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Tests and migrations are exempt. **Fix**: swap for a module-level `logger`.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# BE013 — Typed OpenAPI schema (warning)
|
|
2
|
+
|
|
3
|
+
Every DRF view class must either declare `serializer_class` or carry a drf-spectacular `@extend_schema` / `@extend_schema_view` annotation. Without one, the endpoint appears untyped in `/api/schema/` — and the generated TypeScript client (`dude api sync`) degrades to `unknown` for that route.
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
# ✅ either of these
|
|
7
|
+
class UserViewSet(ReadOnlyModelViewSet):
|
|
8
|
+
serializer_class = UserSerializer
|
|
9
|
+
|
|
10
|
+
@extend_schema(responses=HealthSerializer, tags=["health"])
|
|
11
|
+
class HealthView(APIView):
|
|
12
|
+
...
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
# ❌ schema (and TS client) has no idea what this returns
|
|
17
|
+
class HealthView(APIView):
|
|
18
|
+
def get(self, request):
|
|
19
|
+
return Response({"status": "ok"})
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
**Fix**: set `serializer_class`, or annotate with `@extend_schema(request=..., responses=...)`. Then run `dude api sync`.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# BE014 — Every app ships tests (error)
|
|
2
|
+
|
|
3
|
+
Every Django app under `backend/apps/` must contain a `tests/` package (`__init__.py` included) with at least one `test_*.py` file. An app with zero tests has zero executable documentation of its behaviour — regressions land silently.
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
apps/users/
|
|
7
|
+
└── tests/
|
|
8
|
+
├── __init__.py
|
|
9
|
+
├── test_models.py # ✅ at least one test_*.py
|
|
10
|
+
└── test_views.py
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Convention: mirror the module you exercise (`test_models.py`, `test_views.py`, `test_services.py`). Use `pytest.mark.django_db` for DB access and DRF's `APIClient` for endpoint tests.
|
|
14
|
+
|
|
15
|
+
**Fix**: create `tests/__init__.py` and a first real test — the health/users apps in this scaffold show the pattern.
|
|
@@ -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).
|