This document explains the development workflow, tools, and best practices for the Aswin Portfolio project.
- Node.js 18 or higher
- npm 9 or higher
- Git
# Clone the repository
git clone https://github.com/Aswincloud/portfolio.git
cd portfolio
# Install dependencies
npm install
# Start development server
npm run devnpm run dev- Start development servernpm run dev:all- Start both frontend and backend serversnpm run build- Build for productionnpm run preview- Preview production build
npm run lint- Run ESLintnpm run lint:fix- Run ESLint with auto-fixnpm run format- Format code with Prettiernpm run format:check- Check code formatting
npm run test- Run tests in watch modenpm run test:run- Run tests oncenpm run test:coverage- Run tests with coveragenpm run test:ui- Run tests with UI
npm run security:check- Run custom security checksnpm run security:audit- Run npm audit
npm run quality:check- Run all quality checksnpm run validate- Run quality checks + buildnpm run pre-commit- Run pre-commit hooks
This project uses Husky and lint-staged to ensure code quality before commits:
- ESLint - Fixes linting issues
- Prettier - Formats code
- Tests - Runs tests for changed files
- Security Checks - Scans for vulnerabilities
Pre-commit hooks are automatically installed when you run npm install.
npm run pre-commit- Vitest - Fast unit testing
- React Testing Library - Component testing
- Jest DOM - DOM testing utilities
src/
├── components/
│ ├── HeroSection.jsx
│ └── __tests__/
│ └── HeroSection.test.jsx
└── setupTests.js
import { render, screen } from '@testing-library/react';
import { describe, it, expect } from 'vitest';
import MyComponent from '../MyComponent';
describe('MyComponent', () => {
it('renders correctly', () => {
render(<MyComponent />);
expect(screen.getByText('Expected Text')).toBeInTheDocument();
});
});# Watch mode (development)
npm run test
# Run once
npm run test:run
# With coverage
npm run test:coverage- NPM Audit - Dependency vulnerabilities
- Sensitive Files - Checks for accidentally committed secrets
- Gitignore Validation - Ensures important files are ignored
- Package.json Security - Scans for dangerous scripts
security/detect-object-injectionsecurity/detect-non-literal-regexpsecurity/detect-possible-timing-attacks
npm run security:check
npm run security:audit- Tab Width: 2 spaces
- Quotes: Single quotes
- Semicolons: Yes
- Trailing Commas: ES5
- Line Width: 100 characters
# Format all files
npm run format
# Check formatting
npm run format:check- Base: ESLint recommended + Vite React
- Plugins: React, React Hooks, JSX A11y, Security
- Rules: Strict mode for React hooks and accessibility
# Check linting
npm run lint
# Fix linting issues
npm run lint:fixmain- Production branchfeature/- Feature brancheshotfix/- Emergency fixes
- Stage changes:
git add . - Commit:
git commit -m "message"- Pre-commit hooks run automatically
- Code is linted, formatted, and tested
- Security checks are performed
- Push:
git push origin branch-name
type(scope): description
Example:
feat(auth): add login functionality
fix(ui): resolve button alignment issue
docs(readme): update installation instructions
-
Quality Checks (runs on all branches):
- Install dependencies
- Run linting
- Check formatting
- Run tests
- Run security checks
- Build project
-
Deploy (runs only on main branch):
- Build React application
- Deploy to Cloudflare Workers
- All quality checks must pass
- Only main branch is deployed
- Requires
CLOUDFLARE_API_TOKENsecret
# Reinstall husky
npm run prepare# Clear test cache
npm run test:run -- --clearCache
# Run specific test
npm run test -- MyComponent.test.jsx# Auto-fix most issues
npm run lint:fix
# Check specific file
npx eslint src/components/MyComponent.jsx# Try automatic fix
npm audit fix
# Check specific vulnerability
npm audit- Text: Console output
- HTML:
coverage/index.html - JSON:
coverage/coverage-final.json
- Statements: 80%
- Branches: 80%
- Functions: 80%
- Lines: 80%
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
}- ESLint
- Prettier
- Vitest
- GitLens
- Auto Rename Tag
- Use functional components with hooks
- Keep components small and focused
- Use TypeScript for type safety (future enhancement)
- Follow React best practices
- Write tests for all components
- Test user interactions
- Mock external dependencies
- Aim for high test coverage
- Never commit sensitive data
- Regularly update dependencies
- Use environment variables for secrets
- Validate all inputs
- Use lazy loading for large components
- Optimize images
- Minimize bundle size
- Use React.memo for expensive components
- React Documentation
- Vite Documentation
- Vitest Documentation
- Testing Library Documentation
- ESLint Documentation
- Prettier Documentation
For questions or issues, please check the existing documentation or create an issue in the repository.