15

I've placed a .eslintignore file in the root of my create-react-app installation, so I can ignore warnings from vendor libs.

It works fine if I run eslint from the commandline:

./node_modules/.bin/eslint src/js/vendor/jquery.js
...warnings ignored...

However running npm start and npm run build seem to ignore the ignore file.

How can I achieve what I want to do here - without editing individual vendor files to add eslint options?

1
  • Did you ever figure this out?
    – Karoh
    Commented May 15, 2017 at 17:54

3 Answers 3

15

This was fixed with this commit in CRA codebase: https://github.com/facebook/create-react-app/commit/6f5221c2d7df0b7a097cfdd461967422c3013e12#diff-dc0c4e7c623b73660da1809fc60cf6ba

Simply add EXTEND_ESLINT=true to a .env file in your project root.

5
  • Which version of react-scripts are you using?
    – sebbab
    Commented Jul 18, 2020 at 10:34
  • I use react-scripts: v3.4.1 Commented Jul 21, 2020 at 12:42
  • 1
    @ShamilMammadov it works (refer back to the original link in this post), specifically look here, use .env file: github.com/facebook/create-react-app/commit/… (...Don't update the scripts in the package.json, as @sebbab said, but add the env var in a .env file.) Commented Jul 26, 2020 at 19:13
  • 1
    I just updated @sebbab's answer to correctly reflect the work-around in the link he posted. Commented Jul 26, 2020 at 19:21
  • This makes npm run build find errors that npm run lint doesn't find. This makes no sense.
    – aldel
    Commented Dec 22, 2020 at 20:33
9

YES .eslintignore is ignored. According to this issue.

CRA 1.x+ purposely does not support .eslintignore. Sorry!

Workarround

  • add /* eslint-disable */ to the beginning of the file.

  • move vendor files into public/ or use a NPM package.

3
  • Adding /* eslint-disable */ did it for me. I use webpack's Banner plugin to insert the comment at the top of my transpiled file that was having this issue. Commented Jan 25, 2020 at 1:27
  • 3
    ...but why? Seems like a strange decision. Does this accomplish anything other than slowing down developers? Commented Jul 9, 2021 at 14:26
  • Does the newest version (as of December 2, 2022) still ignore .eslintignore files? I tried putting a file in both my React project src folder and in the main project folder, and it seems that the files I listed for ignoring weren't ignored.
    – user749127
    Commented Dec 2, 2022 at 23:15
1

Seems to work if I exclude complete directories from the .eslintignore in the root. Here is my .eslintignore

src/js/vendor/
src/vendor/

Not the answer you're looking for? Browse other questions tagged or ask your own question.