- Run the following commands (be in the root, if you don't have a package.json there, run npm init first to create one):
npm install eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin husky prettier --save-dev
npm pkg set scripts.prepare="husky install"
npm run prepare
-
Copy files: .eslintrc.json, .prettierignore, .prettierrc and .husky/pre-commit
-
Add following to script section in package.json:
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --fix --ext .ts",
"format:write": "npx prettier -w .",
"format:check": "npx prettier -c .",
- Make a commit. You should see that your files are being checked for rule breaks. If it does not work and you are using a Mac, run following command and try a new commit:
chmod ug+x .husky/*
Test