| TypeScript Basics | |
|---|---|
tsc --init | Create a tsconfig.json file in the project |
tsc | Compile TypeScript files to JavaScript |
tsc --watch | Watch for file changes and recompile automatically |
tsc --noEmit | Check for type errors without emitting files |
tsc --project tsconfig.json | Run the TypeScript compiler using a specific tsconfig file |
| Linting and Formatting | |
|---|---|
eslint . | Run ESLint on the entire project |
eslint --fix | Automatically fix linting issues |
eslint 'src/**/*.{ts,tsx}' | Lint only TypeScript files in the src directory |
prettier --write . | Format all files in the project |
prettier --check . | Check formatting without making changes |
prettier 'src/**/*.{ts,tsx,md}' --check | Check formatting of source files and markdown |
| Package Management | |
|---|---|
npm install [package] | Install a package and add it to dependencies |
npm install -D [package] | Install a package as a dev dependency |
npm uninstall [package] | Remove a package from dependencies |
npm outdated | List outdated dependencies |
npm dedupe | Remove duplicate packages in node_modules |
| Build and Deployment | |
|---|---|
npm run build | Run the build script defined in package.json |
npm start | Start the production server |
npm run deploy | Run the deployment script |
git push origin main | Trigger Cloudflare Pages deployment (GitHub repo connected to Pages) |
npx wrangler pages dev .next | Preview Cloudflare Pages build locally (optional) |
next build | Build a Next.js project for production |
next export | Export a static site (useful for Cloudflare or Netlify) |
npm run build && du -h .next/static/css | Check the size of generated Tailwind CSS files (performance check) |
| Testing | |
|---|---|
npm test | Run the test script defined in package.json |
jest | Run tests using Jest |
jest --watch | Run tests in watch mode |
npx vitest run | Run all tests using Vitest |
npx vitest | Run Vitest in watch mode |
npx vitest --coverage | Run tests with code coverage using Vitest |
npx jest --coverage | Run tests with code coverage using Jest |
| Scripts and Environment | |
|---|---|
npx tsx scripts/[your-script].ts | Run a custom TypeScript script using tsx |
dotenv -e .env -- tsx scripts/[your-script].ts | Run a script with environment variables from a .env file |
npm run type-check | Run type checking using tsc --noEmit |
npx husky add .husky/pre-commit "npm run lint && npm run type-check" | Add a pre-commit Git hook for linting and type-checking |
ts-node scripts/[your-script].ts | Run a script using ts-node (alternative to tsx) |
cross-env NODE_ENV=production tsx scripts/[your-script].ts | Set env variables and run a script (cross-platform) |
npx dotenv -- tsx scripts/generate-sitemap.ts | Run script with dotenv for sitemap generation |
| Security and Auditing | |
|---|---|
npm audit | Run a security audit on project dependencies |
npm audit fix | Automatically fix minor security issues |
npx depcheck | Check for unused or missing dependencies |