Description
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
-
npm install eslint@6.7.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"
}
}
]
}
- Create a .env with the following
EXTEND_ESLINT=true
- Add the following block to
App.js
somewhere
const myFunc = () => {
if (false) {
return 'foo';
}
}
-
Add a package.json script for linting:
"lint": "eslint src"
-
npm run lint
. Observe that there are no lint errors detected -
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.
Activity
eip1599 commentedon 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 commentedon 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 commentedon 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.