fleetlint Policy for a fleet of repositories
v0.9
Getting started

lint/shell

Shell scripts are linted

Severityinfo
Tiersall
Stacksany
Scoperoot
Kindexpr
Sourcelibrary v0.6.0
Selected byfleetlint-recommended@v0.6.0

Requirement

When the repository contains shell scripts, shellcheck runs as a hook (pre-commit or lefthook), in the task runner or in CI (GitHub, Gitea, Forgejo or GitLab).

Why

Unquoted variables and unchecked exit codes are the bugs shell scripts ship with, and shellcheck finds them without running anything.

Applies when

tracked().exists(p, p.endsWith(".sh"))

Check

[".pre-commit-config.yaml", "lefthook.yml", "lefthook.yaml", ".lefthook.yml"].exists(f, file(f) && text(f).contains("shellcheck")) || (taskrunner.file != "" && text(taskrunner.file).contains("shellcheck")) || workflows().exists(w, text(w).contains("shellcheck"))

Fix

Add the shellcheck hook to .pre-commit-config.yaml (or lefthook.yml).

Agent instruction: Add the shellcheck hook (and shfmt) to .pre-commit-config.yaml and fix what it reports in the tracked scripts.

A finding of this rule points at the file ([".pre-commit-config.yaml", "lefthook.yml", "lefthook.yaml", "lefthook.toml", "lefthook.json", "lefthook.jsonc", ".lefthook.yml", ".lefthook.yaml", ".lefthook.toml", ".lefthook.json", ".lefthook.jsonc"].filter(f, file(f)) + [".pre-commit-config.yaml"])[0] yields.

Sources


Generated by fleetlint docs from catalog v0.6.0.