This project uses Husky for pre-commit checks and GitHub Actions for continuous integration. Because SIST is a full-stack application (Laravel Backend + React Frontend), our pipeline runs parallel checks for both PHP and JavaScript environments.
Husky is configured to automatically run checks before each commit to ensure code quality across both the frontend and backend.
- ESLint - Auto-fixes linting issues on staged React/JS files (resources/js/*).
- Prettier - Auto-formats staged JS, JSX, and CSS files.
- Laravel Pint - Auto-formats staged PHP files to adhere to Laravel standards.
- You stage files with
git add . - You commit with
git commit - Husky triggers
lint-staged - Only staged files are checked and auto-fixed
- If checks pass, the commit proceeds
- If checks fail (e.g., a syntax error that cannot be auto-fixed), the commit is blocked.
- .husky/pre-commit - Triggers
pnpm exec lint-staged. - package.json -> lint-staged - Defines which linters run on which file extensions.
- eslint.config.js - ESLint Flat Config rules for React.
git commit --no-verify
Continuous Integration runs on every push to main and on all pull requests. It splits into two parallel jobs to maximize speed.
- Checkout code - Gets the repository code.
- Setup pnpm - Installs the pnpm package manager (v9).
- Setup Node.js - Installs Node.js 20 with the pnpm cache.
- Install dependencies - Runs
pnpm install --frozen-lockfile. - Run ESLint - Checks for React/JS linting errors.
- Check formatting - Verifies Prettier formatting.
- Build Vite Assets - Creates the production build of the React app.
- Checkout code - Gets the repository code.
- Setup PHP - Installs PHP 8.5 with required extensions (SQLite, PDO, etc.).
- Install Composer Dependencies - Installs Laravel vendor packages.
- Prepare Application - Copies
.env.exampleand generates an app key. - Format Check - Runs
./vendor/bin/pint --test(Fails if PHP is poorly formatted). - Run Tests - Executes PHPUnit/Pest tests using an in-memory SQLite database.
- Go to the "Actions" tab in your GitHub repository.
- Click on any workflow run to see details.
- Failed checks will block PR merges (if branch protection is enabled).
This repository is pre-configured with workspace settings to ensure a seamless developer experience.
When opening this project in VS Code, you will be prompted to install the recommended extensions (ESLint, Prettier, Laravel Pint). Once installed, the workspace .vscode/settings.json enforces Format on Save and Auto-Fix on Save globally:
- React/JS/CSS: Handled automatically by Prettier & ESLint.
- PHP: Handled automatically by Laravel Pint.
You should rarely, if ever, have formatting issues block a commit if these extensions are active.
pnpm dev # Start the Vite development server (HMR) pnpm build # Build React assets for production pnpm lint # Check for linting errors in resources/js pnpm lint:fix # Auto-fix linting errors pnpm format # Format all JS/CSS files with Prettier pnpm format:check # Check if JS/CSS files are formatted
php artisan serve # Start the PHP development server php artisan test # Run backend test suite pnpm format:php # Format all PHP files using Laravel Pint ./vendor/bin/pint # Direct access to Laravel Pint binary
When cloning the repository for the first time, run these commands to set up the dual environment:
-
Install PHP dependencies: composer install
-
Set up the environment file: cp .env.example .env php artisan key:generate
-
Create the local SQLite database and migrate: touch database/database.sqlite php artisan migrate
-
Install Node dependencies (This automatically sets up Husky): pnpm install
-
Start the development servers (Requires two terminal tabs): php artisan serve pnpm dev
If Husky didn't initialize properly upon cloning, manually wire it up: pnpm exec husky init
If Git Bash crashes instantly when trying to commit, it is likely the Windows CRLF bug.
- Open
.husky/pre-commitin VS Code. - Look at the bottom right corner of the window. Change CRLF to LF.
- Save the file and try your commit again.
If the visual Git UI in VS Code fails silently, it is likely due to missing environment variables for pnpm. Use the terminal instead:
git commit -m "your message here"
Lint-staged failing with hidden errors:
To see exactly what file is breaking the commit: pnpm exec lint-staged
- Ensure your
pnpm-lock.yamlandcomposer.lockare committed. - Verify you are running PHP 8.5 and Node 20 locally.