24
loading...
This website collects cookies to deliver better user experience
You may want to bookmark this article and use it as a reference when creating your projects. I will try to keep it up to date, and when I discover a new useful feature, I will include it here.
node -v
npm -v
command not found
or a similar error, download and install Node.js from the official website: https://nodejs.org/en/download/npx create-next-app@latest
npm run dev
.gitignore
file.npm install sass
styles
folder, you should see two .css
files there:.sass
or .scss
as you prefer. .eslintrc.json
) can be found in the root directory of your project.npm run dev
). This is why we are going to set up a Git hook in the next step, but first, let's install and configure Prettier.npm install --save-dev prettier
npm install --save-dev eslint-config-prettier
.prettierrc.json
) in the root directory of your project. Here is a sample configuration.{
"singleQuote": true,
"semi": true,
"tabWidth": 2
}
prettier
to your existing Eslint config (.eslintrc.json
):{
"extends": ["next/core-web-vitals", "prettier"]
}
npm run lint
.next lint
command every time you try to send a commit.npm install husky --save-dev
prepare
script to your package.json
file:...
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"prepare": "husky install"
},
...
.husky
folder with the required configurations.npm run prepare
npx husky add .husky/pre-commit "next lint --max-warnings=0"
next lint
command every time you try to send a commit.--max-warnings=0
flag is optional and can be removed in order to allow pushing the code with Eslint warnings. The info message will only appear in case of errors.# Install commitlint cli and conventional config
npm install --save-dev @commitlint/{config-conventional,cli}
# For Windows:
npm install --save-dev @commitlint/config-conventional @commitlint/cli
echo "module.exports = {extends: ['@commitlint/config-conventional']}" > commitlint.config.js
npx husky add .husky/commit-msg 'npx --no -- commitlint --edit "$1"'