# Pre-Deploy Validation ## Contract Running `npm run check` guarantees: ✅ **Build succeeds** - TypeScript compilation + Vite build passes with no errors ✅ **Lint passes** - ESLint checks pass ✅ **Format passes** - ESLint auto-fix applied ❌ **Does NOT guarantee**: - Tests pass (tests are optional, run separately) - Runtime behavior - API connectivity - WebSocket connection --- ## Pre-Deploy Command ```bash npm run check ``` **What it runs**: 1. `npm run build` - TypeScript compilation + Vite production build 2. `npm run lint` - ESLint checks 3. `npm run format` - ESLint auto-fix --- ## Individual Check Commands ### Build Check ```bash npm run build ``` **What it does**: `tsc -b && vite build` **Pass criteria**: TypeScript compiles AND Vite builds with 0 errors **Fail criteria**: Any TypeScript or build error ### Lint Check ```bash npm run lint ``` **What it does**: `eslint .` **Pass criteria**: No ESLint errors **Fail criteria**: Any ESLint error (warnings are OK) ### Format Check ```bash npm run format ``` **What it does**: `eslint . --fix` **Pass criteria**: Auto-fixes applied, no remaining errors **Fail criteria**: Errors that cannot be auto-fixed --- ## Optional: Test Check Tests are **optional** but **recommended** before deploy. ```bash npm run test ``` **What it does**: `vitest run` - Runs all component tests **Pass criteria**: All tests pass **Fail criteria**: Any test fails **When to run tests**: - ✅ Before deploying to production - ✅ After making UI changes - ✅ After updating dependencies - ⚠️ Optional for hotfixes (use judgment) --- ## Pass/Fail Rules ### ✅ SAFE TO DEPLOY (Minimum) All of the following must be true: - `npm run build` exits with code 0 - `npm run lint` exits with code 0 - `npm run format` exits with code 0 ### ✅ SAFE TO DEPLOY (Recommended) All minimum checks PLUS: - `npm run test` exits with code 0 ### ❌ DO NOT DEPLOY If any of the following are true: - `npm run build` fails (TypeScript or Vite errors) - `npm run lint` fails (ESLint errors) - `npm run format` fails (unfixable ESLint errors) - `npm run test` fails (if you chose to run tests) --- ## Current Issues (Must Fix Before Deploy) ⚠️ **Build is currently failing**: ``` src/App.dom.test.tsx:3:26 - error TS6133: 'waitFor' is declared but its value is never read src/tabs/OverviewTab.dom.test.tsx:6:10 - error TS6133: 'tableNameTransactions' is declared but its value is never read ... and 9 more errors ``` **Action required**: Fix TypeScript errors before deploying --- ## Full Pre-Deploy Checklist ```bash # Minimum (required) npm run check # Recommended (includes tests) npm run check && npm run test # Full validation (includes coverage) npm run check && npm run coverage ``` --- ## Quick Reference | Command | Purpose | Time | Critical | |---------|---------|------|----------| | `npm run build` | Compile + Build | ~15s | YES | | `npm run lint` | ESLint check | ~5s | YES | | `npm run format` | ESLint fix | ~5s | YES | | `npm run test` | Run tests | ~10s | RECOMMENDED | | `npm run check` | All checks | ~25s | YES | --- ## Troubleshooting ### Build fails - Check TypeScript errors in output - Fix type errors in code - Ensure all imports are correct - Check Vite build errors ### Lint fails - Check ESLint errors in output - Fix code style issues - Update ESLint config if needed ### Format fails - Some errors cannot be auto-fixed - Manually fix remaining issues - Re-run `npm run format` ### Tests fail - Check test output for failures - Fix failing tests - Update snapshots if needed (`vitest -u`) --- ## Notes - **Tests are optional**: But strongly recommended for production deploys - **Checks are mandatory**: Build, lint, format must pass - **No shortcuts**: Do not skip checks or deploy with failures - **Independent**: This project's checks are independent of the backend --- ## Related - Backend pre-deploy: `../bytelyst-trading-bot-service/docs/pre-deploy.md` - Deployment script: `deploy.ps1` - Test coverage: `npm run coverage`