Create-react-app: Question: ESLint extend airbnb

Created on 6 Jan 2017  路  6Comments  路  Source: facebook/create-react-app

Hey guys,

first of all, great work with CRA!

Sorry if it's already been asked, but Is it possible to use airbnb's code style with CRA? We're trying to get to a sweet spot where code style is the same across all stacks.

Thanks a lot in advance.

Most helpful comment

FWIW, in the future we suggest moving to tools like prettier for stylistic enforcement. It doesn鈥檛 seem very wise that developers spend their time manually correcting style issues. In the meantime I hope this discussion helps.

All 6 comments

In CRA, ESLint is only used for checking for possible errors, not for style enforcement.
You can still manually add ESLint and use your own config separately.

@andrezzoid we have done it on our projects in a couple of ways.

First and most simply, just add eslint, eslint-config-airbini and all it's peers, and configure it.

If peer dependencies warnings bother you, another "dirty" solution is that of adding a folder in the root of your project (e.g. .eslint), there init a new, private npm project with your eslint dependencies. Then the main root's script should look something like cd .eslint && npm run eslint.

@EnoahNetzach Thanks for the clearing that up. However, I would like to know how to connect the manual eslint config with the create-react-app default start script.

I would like to be able to see errors on the console as I could when I used the default eslint config. Thanks.

@andela-cdike unfortunately I don't think that is an option.

@EnoahNetzach Thanks for the help. Fortunately, the eslint config works with my editor so I don't need the console view as such.

FWIW, in the future we suggest moving to tools like prettier for stylistic enforcement. It doesn鈥檛 seem very wise that developers spend their time manually correcting style issues. In the meantime I hope this discussion helps.

Was this page helpful?
0 / 5 - 0 ratings