Instruction file imported from workoho/spfx-guest-sponsor-info (
.github/instructions/shell-code-quality.instructions.md). Copyright stays with the author.
Shell Script Code Quality
Structure and semantics
- Prefer names that describe intent, side effects, or policy rather than the current implementation detail.
- Keep control flow readable. When conditionals start mixing setup, policy, and side effects, extract a small helper function.
- Comment non-obvious parameter expansion, fallback behavior, and destructive operations.
Safety and idempotency
- Preserve
set -euo pipefailand the repositorycdboilerplate where this repository expects it. - Keep scripts idempotent: guard file creation, avoid unconditional overwrite, and make repeated runs safe.
- Prefer explicit dry-run support for side-effecting scripts when that pattern already exists nearby.
Validation
- After every shell script change, run
npm run lint:sh. - Fix all reported shellcheck errors and warnings; do not leave warnings behind for the user or the commit hook to discover later.
- If formatting changed, run the repository fix workflow that includes
shfmt.
Final self-check
Before finishing, verify:
- Are names and comments clear enough for a reviewer to follow quickly?
- Is the script still safe to run twice?
- Did you run the matching shell validation and fix every warning?