HTML/CSS Guardrails
Enforce markup and stylesheet quality standards. Validates that HTMLHint and Stylelint report no errors or warnings above configured thresholds.
html to your lunar-config.yml:uses: github://earthly/lunar-lib/policies/html@v1.0.5
Included Guardrails
This policy includes 2 guardrails that enforce standards for your devex build and ci.
htmlhint-clean
Ensures HTMLHint reports no errors and fewer warnings than the configured threshold. HTMLHint catches unclosed tags, missing attributes, and accessibility issues in HTML files.
stylelint-clean
Ensures Stylelint reports no errors and fewer warnings than the configured threshold. Stylelint catches invalid properties, formatting issues, and common CSS/SCSS/LESS mistakes.
How Guardrails Fit into Lunar
Lunar guardrails define your engineering standards as code. They evaluate data collected by integrations and produce pass/fail checks with actionable feedback.
Policies support gradual enforcement—from silent scoring to blocking PRs or deployments—letting you roll out standards at your own pace without disrupting existing workflows.
Learn How Lunar Works →Required Integrations
This policy evaluates data gathered by one or more of the following integration(s).
Make sure to enable them in your lunar-config.yml.
Configuration
Configure this policy in your lunar-config.yml.
Inputs
| Input | Required | Default | Description |
|---|---|---|---|
max_htmlhint_warnings
|
Optional |
0
|
Maximum allowed HTMLHint warnings (0 = must be clean) |
max_stylelint_warnings
|
Optional |
0
|
Maximum allowed Stylelint warnings (0 = must be clean) |
Documentation
View on GitHubHTML/CSS Guardrails
Enforces HTML and CSS code quality via HTMLHint and Stylelint.
Overview
Validates that HTML and CSS-family files pass lint checks. Uses data collected by the html collector's htmlhint and stylelint sub-collectors. Checks are configurable with maximum warning thresholds.
Policies
This plugin provides the following policies (use include to select a subset):
| Policy | Description | Failure Meaning |
|---|---|---|
htmlhint-clean |
HTMLHint warnings below threshold | HTML files have lint issues (unclosed tags, missing attributes, etc.) |
stylelint-clean |
Stylelint warnings below threshold | CSS/SCSS/LESS files have lint issues (invalid properties, formatting, etc.) |
Required Data
This policy reads from the following Component JSON paths:
| Path | Type | Provided By |
|---|---|---|
.lang.html |
object | html collector |
.lang.html.lint.warnings |
array | html collector (htmlhint) |
.lang.html.native.htmlhint |
object | html collector (htmlhint) |
.lang.css |
object | html collector |
.lang.css.lint.warnings |
array | html collector (stylelint) |
.lang.css.native.stylelint |
object | html collector (stylelint) |
Installation
Add to your lunar-config.yml:
policies:
- uses: github://earthly/lunar-lib/policies/html@main
on: ["domain:your-domain"]
enforcement: report-pr
# include: [htmlhint-clean] # Only run specific checks
with:
max_htmlhint_warnings: "0" # Maximum HTMLHint warnings (default: "0")
max_stylelint_warnings: "0" # Maximum Stylelint warnings (default: "0")
Examples
Passing Example
{
"lang": {
"html": {
"file_count": 5,
"lint": {
"warnings": []
},
"native": {
"htmlhint": {
"passed": true,
"error_count": 0,
"warning_count": 0
}
}
},
"css": {
"file_count": 3,
"lint": {
"warnings": []
},
"native": {
"stylelint": {
"passed": true,
"error_count": 0,
"warning_count": 0
}
}
}
}
}
Failing Example
{
"lang": {
"html": {
"file_count": 5,
"lint": {
"warnings": [
{ "file": "index.html", "line": 15, "severity": "warning", "message": "Tag must be paired, missing: </div>", "rule": "tag-pair" }
]
},
"native": {
"htmlhint": {
"passed": false,
"error_count": 0,
"warning_count": 1
}
}
},
"css": {
"file_count": 3,
"lint": {
"warnings": [
{ "file": "styles/main.css", "line": 42, "severity": "error", "message": "Unexpected unknown property \"colr\"", "rule": "property-no-unknown" }
]
},
"native": {
"stylelint": {
"passed": false,
"error_count": 1,
"warning_count": 0
}
}
}
}
}
Failure messages:
"1 HTMLHint warning(s) found, maximum allowed is 0. Run 'htmlhint' and fix all issues.""1 Stylelint error(s) found, maximum allowed is 0. Run 'stylelint' and fix all issues."
Remediation
htmlhint-clean
- Run
npx htmlhint **/*.htmlto see all warnings - Fix the reported issues (unclosed tags, missing attributes, etc.)
- Configure
.htmlhintrcto customize rules for your project - If more warnings are acceptable, increase
max_htmlhint_warningsthreshold
stylelint-clean
- Run
npx stylelint "**/*.{css,scss,less}"to see all warnings - Fix the reported issues (invalid properties, formatting problems, etc.)
- Configure
.stylelintrc.jsonto customize rules for your project - If more warnings are acceptable, increase
max_stylelint_warningsthreshold
Open Source
This policy is open source and available on GitHub. Contribute improvements, report issues, or fork it for your own use.
Common Use Cases
Explore how individual guardrails work with specific integrations.
Ready to Automate Your Standards?
See how Lunar can turn your AGENTS.md, engineering wiki, compliance docs, or postmortem action items into automated guardrails with our 100+ built-in guardrails.