- Create package.json. ("y" flag tells the generator to use the defaults instead of asking questions.)
- Create .gitignore file.
- Add "node_modules" to .gitinore.
- Install ESLint, Husky and Lint-staged as devDependencies
npm init -y
touch .gitignore
echo 'node_modules' > .gitignore
npm i -D eslint husky lint-staged
- Initialize eslint configuration
- Add "lint" and "prepare" scripts to package.json scripts.
- Setup Lint-staged.
- Setup Husky "pre-commit" git hook.
npm pkg set scripts.lint="npx eslint"
npm pkg set scripts.prepare="husky install"
touch .lintstagedrc
echo '{
"*.js": "npm run lint"
}' > .lintstagedrc
npm run prepare
npx husky add .husky/pre-commit "npx lint-staged"