Hamburger Cross Icon
HTML/CSS Guardrails - Lunar Policy for Devex Build And Ci

HTML/CSS Guardrails

Policy Beta Devex Build And Ci

Enforce markup and stylesheet quality standards. Validates that HTMLHint and Stylelint report no errors or warnings above configured thresholds.

Add 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.

Guardrail

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.

htmlhint html linting markup quality accessibility
View Guardrail
Guardrail

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.

stylelint css linting stylesheet quality scss less
View Guardrail

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
1
Integrations Gather Data
Collectors extract metadata from code, CI pipelines, tool outputs, and scans
2
{ } Centralized as JSON
All data merged into each component's unified metadata document
3
Guardrails Enforce Standards This Policy
Real-time feedback in PRs and AI workflows

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 GitHub

HTML/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

  1. Run npx htmlhint **/*.html to see all warnings
  2. Fix the reported issues (unclosed tags, missing attributes, etc.)
  3. Configure .htmlhintrc to customize rules for your project
  4. If more warnings are acceptable, increase max_htmlhint_warnings threshold

stylelint-clean

  1. Run npx stylelint "**/*.{css,scss,less}" to see all warnings
  2. Fix the reported issues (invalid properties, formatting problems, etc.)
  3. Configure .stylelintrc.json to customize rules for your project
  4. If more warnings are acceptable, increase max_stylelint_warnings threshold

Open Source

This policy is open source and available on GitHub. Contribute improvements, report issues, or fork it for your own use.

View Repository

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.

Works with any process
check AI agent rules & prompt files
check Post-mortem action items
check Security & compliance policies
check Testing & quality requirements
Automate Now
Paste your AGENTS.md or manual process doc and get guardrails in minutes
Book a Demo