docs: add TPL-008 rule and update architecture rules documentation
- Document TPL-008 (valid block names) rule - Add common block name mistakes to quick reference - Update statistics: 58 rules total (was 57) - Update version to 2.4 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -661,6 +661,36 @@ Show empty state when lists have no items.
|
||||
</template>
|
||||
```
|
||||
|
||||
#### TPL-008: Use Valid Block Names
|
||||
**Severity:** Error
|
||||
|
||||
Templates must use block names that exist in their base template. Using undefined blocks silently fails (content is not rendered).
|
||||
|
||||
**Valid Admin Template Blocks:**
|
||||
- `title` - Page title
|
||||
- `extra_head` - Additional head content (CSS, meta tags)
|
||||
- `alpine_data` - Alpine.js component function name
|
||||
- `content` - Main page content
|
||||
- `extra_scripts` - Additional JavaScript
|
||||
|
||||
```jinja
|
||||
{# ✅ Good - Valid block names #}
|
||||
{% block extra_scripts %}
|
||||
<script src="/static/admin/js/dashboard.js"></script>
|
||||
{% endblock %}
|
||||
|
||||
{# ❌ Bad - Invalid block name (silently ignored!) #}
|
||||
{% block page_scripts %}
|
||||
<script src="/static/admin/js/dashboard.js"></script>
|
||||
{% endblock %}
|
||||
```
|
||||
|
||||
**Common mistakes detected:**
|
||||
- `page_scripts` → use `extra_scripts`
|
||||
- `scripts` → use `extra_scripts`
|
||||
- `js` → use `extra_scripts`
|
||||
- `head` → use `extra_head`
|
||||
|
||||
---
|
||||
|
||||
### Jinja Macro Rules (app/templates/**/*.html)
|
||||
@@ -969,6 +999,8 @@ Before committing code:
|
||||
| Business logic in endpoint | Move to service layer |
|
||||
| console.log in JS | Use `window.LogConfig.createLogger()` |
|
||||
| Missing ...data() | Add spread operator in component return |
|
||||
| Missing currentPage | Add `currentPage: 'page-name'` in component return |
|
||||
| Invalid block name | Use valid block: `extra_scripts`, `extra_head`, etc. |
|
||||
| Bare except clause | Specify exception type |
|
||||
| Raw dict return | Create Pydantic response model |
|
||||
| Template not extending base | Add `{% extends %}` or `{# standalone #}` marker |
|
||||
@@ -1002,16 +1034,16 @@ All rules are defined in `.architecture-rules.yaml`. To modify rules:
|
||||
|----------|-------|--------|----------|
|
||||
| Backend | 20 | 15 | 5 |
|
||||
| Frontend JS | 7 | 6 | 1 |
|
||||
| Frontend Templates | 7 | 3 | 4 |
|
||||
| Frontend Templates | 8 | 4 | 4 |
|
||||
| Frontend Macros | 5 | 2 | 3 |
|
||||
| Frontend Components | 1 | 0 | 1 |
|
||||
| Frontend Styling | 4 | 1 | 3 |
|
||||
| Naming | 5 | 3 | 2 |
|
||||
| Security | 5 | 5 | 0 |
|
||||
| Quality | 3 | 2 | 1 |
|
||||
| **Total** | **57** | **37** | **20** |
|
||||
| **Total** | **58** | **38** | **20** |
|
||||
|
||||
---
|
||||
|
||||
**Last Updated:** 2025-12-07
|
||||
**Version:** 2.3
|
||||
**Last Updated:** 2025-12-21
|
||||
**Version:** 2.4
|
||||
|
||||
Reference in New Issue
Block a user