AsTeR
AsTeR

Reputation: 7541

How to configure Webpack & Babel to fail on undeclared variables?

I am using webpack with Babel to build my React application.

module: {
        loaders: [
            {
                test: /\.js$/,
                loader: 'babel-loader',
                query: {
                    presets: ['env', 'react']
                },
                exclude: /node_modules/
            }
        ]
    },

I have recently been using env (formerly es2015), so part of my code has some undeclared variables. I would like to configure webpack to fail at build rather than having a buggy js, which at execution which throws me error like :

assignment to undeclared variable fooBar

Upvotes: 0

Views: 366

Answers (1)

sammysaglam
sammysaglam

Reputation: 433

Not sure if Babel can do that, but Eslint sure can! Simply setup your Eslint config file; as well, implement Eslint into your webpack config using Eslint Webpack Plugin so it can fail on building. Feel free to let me know if you need more help on this.

Upvotes: 2

Related Questions