$ npm i -g create-react-app
$ npm init react-app <app-name>
A specific version of eslint
comes preinstalled, do not install your own - things will break.
$ npm i prettier eslint-config-prettier eslint-plugin-prettier husky lint-staged pretty-quick -D
Create a file named .eslintrc
in the root directory of the app. It should contain:
{
"extends": ["react-app", "plugin:prettier/recommended"]
}
In package.json
, add:
"husky": {
"hooks": {
"pre-commit": "pretty-quick --staged"
}
}
Prettier rules go in .prettierrc.json
, in the root directory of the app.
My preferred prettier rules are as follows:
{
"semi": false,
"singleQuote": true,
"trailingComma": "es5"
}