Search code examples
reactjseslintcreate-react-app

Why can't I lint my create-react-app project with the eslint-config-rallycoding npm package?


I've been able to use the npm package eslint-config-rallycoding in multiple react and react native projects, but I run into issues when trying it with create-react-app. Are there additional steps I need to do?

Usually all that is needed is:

  1. Create the project
  2. npm i --save-dev eslint-config-rallycoding
  3. touch .eslintrc
  4. Add { "extends": "rallycoding" } to the .eslintrc file

I am using sublime text 3 and this works with other projects just fine. I know create-react-app has a bunch of extra boilerplate, perhaps there's something I need to override?

https://www.npmjs.com/package/eslint-config-rallycoding https://github.com/facebookincubator/create-react-app


Solution

  • After reading the following lines in the create-react-app readme, I noticed there is already linting included:

    You would need to install an ESLint plugin for your editor first. Then, add a file called .eslintrc to the project root:

    js { "extends": "react-app" }

    Now your editor should report the linting warnings.

    To customize it further with a specific linting package like the above, you would need to eject to run npm run eject which would remove the single build dependency from your project allowing customization to babel, webpack, and eslint files.