Skip to main content

Run Linter

Run any lint tool (ESLint, ruff, golangci-lint, rubocop) against your source.

Reference: loha/run-lint@v1

Category: test

Runtime: docker.io/library/node:20-alpine (non-root, digest-pinned at Node 20)

License: Apache-2.0

When to use​

Use this step to enforce code style and catch common errors before they reach production. Generic enough for any linter; configure the command and image to match your stack.

Parameters​

ParameterTypeDefaultRequiredDescription
LINT_COMMANDstringnpx eslint . --format compactNoLint command to execute. For Node.js: npx eslint ., pnpm lint. For Python: ruff check ., flake8. For Go: golangci-lint run.
WORKING_DIRECTORYstring.NoDirectory to run in, relative to workspace root. Use for monorepo subdirectories.
LINT_IMAGEstringdocker.io/library/node@sha256:fb4cd12c85ee03686f6af5362a0b0d56d50c58a04632e6c0fb8363f609372293NoContainer image with lint tool installed. Use node:20-alpine for JS/TS, python:3.12-slim for Python, golangci/golangci-lint for Go.
FAIL_ON_ERRORenum: true, falsetrueNoFail the step if linting finds errors. Set to false for warning-only mode.

Workspaces​

  • source (required): bound from pipeline workspace source

Results​

ResultDescription
LINT_RESULTPASS or FAIL
ERROR_COUNTNumber of lint errors found

How it works​

Runs LINT_COMMAND inside LINT_IMAGE (default node:20-alpine) under WORKING_DIRECTORY. The exit code becomes LINT_RESULT (PASS or FAIL). ERROR_COUNT is best-effort parsed from common linter output formats; works for ESLint and ruff out of the box.

Examples​

Node.js / TypeScript with pnpm​

steps:
- name: lint
uses: loha/run-lint@v1
with:
LINT_COMMAND: 'pnpm lint'
WORKING_DIRECTORY: 'apps/dashboard'

Python with ruff​

steps:
- name: lint
uses: loha/run-lint@v1
with:
LINT_COMMAND: 'ruff check . --output-format concise'
LINT_IMAGE: 'python:3.12-slim'

Go with golangci-lint​

steps:
- name: lint
uses: loha/run-lint@v1
with:
LINT_COMMAND: 'golangci-lint run ./...'
LINT_IMAGE: 'golangci/golangci-lint:v1.62-alpine'

Troubleshooting​

Problem: "command not found" for the lint tool.

Solution: Either install it as a project dev-dependency (so npx/pnpm finds it) or pass an image that ships with the tool via LINT_IMAGE.


Problem: Too many errors on first adoption: pipeline is always red.

Solution: Set FAIL_ON_ERROR: "false" to surface issues without blocking. Fix incrementally, then flip the flag back.