Welcome to the React Starter repository! This guide will help you set up the project for development and provide details on scripts, tools, and conventions used in the repository. Follow the steps carefully to get started.
Ensure you have the following installed before proceeding:
- Node.js: The project requires Node.js v20.11.0. You can use nvm to manage Node.js versions.
nvm install nvm use
- npm: Comes bundled with Node.js. Ensure it's up-to-date:
npm install -g npm@latest
- Git: Required for version control. Download Git if not already installed.
-
Clone the Repository Open your terminal and clone the repository:
git clone <repository-url> cd <repository-name>
-
Install Dependencies Install all required dependencies:
npm install
-
Start the Development Server Run the following command to start the development server:
npm run dev
The app will be accessible at
http://localhost:5173
by default (or another port if specified).
Below are the common scripts available in the repository:
-
Development Server
npm run dev
Starts the Vite development server.
-
Build for Production
npm run build
Builds the project for production. Output files will be in the
dist
directory. -
Preview Build
npm run preview
Serves the production build locally.
-
Linting
npm run lint
Runs ESLint to check for code issues.
-
Fix Linting Issues
npm run lint:fix
Attempts to automatically fix linting issues.
-
Prettier Check
npm run prettier
Checks for formatting issues.
-
Prettier Fix
npm run prettier:fix
Automatically fixes formatting issues.
-
Commit Changes
npm run commit
Launches an interactive prompt to structure your commit messages using
commitizen
. -
Release Version
npm run release
Creates a new version of the project using
standard-version
.
- The project follows Airbnb's ESLint rules with additional TypeScript support.
- Formatting is handled by Prettier.
- This repository uses Commitizen for structured commit messages. Always use:
npm run commit
- Commit messages follow the Conventional Commits standard.
- Pre-commit hooks are configured using Husky and lint-staged.
- Code is automatically linted and formatted on each commit.
- The project uses Vite as the build tool for faster development and optimized production builds.
- TypeScript is used to ensure type safety across the project.
- Husky is configured to run pre-commit and pre-push hooks for linting and testing.
- Used for automated versioning and changelog generation.
-
Node.js Version Issues
- Use the correct Node.js version by running:
nvm use
- Use the correct Node.js version by running:
-
Port Already in Use
- If the default port is busy, Vite will use the next available port. Check the terminal output for the exact URL.
-
Dependency Issues
- Run the following to ensure a clean install:
rm -rf node_modules package-lock.json npm install
- Run the following to ensure a clean install:
-
Pull the Latest Changes Before starting your work, always pull the latest changes:
git pull origin main
-
Create a New Branch Use a meaningful name for your branch:
git checkout -b feature/your-feature-name
-
Make Commits Use
npm run commit
to ensure commit messages follow the standard. -
Push Changes Push your branch to the remote repository:
git push origin feature/your-feature-name
-
Open a Pull Request Create a pull request for review.
- Write clean, modular, and reusable code.
- Ensure all tests pass before pushing changes.
- Adhere to the commit message guidelines.