Add lint-checks composite action (prettier/eslint/commitlint, opt-in)

This commit is contained in:
Noah Holt 2026-08-10 22:51:09 -05:00
parent 43f0cdb92a
commit 1b62ee5f85

View file

@ -1,10 +1,10 @@
name: lint-checks
description: >
Node formatting, linting, and conventional-commit checks: prettier
(`format:check`) and eslint (`lint`) npm scripts, each `--if-present`,
plus commitlint if the repo has a commitlint config. Run after
actions/checkout and npm ci (e.g. after node-checks), in a job with node
available.
Style and hygiene checks: prettier (via the repo's format:check script),
eslint (via the repo's lint script), and conventional-commit linting when
a commitlint config exists. Each check is --if-present/config-gated, so
repos opt in by defining the script or config. Run after node-checks in
the same job (needs node_modules from npm ci).
runs:
using: composite
steps:
@ -13,18 +13,9 @@ runs:
- run: npm run lint --if-present
shell: bash
- shell: bash
env:
GITHUB_EVENT_NAME: ${{ github.event_name }}
GITHUB_BASE_REF: ${{ github.base_ref }}
run: |
set -euo pipefail
if ls commitlint.config.* .commitlintrc* >/dev/null 2>&1; then
if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then
git fetch origin "$GITHUB_BASE_REF" --depth=1
npx --yes commitlint --from "origin/$GITHUB_BASE_REF" --to HEAD
npx --no-install commitlint --last --verbose
else
npx --yes commitlint --from HEAD~1 --to HEAD
fi
else
echo "no commitlint config found, skipping conventional-commit check"
echo "no commitlint config, skipping conventional-commit check"
fi