How to not show warnings in Create React App
Solution 1
For local Eslint, add a file to your project named .eslintignore
and add any directories or files you want to ignore:
build/
src/
*.js
Though you might as well remove it entirely at this point.
This doesn't work with building or starting the code however, if you are using create-react-app
. There is no way to disable Eslint without ejecting because it's built into react-scripts. Anytime any you build or start the server, it will run eslint using its internal configs aside from special cases defined in package.json
. The only way around that is to eject or prepend each file with the disable comment as mentioned elsewhere. See this issue on Github for more information.
Solution 2
Those warnings come from eslint. To disable them add /* eslint-disable */
at the top of the file you don't want to follow the eslint rules.
Solution 3
For specific eslint
warning supression insert the following code at the beginning of the file.
/* eslint-disable react/no-direct-mutation-state */
Solution 4
Set the DISABLE_ESLINT_PLUGIN
environment variable:
DISABLE_ESLINT_PLUGIN=true npm start
Solution 5
My rep is not high enough to comment on @fly's excellent answer, so I'll C+P it to add this instead:
For anyone looking for a temporary but quick and effective workaround for disabling console warnings from DevTools, this might do the trick.
Disclaimer - this might not work on versions that are not mine(react-scripts v3.0.1, react-dev-utils@^9.0.1), so use it at your own risk.
- enter this directory
node_modules/react-dev-utils/webpackHotDevClient.js
- look for this function(should be around line 114)
function handleWarnings(warnings) {
either add the
return
at the start offunction printWarnings()
(line 124), or comment out the call toprintWarnings()
in line 145.restart, eg with
npm run start
, for change to take effect.
This way, the hot reloader continues to work, but the annoying warnings which have already been caught in my editor are not output in the browser.
Shai UI
front-end developer in finance. especially html5/javascript/css based apps for mobile/desktop/tablets, node.js on the back-end. my main interests are heavy GUI, 2d/3d, data visualizations. check out my youtube channel: https://www.youtube.com/channel/UCJagBFh6ClHpZ2_EI5a3WlQ
Updated on December 28, 2021Comments
-
Shai UI over 2 years
I'm using create-react-app from Facebook, when it starts via 'npm start' it shows me a list of warnings, such as:
'Bla' is defined but never used
Expected '===' and instead saw '=='I don't want to see any of these warnings, is there a way to supress them?
-
Craig1123 about 6 yearsWhy would you want to disable those warnings? It isn't hard to fix them and they won't be there in production
-
Craig1123 about 6 yearsIf you insist on ignoring them, the terminal prints a hint on how to do it when you run the start script
-
Shai UI about 6 yearsThe hint it for single files, not for all files
-
SrThompson about 6 yearsYou can eject and remove eslint from the project
-
Craig1123 about 6 yearsYou can always remove the entire eslint if you want 0 warnings. If you want a specific rule to stop warning you, edit you .eslintrc file
-
Fen1kz almost 6 years@Craig1123 I'm not OP, but I want to disable it then when I'm actively prototyping and want to leave all warnings aside until I'm ready to refine the prototype
-
-
Shai UI about 6 yearsyes that works, but I don't want to do it for every file. how do I do it for everything. I don't want to see warnings at all.
-
Everettss about 6 yearsI don't think it is currently possible github.com/facebook/create-react-app/issues/2157 create-react-app is supposed to be opinionated in opposite to raw react.
-
Shai UI about 6 yearsI think it's possible if I npm run eject and then configure eslint on my own or something like this
-
Everettss about 6 years@foreyez Oh yea you are definitely right about ejecting. It's up to you.
-
Shai UI about 6 yearsadding this file and content doesn't work. note I haven't run eject yet.
-
Kevin Hoerr about 6 yearsAh, apparently that's on purpose: github.com/facebook/create-react-app/issues/2339 Only solution is to eject.
-
Kevin Hoerr about 6 yearsTo clarify, there is no way to disable Eslint without ejecting because it's built into react-scripts. Anytime any you build or start the server, it will run eslint using its internal configs aside from special cases defined in
package.json
. The only way around that is to eject or prepend each file with the disable comment as mentioned elsewhere. -
Admin about 5 years@SilvioBiasiol Yes, as long as you are using CRA 2.x.x+
-
Shamseer Ahammed over 2 yearsThis will only hide warning from chrome
-
Dashiell Rose Bark-Huss over 2 yearsYes that's why I specified "in DevTools"