mirror of
https://github.com/acedanger/finance.git
synced 2025-12-05 22:50:12 -08:00
Refactor shell scripts for improved safety and consistency; add guidelines to documentation
This commit is contained in:
25
.github/copilot-instructions.md
vendored
25
.github/copilot-instructions.md
vendored
@@ -133,6 +133,31 @@ This project is a financial transaction management application built with Astro
|
||||
|
||||
## Code Style & Conventions
|
||||
|
||||
### Shell Scripts
|
||||
|
||||
All shell scripts should follow these conventions:
|
||||
|
||||
- Use `#!/usr/bin/env bash` instead of direct path to bash
|
||||
- Include standard safety flags at the start of each script:
|
||||
```bash
|
||||
set -o errexit # Exit on error
|
||||
set -o errtrace # Exit on error inside functions
|
||||
set -o nounset # Error on undefined variables
|
||||
set -o pipefail # Error if any command in a pipe fails
|
||||
```
|
||||
- Use `readonly` for constants and configuration values
|
||||
- Write error messages to stderr using `>&2`
|
||||
- Use proper error handling and exit codes
|
||||
- Validate all required parameters and dependencies
|
||||
- Use `[[` instead of `[` for better feature support
|
||||
- Quote all variable expansions
|
||||
- Use `${variable:-}` pattern for safe variable expansion
|
||||
- Handle special characters in input properly
|
||||
- Include clear error messages and validation
|
||||
- Group configuration/constants at the top of the script
|
||||
- Add descriptive comments for complex logic
|
||||
- Follow consistent indentation and formatting
|
||||
|
||||
### Import Path Aliases
|
||||
|
||||
Always use the path aliases defined in `tsconfig.json` instead of relative imports. This makes the code more maintainable and easier to refactor.
|
||||
|
||||
Reference in New Issue
Block a user