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:
@@ -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