Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Issues
  • #8266
Closed
Open
Issue created Jan 01, 2020 by Administrator@rootContributor

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

Created by: cheezekurl

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

Assignee
Assign to
Time tracking