A modern React + TypeScript + Vite starter with pre-configured ESLint, Prettier, Git hooks, Commitlint, React Testing Library, Vitest and GitHub Actions out of the box π¦
- β‘οΈ Vite - Next Generation Frontend Tooling
- βοΈ React 18 - A JavaScript library for building user interfaces
- π TypeScript - Why not?!
- π¨ ESLint - JavaScript linter
- π Prettier - Code Formatter
- πΊ Husky - Native Git hooks
- πΊ Lint Staged - Run Linters On Staged Files
- π Commitlint - Linting your commits based on commit convention
- βοΈ Vitest - Unit Testing Framework
- βοΈ Testing Library - Test UI components in a user-centric way
- π¬ GitHub Actions - CI with GitHub Actions
- β¨οΈ Alias Imports
We encourage you to use Visual Studio Code
Please install the following plugins:
- Code Spell Checker
- ESLint
- EditorConfig
- Prettier
Optional plugins:
- GitLens
- TODO Highlight
components # Reusable components used in multiple pages.
βββ Button # One example of component
βββ __tests__ # All test files related to Button
β βββ Button.test.tsx # Component Unit Test
βββ Button.module.scss # Button styles
βββ Button.tsx # Component file
βββ index.tsx # Exports component outside
pages
βββ Counter # One example of page
βββ __tests__ # All test files related to Counter page
β βββ Counter.test.tsx # Component Unit Test
βββ hooks # Hooks related only to Counter page
β βββ __tests__
β β βββ useCounter.test.ts
β βββ useCounter.ts
βββ components # You could have components related only to Counter page.
βββ utils # You could have utils related only to Counter page.
βββ Counter.module.scss
βββ Counter.tsx
βββ index.tsx # Exports page component
routes # All the routes
hooks # You may have hooks folder used in multiple pages or components in top level directory
βββ __tests__
β βββ useSomeHook.test.ts
β βββ useOtherHook.test.ts
βββ useSomeHook
βββ useOtherHook
Idea is to have related files in one place.
By this every component or page has its own folder with its own tests and styles. Every page has its own components, hooks, utils.
We use NVM
to manage the Node version. You can install it NVM
Version is specified in .nvmrc
file.
After installing NVM, run the following command to install the Node version used in this project:
nvm install
nvm use
We use yarn
to manage the dependencies. You can install it by running the following command and then install dependencies:
npm install -g yarn
yarn # or yarn install
In this project, you can run the following scripts:
Script | Description |
---|---|
yarn dev | Runs the app in the development mode. |
yarn build | Builds the app for production to the dist folder. |
yarn preview | Serves the production app locally after build. |
yarn lint | Lints the project |
yarn test | Runs and watches unit tests. |
yarn test:coverage | Gets unit test coverage. |
yarn test:ci | Runs unit tests once. |
yarn test:ui | Runs unit test in UI. |
We use Commitlint to lint our commit messages. This ensures that we have consistent commit messages.
Example of a good commit message:
git commit -m "feat: add new button component"
Commit Types:
Type | Description |
---|---|
feat | A new feature for user, not a new feature for build script |
fix | A bug fix for user, not a fix to a build script |
chore | Other changes that don't modify src or test files |
style | Changes that do not affect the meaning of the code (white-space, formatting) |
docs | Documentation only changes |
refactor | A code change that neither fixes a bug nor adds a feature |
perf | A code change that improves performance |
test | Adding missing tests or correcting existing tests |
build | Changes that affect the build system or external dependencies |
ci | Changes to our CI configuration files and scripts |
revert | Reverts a previous commit |