Mirrors the conventions used in ../yams: a sectioned .gitignore, thin .githooks dispatchers over runnable scripts/, release-please config and manifest, conventional-commit linting, CODEOWNERS, a PR template with a rule-precision checkbox, and tests + commitlint workflows. CI calls scripts/lint.sh so local hooks and CI cannot drift.
47 lines
1.2 KiB
Bash
Executable file
47 lines
1.2 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Thin dispatcher: all check logic lives here so it stays runnable on demand
|
|
# outside the git hooks. Mirrors the yams convention (`scripts/lint.sh --hook`).
|
|
set -euo pipefail
|
|
|
|
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
cd "$REPO_ROOT"
|
|
|
|
mode="${1:---hook}"
|
|
|
|
# Format only tracked Dart sources: `dart format .` would also crawl build/ and
|
|
# the fixture packages, which is not what a lint gate should touch.
|
|
run_format() {
|
|
echo "[lint] dart format (tracked sources)"
|
|
git ls-files -z '*.dart' | xargs -0 dart format --output=none --set-exit-if-changed
|
|
}
|
|
|
|
run_analyze() {
|
|
echo "[lint] dart analyze"
|
|
dart analyze
|
|
}
|
|
|
|
run_test() {
|
|
echo "[lint] dart test"
|
|
dart test
|
|
}
|
|
|
|
run_commitlint() {
|
|
echo "[lint] commitlint"
|
|
npx --yes --package @commitlint/cli --package @commitlint/config-conventional \
|
|
commitlint --from "${COMMITLINT_FROM:-HEAD~1}" --to "${COMMITLINT_TO:-HEAD}"
|
|
}
|
|
|
|
case "$mode" in
|
|
--hook)
|
|
run_format
|
|
run_analyze
|
|
;;
|
|
format) run_format ;;
|
|
analyze) run_analyze ;;
|
|
test) run_test ;;
|
|
commitlint) run_commitlint ;;
|
|
*)
|
|
echo "usage: scripts/lint.sh [--hook|format|analyze|test|commitlint]" >&2
|
|
exit 2
|
|
;;
|
|
esac
|