Commit 68d89ff
committed
feat(ci): add strict HTML, CSS, and JS pre-commit checkers
Three new pre-commit hooks (all PyPI-installable, language: python):
djlint-check — HTML formatter consistency
Runs djlint --check so any future hand-edits that deviate from djlint's
canonical HTML formatting are caught before commit.
Configuration additions in pyproject.toml:
profile = "html" — enables the full HTML5 rule set
indent = 2 — enforces 2-space indentation
max_line_length = 120 — matches the Python project limit
format_js = false — prevents djlint from mangling JS regex tokens
format_css = false — CSS is intentionally minified; keep it verbatim
check-embedded-css (scripts/check_css.py + tinycss2==1.5.1)
Extracts every <style> block from HTML files and parses each with
tinycss2. Reports parse errors at the tokeniser level (malformed tokens,
unexpected characters) and declaration-level errors (missing ':' separator,
empty value lists). Accepts modern CSS (custom properties, var(), clamp(),
vendor prefixes) without false positives.
check-embedded-js (scripts/check_js.py + py-mini-racer==0.6.0)
Extracts every inline <script> block (skipping src= external scripts) and
passes each through V8's Function constructor via py-mini-racer. This
catches all ES2020+ syntax errors (including optional chaining, async/await,
nullish coalescing) without executing the code.
Supporting changes:
• esc() refactored from 5 sequential .replace() calls to a single-pass
lookup-table approach (avoids djlint misreading the bare />/g regex token;
also slightly faster at runtime).
• index.html reformatted by djlint --reformat (HTML structure only; CSS/JS
content preserved verbatim).
• tinycss2==1.5.1 and py-mini-racer==0.6.0 added to [project.optional-
dependencies].development in pyproject.toml.
https://claude.ai/code/session_01LmU2X5jmgRZ1LHXc9S7bW11 parent 4c52262 commit 68d89ff
5 files changed
Lines changed: 690 additions & 213 deletions
File tree
- dfetch_hub/site
- scripts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
65 | 82 | | |
66 | 83 | | |
67 | 84 | | |
| |||
0 commit comments