Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ignore or prevent ESLint errors from breaking the build in a React project (create-react-project)

I've recently created a project with create-react-project.

The problem is that, while I'm developing, every time there's a problem with ESLint, the build breaks and doesn't compile the code.

Can I keep the build running while still having ESLint running and reporting errors that I will fix later?

like image 355
R01010010 Avatar asked Jan 14 '18 12:01

R01010010


People also ask

How do I get rid of ESLint errors in react project?

Basically, just delete . eslintrc and any other eslint config files(if any) from the project. Also, check your package. json and delete all eslint packages and do npm install on your project.

Do you need to install ESLint With create react app?

Note, ESLint is installed with create-react-app, so you don't need to explicitly install it. Then install the packages for Airbnb config. This command will work for Yarn or NPM.

Does create react app use ESLint?

Because Create React App comes with ESLint already integrated. They use their own sharable ESLint configuration and this can be found under the eslintConfig object in package.


2 Answers

If you want to force ESLint to always emit warnings (that will not stop you build) instead of errors, you need to set emitWarning: true:

{
    enforce: 'pre',
    include: paths.appSrc,
    test: /\.(js|jsx|mjs)$/,
    use: [{
        loader: require.resolve('eslint-loader'),
        options: {
            formatter: eslintFormatter,
            eslintPath: require.resolve('eslint'),
            emitWarning: true, 👈 HERE
        },
    }],
},

As stated in the docs:

Errors and Warning

By default the loader will auto adjust error reporting depending on eslint errors/warnings counts. You can still force this behavior by using emitError or emitWarning options:

  • emitError (default: false)

    Loader will always return errors if this option is set to true.

  • emitWarning (default: false)

    Loader will always return warnings if option is set to true. If you're using hot module replacement, you may wish to enable this in development, or else updates will be skipped when there's an eslint error.

  • ...

like image 69
Danziger Avatar answered Oct 20 '22 22:10

Danziger


just add DISABLE_ESLINT_PLUGIN=true in your .envfile

cheers !

like image 11
janadari ekanayaka Avatar answered Oct 20 '22 21:10

janadari ekanayaka