Last active
October 30, 2021 11:55
-
-
Save radiovisual/7c27e5a1d0f7aa56e0e3922c98e19ffc to your computer and use it in GitHub Desktop.
React Native AirBnB ESLint Config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"parser": "babel-eslint", | |
"plugins": [ | |
"react", | |
"react-native" | |
], | |
"parserOptions": { | |
"ecmaFeatures": { | |
"jsx": true, | |
"modules": true | |
} | |
}, | |
"extends" : [ | |
"eslint:recommended", | |
"plugin:react/recommended", | |
"airbnb-base" | |
], | |
"rules" : { | |
"arrow-body-style" : 'warn' | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm install --save-dev babel-eslint eslint-config-airbnb-base eslint-plugin-react eslint-plugin-react-native |
You also need to install eslint-plugin-import
and eslint
. I asume you forgot them because you have them installed globally, wich is a bat practice, so: npm i eslint-plugin-import eslint --save-dev
.
Then can run npx eslint .
or add this scripts to your package.json
:
"lint": "eslint .",
"lint-fix": "eslint . --fix"
And then run npm run estlint
or npm run eslint-fix
if you want to autofix your code.
Also is cool to have a pre-commit
hook with eslint
, maybe using pre-git
npm package and adding this to the package.json
:
"config": {
"pre-git": {
"pre-commit": [
"npm run lint"
],
"pre-push": [],
"post-commit": [],
"post-checkout": [],
"post-merge": []
}
},
Thanks.
Awesome.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, but you've a typo in line 19: JSON standard does not allow single quoted strings 👍