Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extending ESLint with rule overrides: unexpected result with react-scripts build #8266

Closed
cheezekurl opened this issue Jan 1, 2020 · 3 comments

Comments

@cheezekurl
Copy link

cheezekurl commented Jan 1, 2020

Describe the bug

When applying custom ESLint configuration where you define a rule as error globally but off for a filename pattern, npm run build does not correctly ignore those filename patterns for the rule in question. Running ESLint directly works as expected, disabling the rule for that filename pattern.

Note that I have set up EXTEND_ESLINT=true in my .env and added "react-app" to extends in my .eslintrc.js

Did you try recovering your dependencies?

Yes - I even created a fresh create-react-app to repro this.

Which terms did you search for in User Guide?

Extend ESLint, ESLint

Environment

 System:
    OS: macOS 10.15.2
    CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
  Binaries:
    Node: 12.14.0 - ~/.nvm/versions/node/v12.14.0/bin/node
    Yarn: Not Found
    npm: 6.13.4 - ~/.nvm/versions/node/v12.14.0/bin/npm
  Browsers:
    Chrome: 79.0.3945.88
    Firefox: 34.0.5
    Safari: 13.0.4
  npmPackages:
    react: ^16.12.0 => 16.12.0
    react-dom: ^16.12.0 => 16.12.0
    react-scripts: 3.3.0 => 3.3.0
  npmGlobalPackages:
    create-react-app: Not Found

I have also reproduced the same issue on my Windows 10 PC at work, but do not have access to that command output at the moment.

Steps to reproduce

  1. npm install eslint@6.7.2

  2. Create an .eslintrc.js with the following:

module.exports = {
        "extends": ["react-app"],
        "rules": {
            "consistent-return": "error"
        },
        "overrides": [
            {
                "files": "App.js",
                rules: {
                    "consistent-return": "off"
                }
            }
        ]
}
  1. Create a .env with the following
EXTEND_ESLINT=true
  1. Add the following block to App.js somewhere
  const myFunc = () => {
    if (false) {
      return 'foo';
    }
  }
  1. Add a package.json script for linting: "lint": "eslint src"

  2. npm run lint. Observe that there are no lint errors detected

  3. npm run build.

Expected behavior

The build would succeed

Actual behavior

The build failed with the following error

Creating an optimized production build...
Failed to compile.

./src/App.js
  Line 6:21:  Expected to return a value at the end of arrow function  consistent-return

Search for the keywords to learn more about each error.

Reproducible demo

https://github.com/cheezekurl/cra-eslint-bug-repro

@eip1599
Copy link
Contributor

eip1599 commented Jan 2, 2020

@cheezekurl I had the same problem, this set as 3.3.1 milestone. Check here.
So I found a temporary answer on stackoverflow.

@stale
Copy link

stale bot commented Feb 1, 2020

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label Feb 1, 2020
@stale
Copy link

stale bot commented Feb 6, 2020

This issue has been automatically closed because it has not had any recent activity. If you have a question or comment, please open a new issue.

@stale stale bot closed this as completed Feb 6, 2020
@lock lock bot locked and limited conversation to collaborators Feb 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants