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/alerts.html' import alert_dynamic, error_state %}
|
||||||
{% from 'shared/macros/headers.html' import page_header_refresh %}
|
{% 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/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 %}
|
{% block title %}Billing History{% endblock %}
|
||||||
|
|
||||||
@@ -198,7 +198,7 @@
|
|||||||
{% endcall %}
|
{% endcall %}
|
||||||
|
|
||||||
<!-- Pagination -->
|
<!-- Pagination -->
|
||||||
{{ pagination_full() }}
|
{{ pagination(show_condition="!loading && pagination.total > 0") }}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|||||||
@@ -96,11 +96,17 @@
|
|||||||
{#
|
{#
|
||||||
Pagination Full Macro (First/Prev/Numbers/Next/Last)
|
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:
|
This macro expects flat variables (total, skip, page, limit) but our Alpine.js
|
||||||
{% from 'shared/macros/pagination.html' import pagination_full %}
|
components use nested pagination objects (pagination.total, pagination.page, etc.).
|
||||||
{{ pagination_full() }}
|
|
||||||
|
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:
|
Required Alpine.js data properties:
|
||||||
- page: Current page number
|
- page: Current page number
|
||||||
|
|||||||
@@ -1135,6 +1135,37 @@ class ArchitectureValidator:
|
|||||||
suggestion=f"Use '{{% block {invalid_blocks[block_name]} %}}' instead",
|
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(
|
def _check_alpine_template_vars(
|
||||||
self, file_path: Path, content: str, lines: list[str], js_content: str
|
self, file_path: Path, content: str, lines: list[str], js_content: str
|
||||||
):
|
):
|
||||||
@@ -2995,6 +3026,9 @@ class ArchitectureValidator:
|
|||||||
js_content = js_file.read_text()
|
js_content = js_file.read_text()
|
||||||
self._check_alpine_template_vars(file_path, content, lines, js_content)
|
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
|
# Skip base/partials for TPL-001 check
|
||||||
if is_base_or_partial:
|
if is_base_or_partial:
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user