How to configure React Native (Expo) project to use AirBnB's React rules via ESLint?
See original GitHub issueI simply want to set-up the AirBnb’s React (Native) rules via ESLint on a React Native (Expo) project.
I found a ton of contradictory articles how to do that and I got really frustrated. Are there any official set-up guidelines?
Which modules exactly do I need to install with npm and how should my .eslintrc
config look like?
PS: Could somebody please add a “question” tag to this issue?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:32
- Comments:24
Top Results From Across the Web
Add Eslint Support to your React Native Project + React Hooks ...
Recently I came across a requirement where I needed to add eslint support for my one of React Native project. In this article,...
Read more >How to set up an expo init project with react-native ... - YouTube
react - native init comes with really nice linting rules setup already, ... I was using the newer react - native -community/ eslint...
Read more >Set up ESLint and Prettier for React Native projects - Three29
A step by step guide on how to set up ESLint and Prettier for React Native projects. Easy to follow instructions with CLI...
Read more >Set up React JS with ESLint, Prettier and Airbnb
One of the easiest way you can improve your code is to use a linter! Not only improve but also unified...
Read more >The easiest way to begin with Expo, Typescript, ESLint and ...
Tagged with expo, reactnative, typescript. ... Create the project using the Typescript template ... Install the Airbnb's ESLint packages.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is what I do in React and React Native:
Step 1
Step 2 Backup your eslintrc file in case you want to examine it.
Step 3
Step 4 Restart your editor
Step 5 Paste this into your
.eslintrc.json
: and remove my comments which will cause the JSON to blow upIf there are expo eslint settings, they will fit on top of these.
I collected these settings over time, mostly from researching specific JSX and babel related errors and reading.
I’m posting it because no one else has helped you in the past month, and this works. We can now switch the question from, “what is the correct way?”, to the more easy to handle “is this not the correct way?”
(Just a quick note on the solution mentioned here) The config @amackintosh shared here works very well for me, but I got the error
[eslint] JSX not allowed in files with extension '.js' (react/jsx-filename-extension)
(because I use some helper functions in my components for rendering out of the render function of component), I solved this problem by what mentioned here, so my .eslintrc.json is:{ "env": { "node": true, "browser": true, "es6": true }, "parser": "babel-eslint", "extends": "airbnb", "rules": { "react/jsx-filename-extension": [ 1, { "extensions": [ ".js", ".jsx" ] } ] } }
and everything is working perfect