Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bumbaiya/nextjs-husky-template
Nextjs template bootstraped with Tailwincss, Prettier, Lint-staged and husky
https://github.com/bumbaiya/nextjs-husky-template
eslint husky lint-staged nextjs prehook prettier prettier-plugin-tailwindcss tailwindcss
Last synced: 5 days ago
JSON representation
Nextjs template bootstraped with Tailwincss, Prettier, Lint-staged and husky
- Host: GitHub
- URL: https://github.com/bumbaiya/nextjs-husky-template
- Owner: BUMBAIYA
- Created: 2023-06-29T04:56:13.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-10-21T10:39:06.000Z (about 1 year ago)
- Last Synced: 2024-10-11T10:52:22.698Z (28 days ago)
- Topics: eslint, husky, lint-staged, nextjs, prehook, prettier, prettier-plugin-tailwindcss, tailwindcss
- Language: TypeScript
- Homepage:
- Size: 117 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Nextjs Husky Template
This is a [Next.js](https://nextjs.org/) project template bootstraped with [Tailwindcss](https://tailwindcss.com), [Pretiier](https://prettier.io/), [Prettier-tailwindcss-plugin](https://github.com/tailwindlabs/prettier-plugin-tailwindcss), [Husky](https://typicode.github.io/husky/) and [lint-staged](https://github.com/okonet/lint-staged)
## Why
Linting and code formatting makes more sense when run before committing your code. By doing so you can ensure no errors go into the repository and enforce code style. But running a lint process on a whole project is slow, and linting results can be irrelevant. Ultimately you only want to lint files that will be committed.
1. Prettier - Code is formatted on save - Same code formatting throughtout the codebase - No need to discuss code style in code review
2. Prettier-tailwindcss-plugin - Formats tailwindcss classes - Each contributer will have same tailwindcss class sequence
3. Husky - Create a pre commmit hook - Run a script on staged code before committing.
4. Lint-staged - Ensure no errors go into the repository and enforce code style.
## Getting Started
### Step 1 - Clone and Install Dependencies
```bash
git clone https://github.com/BUMBAIYA/nextjs-husky-template.git
```Important: Install dependencies before changing files.
Run this command in project root folder
```bash
yarn
```### Step 2 - Create new git repo
Delete the `.git` folder from the repo
Note: Enable show hidden folder to show `.git` folder on windows
Initialize new local repo run this from project root
```bash
git init .
```Important: Edit the name in `package.json` file as your project name
### Step 3 - Enable Git hooks
```bash
npx husky install
```### Step 4 - Add and Commit
```bash
git add .
git commit -m "Initial commit"
```## Step - 5 You are all set for your usual development after following all the steps
## Customize Code Styles
To set code style of your liking edit `prettier.config.js`
Note: After changing code styles run this commands to format the codebase as your code style
```bash
npx prettier --write *
npx prettier --write ./src
```## Add pre commit hook
```bash
npx husky add .husky/pre-commit "# New Hook"
```or [refer](https://typicode.github.io/husky/getting-started.html#create-a-hook)
To add new lint stage edit `.lintstagedrc.json` or [refer](https://github.com/okonet/lint-staged#readme)