Hamburger Cross Icon
Linter Guardrails - Lunar Policy for Testing And Quality

Linter Guardrails

Policy Stable Testing And Quality

Enforce code quality standards by validating that linting tools run and pass. Ensures consistent code style, catches common bugs, and maintains codebase health by tracking lint warnings against configurable thresholds.

Add linter to your lunar-config.yml:
uses: github://earthly/lunar-lib/policies/linter@v1.0.0

Included Guardrails

This policy includes 2 guardrails that enforce standards for your testing and quality.

Guardrail

ran

Ensures linting was executed for the specified language. Fails if no lint data is found, indicating the linter was not configured or did not run.

linting code quality static analysis ci
View Guardrail
Guardrail

max-warnings

Ensures lint warnings are at or below the maximum allowed threshold. Validates that the codebase maintains acceptable lint warning counts.

linting warnings code quality threshold
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
language Required Programming language to check (e.g., "go", "java", "python")
max_warnings Optional 0 Maximum number of lint warnings allowed (0 = no warnings allowed)

Documentation

View on GitHub

Linter Guardrails

Policies for validating that linting runs and passes with acceptable warning counts.

Overview

This policy plugin enforces code quality standards by validating that linting tools are configured and run as part of your CI pipeline. It checks that linting was executed and that the number of warnings stays within acceptable limits, helping maintain consistent code style and catch common bugs early.

Policies

This plugin provides the following policies (use include to select a subset):

Policy Description Failure Meaning
ran Ensures linting was executed Linting was not run or no linter is configured
max-warnings Ensures lint warnings are at or below threshold Too many lint warnings in the codebase

Required Data

This policy reads from the following Component JSON paths:

Path Type Provided By
.lang.{language}.lint object Language-specific linter collector
.lang.{language}.lint.warnings array Language-specific linter collector

Note: Ensure the corresponding collector is configured before enabling this policy.

Installation

Add to your lunar-config.yml:

policies:
  - uses: github://earthly/lunar-lib/policies/linter@v1.0.0
    on: [go]  # Or use domain: ["domain:your-domain"]
    enforcement: report-pr
    with:
      language: "go"
      max_warnings: "0"

Lenient Mode (allow some warnings)

policies:
  - uses: github://earthly/lunar-lib/policies/linter@v1.0.0
    on: [go]
    enforcement: block-pr
    with:
      language: "go"
      max_warnings: "10"  # Allow up to 10 warnings

Examples

Passing Example

{
  "lang": {
    "go": {
      "lint": {
        "warnings": []
      }
    }
  }
}

Failing Example

{
  "lang": {
    "go": {
      "lint": {
        "warnings": [
          {"file": "main.go", "line": 10, "message": "unused variable"}
        ]
      }
    }
  }
}

Failure message: "Found 1 lint warning(s), maximum allowed is 0"

Remediation

When this policy fails, you can resolve it by:

  1. Configure a linter: Ensure a linter collector is running (e.g., the golang collector with golangci-lint)
  2. Fix lint warnings: Review the lint output and fix the reported issues
  3. Adjust threshold: If adopting linting incrementally, set max_warnings to a higher value and reduce over time

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 engineering wiki, compliance docs, or postmortem action items into automated guardrails with our 100+ built-in guardrails.

Works with any process
check Infrastructure conventions
check Post-mortem action items
check Security & compliance policies
check Testing & quality requirements
Book a Demo
See it work with your own use cases
See How It Works