Answer the question
In order to leave comments, you need to log in
How to properly set up ESLint, Prettier in 2020?
Hello. I read everything I found on this topic in Google. Almost all of them are outdated or do not suit me. Here's what I got when I collected all the information. I'm building an app with create-react-app . Here is what I have in my .eslintrc.json file :
{
"env": {
"browser": true,
"es6": true
},
"extends": [
"airbnb",
"plugin:jsx-a11y/recommended",
"prettier",
"prettier/react"
],
"plugins": ["react", "jsx-a11y", "prettier"],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parser": "babel-eslint",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 2018,
"sourceType": "module"
},
"rules": {
"prettier/prettier": "error",
"react/jsx-filename-extension": [
1,
{
"extensions": [".js"]
}
],
"no-shadow": "off",
"react/state-in-constructor": [2, "never"]
}
}
{
"editor.formatOnSave": true,
"[javascript]": {
"editor.formatOnSave": false // не понятно для чего эта строка
},
"editor.formatOnPaste": false,
"javascript.format.enable": false,
"javascript.validate.enable": false,
"files.associations": {
"*.jsx": "javascriptreact",
"*.js": "javascriptreact"
},
"emmet.syntaxProfiles": {
"javascript": "jsx"
},
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"prettier.disableLanguages": ["js"],
}
Answer the question
In order to leave comments, you need to log in
It looks like the eslint config was picked up by VS Code, but not by create-react-app. If prettier errors do not appear in the browser, then most likely they are. It is necessary to look towards the Advanced configuration , specifically the flag "EXTEND_ESLINT"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question