Javascript Template
Professional JavaScript project template with modern tooling: linting, formatting, testing, git hooks, and automated CI/CD. Zero config, maximum productivity.
๐ Features
- Algorithms: Efficient implementations of common algorithms (Two Sum, Palindrome checker, etc.)
- Well-documented: Comprehensive JSDoc documentation
- Fully tested: 100% test coverage with Vitest
- Type-safe: TypeScript type checking for JavaScript
- Docker support: Containerized development and testing
๐ Prerequisites
- Node.js: >= 24.12.0 < 25.0.0
- pnpm: >= 10.0.0 (enforced via preinstall hook)
- Docker (optional): For containerized development
๐ ๏ธ Installation
# Clone the repository
git clone https://github.com/shonjoydev/javascript-template.git
cd <project-name>
# Install dependencies (only pnpm is allowed)
pnpm install
๐ฆ Available Scripts
Development
# Run tests
pnpm test
# Run tests in watch mode
pnpm test:watch
# Run tests with coverage
pnpm test:coverage
# Run documentation server
pnpm docs:dev
Docker Commands
# Run tests once
pnpm docker:test
# Run tests in watch mode
pnpm docker:test:watch
# Run tests with coverage
pnpm docker:test:coverage
# Run docs dev server
pnpm docker:docs
# Run docs in background
pnpm docker:docs:bg
# Stop all services
pnpm docker:down
# Rebuild containers
pnpm docker:build
# Clean up everything
pnpm docker:clean
๐ณ Docker Setup
Using Docker Compose
# Build and run tests
compose up test
# Run tests in watch mode
compose up test-watch
# Run with coverage
compose up test-coverage
# Run documentation server
compose up docs
Manual Docker Commands
# Build the image
docker build -t myapp-test .
# Run tests
docker run --rm myapp-test
# Run with interactive terminal
docker run -it --rm myapp-test
๐ Project Structure
.
โโโ src/ # Source code
โ โโโ arrays/ # Array utilities
โ โโโ strings/ # String utilities
โ โโโ ...
โโโ tests/ # Test files
โโโ docs/ # Documentation
โโโ .github/ # GitHub workflows
โโโ Dockerfile # Docker configuration
โโโ docker-compose.yml # Docker Compose configuration
โโโ jsconfig.json # JavaScript/TypeScript config
โโโ package.json # Project metadata
โโโ README.md # This file
๐งช Testing
Tests are written using Vitest.
# Run all tests
pnpm test
# Run specific test file
pnpm test src/isPalindrome.test.js
# Run with UI
pnpm test --ui
# Generate coverage report
pnpm test:coverage
๐ Code Quality
- ESLint: Code linting (if configured)
- TypeScript: Type checking for JavaScript files
- Strict mode: Enabled in
jsconfig.json - SonarQube: Docker best practices
๐ค Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Commit Guidelines
- Use clear and descriptive commit messages
- Follow conventional commits format (optional)
- Ensure all tests pass before committing
๐ License
This project is licensed under the MIT License.
๐ค Author
Shonjoy
๐ Acknowledgments
- Vitest - Testing framework
- pnpm - Fast, disk space efficient package manager
- Docker - Containerization platform
๐ Support
For support, email your-email@example.com or open an issue in the repository.
Made with โค๏ธ by Shonjoy