Skip to content
This repository has been archived by the owner on Sep 28, 2020. It is now read-only.

eslint-loader with WebPack 2.2 #148

Closed
jeffrey-l-turner opened this issue Jan 20, 2017 · 9 comments
Closed

eslint-loader with WebPack 2.2 #148

jeffrey-l-turner opened this issue Jan 20, 2017 · 9 comments

Comments

@jeffrey-l-turner
Copy link

I am unable to get the failOnWarning and failOnError properties to work with WebPack 2.2. The newer version of WebPack does not recognize 'eslint' or 'eslint-loader' as a top level property on the webpack.config.js file. I've also tried using those properties in the enforce: 'pre' section of the rules. Is there a new way to specify this with the new version of WebPack. Thanks.

@bebraw
Copy link

bebraw commented Jan 21, 2017

@jeffrey-l-turner Top level configuration isn't supported anymore. Something known as LoaderOptionsPlugin replaced it.

@MoOx
Copy link
Contributor

MoOx commented Jan 23, 2017

Alternatively, this loader accepts parameters in each loader config.

@jeffrey-l-turner
Copy link
Author

jeffrey-l-turner commented Jan 24, 2017

ok for everyone else's edification per #457 as a temporary fix, above, here's what I did and it works:

const webpack = require('webpack');
...
plugins: [
        new webpack.LoaderOptionsPlugin({
            options: {
                eslint:
                {
                    failOnWarning: false,
                    failOnError: false,
                    fix: false,
                    quiet: false,
                },
            },
        }),
    ],

@shssoichiro
Copy link

Unfortunately I wasn't able to get this to work even with the above workaround.

@MoOx
Copy link
Contributor

MoOx commented Feb 1, 2017

You don't need a workaround. Just pass option directly with the loader. I will try to update the doc accordingly.

@MoOx MoOx closed this as completed Feb 1, 2017
@shssoichiro
Copy link

shssoichiro commented Feb 1, 2017

Do you mean something like this?

{
    test: /\.js$/,
    enforce: 'pre',
    exclude: /(node_modules|bower_components|\.spec\.js)/,
    use: [
        {
            loader: 'eslint-loader',
            options: {
                failOnWarning: false,
                failOnError: false
            }
        }
    ]
},

I'm trying this but eslint loader still causes npm to return an error code. I'm using eslint-loader 1.6.1 with webpack 2.2.1.

@maciej-gurban
Copy link

Neither of provided solution worked for me with webpack 2.

@tsvetkovv
Copy link

@maciej-gurban the same issue

@shssoichiro
Copy link

I've tracked down the issue to the fact that, in webpack 2, any use of emitError, which eslint-loader calls, will cause webpack to return an exit code of 2, which is an error. However, I'm not familiar enough with the inner workings of either library to suggest a fix.

The workaround is to set any lints which are not critical to warn instead of error.

Also to note, the actual build still finishes and produces output. This only affects wrappers that would call webpack, such as webpack-dev-server (won't automatically reload the browser if lint errors exist) or frontend-maven-plugin (will fail the maven build if lint errors exist).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants