js-dxtools / webpack-validator

Validates your webpack config with Joi
MIT License
295 stars 29 forks source link

webpack 2 syntax for preloader (`enforce: 'pre'`) return error #142

Closed olivier-o closed 7 years ago

olivier-o commented 7 years ago

using the webpack 2 syntax for preloader (enforce: 'pre') ...

loaders: [
      {
        test: /\.jsx?$/,
        loader: 'eslint-loader?{fix: true}',
        exclude: /node_modules/,
        enforce: 'pre'
      },

return "enforce" is not allowed error message. Will be glad to work on a fix, if someone can point me to where this validation is happening

hinok commented 7 years ago

Have the same problem. In the readme is written that

Note that as of webpack v2 (currently in beta), configuration validation is baked in.

So for webpack 2, there is no reason to use webpack-validator? I found something in the webpack repository

Could someone explain it clearly?


It looks that webpack 2 has config validation, after removing webpack-validator I got this very nice written error

/Users/dk/Desktop/Dev/code-splitting/node_modules/webpack/lib/webpack.js:17
                throw new WebpackOptionsValidationError(webpackOptionsValidationErrors);
                ^
WebpackOptionsValidationError: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration has an unknown property 'eslint'. These properties are valid:
   object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry, externals?, loader?, module?, name?, node?, output?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, stats?, target?, watch?, watchOptions? }
   For typos: please correct them.
   For loader options: webpack 2 no longer allows custom properties in configuration.
     Loaders should be updated to allow passing options via loader options in module.rules.
     Until loaders are updated one can use the LoaderOptionsPlugin to pass these options to the loader:
     plugins: [
       new webpack.LoaderOptionsPlugin({
         // test: /\.xxx$/, // may apply this only for some modules
         options: {
           eslint: ...
         }
       })
     ]
    at webpack (/Users/dk/Desktop/Dev/code-splitting/node_modules/webpack/lib/webpack.js:17:9)
    at Object.<anonymous> (/Users/dk/Desktop/Dev/code-splitting/webpack/webpack-dev-server.js:23:18)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:509:3

So nice!

biswassuman23 commented 7 years ago

Same issue what is the solution?

kentcdodds commented 7 years ago

The solution is to not use this package with Webpack 2 anymore. It's no longer necessary. Please see the notice in the README. Cheers!