|
1 | 1 | #!/usr/bin/env nix-shell |
2 | 2 | #! nix-shell -i bash -I nixpkgs=channel:nixpkgs-unstable -p biome actionlint |
3 | 3 |
|
4 | | -biome \ |
5 | | - format \ |
6 | | - --write \ |
7 | | - --no-errors-on-unmatched \ |
8 | | - --files-ignore-unknown=true \ |
9 | | - "./app/javascript" |
10 | | - |
11 | | -biome \ |
12 | | - format \ |
13 | | - --write \ |
14 | | - --no-errors-on-unmatched \ |
15 | | - --files-ignore-unknown=true \ |
16 | | - "./app/assets" |
17 | | - |
18 | | -# Run actionlint on GitHub Actions workflows |
19 | | -echo "Checking GitHub Actions workflows..." |
20 | | -actionlint |
| 4 | +# bin/lint - Run all linters systematically |
| 5 | +# This script runs all linters except the code_standards gem |
| 6 | + |
| 7 | +set -e # Exit on first error |
| 8 | + |
| 9 | +# Color codes for output |
| 10 | +RED='\033[0;31m' |
| 11 | +GREEN='\033[0;32m' |
| 12 | +YELLOW='\033[1;33m' |
| 13 | +BLUE='\033[0;34m' |
| 14 | +NC='\033[0m' # No Color |
| 15 | + |
| 16 | +# Track overall status |
| 17 | +OVERALL_STATUS=0 |
| 18 | + |
| 19 | +# Function to run a command and report status |
| 20 | +run_linter() { |
| 21 | + local name=$1 |
| 22 | + local command=$2 |
| 23 | + |
| 24 | + echo -e "\n${BLUE}Running ${name}...${NC}" |
| 25 | + |
| 26 | + if eval "$command"; then |
| 27 | + echo -e "${GREEN}✓ ${name} passed${NC}" |
| 28 | + else |
| 29 | + echo -e "${RED}✗ ${name} failed${NC}" |
| 30 | + OVERALL_STATUS=1 |
| 31 | + fi |
| 32 | +} |
| 33 | + |
| 34 | +echo -e "${YELLOW}Running all linters...${NC}\n" |
| 35 | + |
| 36 | +# 1. Ruby linting with StandardRB |
| 37 | +run_linter "StandardRB (Ruby formatter/linter)" \ |
| 38 | + "bundle exec standardrb --fix" |
| 39 | + |
| 40 | +# 2. Ruby type checking with Sorbet |
| 41 | +run_linter "Sorbet (Ruby type checker)" \ |
| 42 | + "bundle exec srb tc" |
| 43 | + |
| 44 | +# 3. ERB template linting |
| 45 | +run_linter "ERB Lint (ERB template linter)" \ |
| 46 | + "bundle exec erb_lint --autocorrect" |
| 47 | + |
| 48 | +# 4. Security scanning with Brakeman |
| 49 | +run_linter "Brakeman (security scanner)" \ |
| 50 | + "bundle exec brakeman -q --no-summary" |
| 51 | + |
| 52 | +# 5. JavaScript/TypeScript formatting with Biome |
| 53 | +run_linter "Biome (JavaScript formatter) - app/javascript" \ |
| 54 | + "biome format --write --no-errors-on-unmatched --files-ignore-unknown=true ./app/javascript" |
| 55 | + |
| 56 | +run_linter "Biome (JavaScript formatter) - app/assets" \ |
| 57 | + "biome format --write --no-errors-on-unmatched --files-ignore-unknown=true ./app/assets" |
| 58 | + |
| 59 | +# 6. GitHub Actions linting with actionlint |
| 60 | +run_linter "Actionlint (GitHub Actions linter)" \ |
| 61 | + "actionlint" |
| 62 | + |
| 63 | +# Summary |
| 64 | +echo -e "\n${YELLOW}========================================${NC}" |
| 65 | +if [ $OVERALL_STATUS -eq 0 ]; then |
| 66 | + echo -e "${GREEN}✓ All linters passed!${NC}" |
| 67 | +else |
| 68 | + echo -e "${RED}✗ Some linters failed. Please fix the issues above.${NC}" |
| 69 | +fi |
| 70 | +echo -e "${YELLOW}========================================${NC}" |
| 71 | + |
| 72 | +exit $OVERALL_STATUS |
0 commit comments