TLDR
-
Install
yarn add husky lint-staged prettier @commitlint/config-conventional @commitlint/cli @commitlint/cz-commitlint commitizen --dev
-
Add husky script
npx npm-add-script -k husky -v "husky"
-
Add prepare script
npx npm-add-script -k prepare -v "husky install"
-
Setup
yarn prepare
-
Add .prettierignore
echo # Add files here to ignore them from prettier formatting \\n dist coverage > .prettierignore
-
Add .prettierrc.json
echo { "singleQuote": true } > .prettierrc.json
-
Add format:all script:
npx npm-add-script -k format:all -v "prettier --write ."
-
Add lintstagedrc
echo { "*.ts": ["prettier --write", "tslint --fix"], "*.scss": ["prettier --write", "stylelint --fix"], "*.{html,js,json}": ["prettier --write"] } > .lintstagedrc.json
-
Add pre-commit hook:
yarn husky -- add .husky/pre-commit "yarn lint-staged"
-
Add commitlint.config.js
echo module.exports = {extends: ['@commitlint/config-conventional']} > commitlint.config.js
-
Add pre-commit hook:
yarn husky add .husky/commit-msg "yarn commitlint --edit $1"
-
Add husky script
npx npm-add-script -k commit -v "git-cz"
-
Add commitizen config to package.json
{
"config": {
"commitizen": {
"path": "@commitlint/cz-commitlint"
}
}
}