Linter Guardrails
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.
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.
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.
max-warnings
Ensures lint warnings are at or below the maximum allowed threshold. Validates that the codebase maintains acceptable lint warning counts.
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 |
|---|---|---|---|
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 GitHubLinter 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:
- Configure a linter: Ensure a linter collector is running (e.g., the
golangcollector withgolangci-lint) - Fix lint warnings: Review the lint output and fix the reported issues
- Adjust threshold: If adopting linting incrementally, set
max_warningsto 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.
Common Use Cases
Explore how individual guardrails work with specific integrations.
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.