eslint-config-prettier-react
v0.0.24
Published
ESLint and Prettier Config
Downloads
1,984
Maintainers
Readme
Forked from wesbos
Local / Per Project Install
- Run below code
npx install-peerdeps --dev eslint-config-prettier-react
You can see in your package.json there are now a big list of devDependencies.
Create a
.eslintrc
file in the root of your project's directory (it should live where package.json does). Your.eslintrc
file should look like this:
{
"extends": [
"prettier-react"
]
}
- ⚠️⚠️⚠️ Delete
eslintConfig
in the package.json
Tip: You can alternatively put this object in your package.json
under the property "eslintConfig":
. This makes one less file in your project.
- You can add two scripts to your package.json to lint and/or fix:
"scripts": {
"lint": "eslint .",
"lint:fix": "eslint . --fix"
},
Global Install
- First install everything needed:
npx install-peerdeps --global eslint-config-prettier-react
- Then you need to make a global
.eslintrc
file:
ESLint will look for one in your home directory
~/.eslintrc
for macC:\Users\username\.eslintrc
for windows
In your .eslintrc
file, it should look like this:
{
"extends": [
"prettier-react"
]
}
- To use from the CLI, you can now run
eslint .
or configure your editor as we show next.
With VS Code
"editor.formatOnSave": true,
"[javascript]": {
"editor.formatOnSave": false
},
"[javascriptreact]": {
"editor.formatOnSave": false
},
"eslint.autoFixOnSave": true,
"prettier.disableLanguages": ["javascript", "javascriptreact"],
With Create React App
- You gotta eject first
npm run eject
oryarn eject
- run
npx install-peerdeps --dev eslint-config-prettier-react
- Crack open your
package.json
and replace"extends": "react-app"
with"extends": "prettier-react"