New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eslint-loader with WebPack 2.2 #148

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

Comments

Projects
None yet
6 participants
@jeffrey-l-turner

jeffrey-l-turner commented Jan 20, 2017

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

This comment has been minimized.

bebraw commented Jan 21, 2017

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

@MoOx

This comment has been minimized.

Member

MoOx commented Jan 23, 2017

Alternatively, this loader accepts parameters in each loader config.

@LinusBorg LinusBorg referenced this issue Jan 23, 2017

Closed

Migration to webpack 2 #457

13 of 14 tasks complete
@jeffrey-l-turner

This comment has been minimized.

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

This comment has been minimized.

shssoichiro commented Jan 31, 2017

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

@MoOx

This comment has been minimized.

Member

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 Feb 1, 2017

@shssoichiro

This comment has been minimized.

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

This comment has been minimized.

maciej-gurban commented Feb 13, 2017

Neither of provided solution worked for me with webpack 2.

@Tsvetkovv

This comment has been minimized.

Tsvetkovv commented Feb 17, 2017

@maciej-gurban the same issue

@shssoichiro

This comment has been minimized.

shssoichiro commented Feb 17, 2017

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 join this conversation on GitHub. Already have an account? Sign in to comment