score:16

Accepted answer

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.

score:0

This is a simple way I avoid seeing unused variable warnings when debugging:

import someVariable from "./wherever"

// Prevent unused variable warnings
while (false) {
 console.log(someVariable)
}

score:0

If you're using create-react-app, then you can go into the package.json and edit the eslintConfig value. I just wanted to disable the "eqeqeq" and "no-unused-vars" rules, so mine looks like this:

"eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ],
    "rules": {
      "eqeqeq": "off",
      "no-unused-vars": "off"
    }
  },

You'll have to re-run npm start for it to take effect.

score:0

You can use craco and configure craco.config.js for example

 module.exports = {
  webpack: {
    configure: (webpackConfig) => {
      const ignoreWarnings = [{ module: /some module/, message: /some message/ }]
      return { ...webpackConfig, ignoreWarnings }
    }
  }
}

more details here

score:1

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.

  1. enter this directory

    node_modules/react-dev-utils/webpackHotDevClient.js

  2. look for this function(should be around line 114)

    function handleWarnings(warnings) {

and add a return statement right after it.

Your code should end up looking like this(if you're using webstorm) bye warnings

That should shut the webpackHotDevClient.js:{whateverLineIdontCare} right up. Cheers.

score:2

If you want to disable warnings in DevTools

  1. Open the Console Tab.
  2. Default levels/Custom levels -> uncheck Warnings

enter image description here

score:3

Recently the ability to add your own editor configurations was added, this can be used to "partially" disable the functionality of ESLint. You just need to create a configuration file in the root directory.

.eslintrc:

{
  "parser": "babel-eslint"
}

.env

SKIP_PREFLIGHT_CHECK=true

If you create a new application, it will by default come with a pre-filled eslintConfig object in the package.json

score:3

To Completely Remove eslint warnings, what you can do is create a file named .eslintignore add * and save it. You wont see any more warning.

*

To Remove warnings from a particular folder means in the .eslintignore file add that folder name

/folder_name
/folder_name/file_name.js

You can also do this in the file level also. Add the following in the beginning of the file

/* eslint-disable */ 

To ignore the next line warning in a file

// eslint-disable-next-line 

score:3

Set the DISABLE_ESLINT_PLUGIN environment variable:

DISABLE_ESLINT_PLUGIN=true npm start

score:4

For specific eslint warning supression insert the following code at the beginning of the file.

/* eslint-disable react/no-direct-mutation-state */

score:4

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 of function printWarnings() (line 124), or comment out the call to printWarnings() 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.

score:17

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.


Related Query

More Query from same tag