Configs for linters and formatters used in DADI projects.
-
Copy
.editorconfig,.eslintrcand.prettierrcto the root of the repository -
Install the required dependencies
npm i @dadi/eslint-config @dadi/prettier-config eslint husky lint-staged prettier --save-dev -
Add the following blocks to
package.json:"husky": { "hooks": { "pre-commit": "lint-staged" } }, "lint-staged": { "*.{js,jsx,md,html,css}": [ "prettier --write", "git add" ] } -
Add the following to your
testnpm script:eslint --ext js,jsx . && prettier --check '**/*.{js,jsx,md,html,css}' -
If you want to reformat an existing repository, run:
./node_modules/.bin/eslint --fix --ext js,jsx . && ./node_modules/.bin/prettier --write '**/*.{js,jsx,md,html,css}'