Create-react-app: [ESLint] Support .eslintignore in project root

Created on 2 Dec 2019  路  7Comments  路  Source: facebook/create-react-app

Is your proposal related to a problem?

ESLint is trying to lint some pre-built files that I dropped into my src directory, but it's finding "errors", and causing the build to fail.

Describe the solution you'd like

I want to be able to drop a .eslintignore file in my create-react-app root and have it Just Work 鈩笍.

Describe alternatives you've considered

I tried using the EXTENDS_ESLINT env variable and overriding specific rules in my custom src/.eslintrc.js, but overriding each rule one at a time, but it's easy to miss some. I really just don't want ESLint even trying to lint the file at all.

Additional context

I'm working on a new version of React Router and it'd be nice if people could just drop react-router.production.js into their src directory and see everything work w/out having to worry about ESLint failing. Google Closure Compiler does some interesting things to our built code that ESLint complains about.

I already submitted #8063 which fixes the main issue, but it'd be nice to just disable ESLint completely on any given file, like you'd be able to in a normal ESLint project.

proposal needs triage

All 7 comments

Hey @mjackson. Your .eslintignore should work when EXTEND_ESLINT=true correct?

That's what I'd hope @ianschmitz, but CRA currently doesn't work that way. I made a small repro in case you'd like to check it out. Here's the commit that introduces the "bug". Because CRA considers this an error, this app won't run.

https://github.com/mjackson/eslint-bug-cra-demo/commit/d605a4214aa2fb9b995fbc6a58227cbb0d2de4c2

@mjackson I believe there is a typo in the environment variable.

Ah, you're right @miraage. Thank you for taking a look. Indeed, it works as @ianschmitz described. Sorry for the false alarm!

No problem! Our plan is to make this the default behavior in v4 where it will just work as you say, but for v3 we made it an opt in.

Sorry to bump a closed issue but can I get an explain like I'm 5, on the set up for this? I can't get .eslintignore to be read no matter what I try.

Setting start in package.json to "start": "EXTEND_ESLINT=true react-scripts start",
Add .eslintignore to the root of the project with **/*.js
Run npm run start

My expected output is build successful with no warnings or errors. My actual result is build with warnings. I've tried this in both existing projects and a fresh project which I've created a repo for here:
https://github.com/stephenmcm/cra-eslintignore

From my testing so far I can see that EXTEND_ESLINT=true does allow extension of eslint configs but doesn't seem to read the .eslintignore.

Is there something painfully obvious I'm missing?

@stephenmcm that should work. Can you open a new issue so we can track?

Was this page helpful?
0 / 5 - 0 ratings