fix: add TPL-011 rule for deprecated macros, fix billing-history pagination
- Add TPL-011 architecture rule to detect deprecated macros - Add pagination_full to deprecated macros list (expects flat vars) - Fix billing-history.html to use standard pagination macro - Add deprecation notice to pagination_full macro in pagination.html 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
{% from 'shared/macros/alerts.html' import alert_dynamic, error_state %}
|
||||
{% from 'shared/macros/headers.html' import page_header_refresh %}
|
||||
{% from 'shared/macros/tables.html' import table_wrapper, table_header_custom, th_sortable %}
|
||||
{% from 'shared/macros/pagination.html' import pagination_full %}
|
||||
{% from 'shared/macros/pagination.html' import pagination %}
|
||||
|
||||
{% block title %}Billing History{% endblock %}
|
||||
|
||||
@@ -198,7 +198,7 @@
|
||||
{% endcall %}
|
||||
|
||||
<!-- Pagination -->
|
||||
{{ pagination_full() }}
|
||||
{{ pagination(show_condition="!loading && pagination.total > 0") }}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
||||
@@ -96,11 +96,17 @@
|
||||
{#
|
||||
Pagination Full Macro (First/Prev/Numbers/Next/Last)
|
||||
=====================================================
|
||||
A full pagination component with first, previous, page numbers, next, and last buttons.
|
||||
⚠️ DEPRECATED: Use the standard 'pagination' macro instead.
|
||||
|
||||
Usage:
|
||||
{% from 'shared/macros/pagination.html' import pagination_full %}
|
||||
{{ pagination_full() }}
|
||||
This macro expects flat variables (total, skip, page, limit) but our Alpine.js
|
||||
components use nested pagination objects (pagination.total, pagination.page, etc.).
|
||||
|
||||
Use:
|
||||
{% from 'shared/macros/pagination.html' import pagination %}
|
||||
{{ pagination(show_condition="!loading && pagination.total > 0") }}
|
||||
|
||||
---
|
||||
Legacy documentation (for reference only):
|
||||
|
||||
Required Alpine.js data properties:
|
||||
- page: Current page number
|
||||
|
||||
@@ -1135,6 +1135,37 @@ class ArchitectureValidator:
|
||||
suggestion=f"Use '{{% block {invalid_blocks[block_name]} %}}' instead",
|
||||
)
|
||||
|
||||
def _check_deprecated_macros(
|
||||
self, file_path: Path, content: str, lines: list[str]
|
||||
):
|
||||
"""TPL-011: Check for usage of deprecated macros"""
|
||||
if "noqa: tpl-011" in content.lower():
|
||||
return
|
||||
|
||||
# Deprecated macros and their replacements
|
||||
deprecated_macros = {
|
||||
"pagination_full": {
|
||||
"replacement": "pagination",
|
||||
"reason": "pagination_full expects flat variables (total, skip, page, limit) but components use nested pagination object",
|
||||
},
|
||||
}
|
||||
|
||||
for i, line in enumerate(lines, 1):
|
||||
for macro_name, info in deprecated_macros.items():
|
||||
if macro_name in line and "# deprecated" not in line.lower():
|
||||
# Check if it's an import or usage
|
||||
if f"import {macro_name}" in line or f"{{ {macro_name}" in line or f"{{{macro_name}" in line:
|
||||
self._add_violation(
|
||||
rule_id="TPL-011",
|
||||
rule_name="Avoid deprecated macros",
|
||||
severity=Severity.WARNING,
|
||||
file_path=file_path,
|
||||
line_number=i,
|
||||
message=f"Deprecated macro '{macro_name}' used - {info['reason']}",
|
||||
context=line.strip()[:80],
|
||||
suggestion=f"Use '{info['replacement']}' macro instead",
|
||||
)
|
||||
|
||||
def _check_alpine_template_vars(
|
||||
self, file_path: Path, content: str, lines: list[str], js_content: str
|
||||
):
|
||||
@@ -2995,6 +3026,9 @@ class ArchitectureValidator:
|
||||
js_content = js_file.read_text()
|
||||
self._check_alpine_template_vars(file_path, content, lines, js_content)
|
||||
|
||||
# TPL-011: Check for deprecated macros
|
||||
self._check_deprecated_macros(file_path, content, lines)
|
||||
|
||||
# Skip base/partials for TPL-001 check
|
||||
if is_base_or_partial:
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user