js-dxtools / webpack-validator

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

Don't fail if loader object is valid, but not a string #124

Closed leonid-bauxy closed 7 years ago

leonid-bauxy commented 7 years ago

It's still a valid if it's in a form of object and webpack needs to parse it after anyway. Don't you think users should be allowed to use the form they prefer if both string and object forms are valid. Or at least add an option to disable this check? Would you accept a pull-request?

In this case I receive an error, even though it's valid:

{ [16]
  "loader": "resolve-url",
  "query": {
    "sourceMap": true
  }
},

[16] "3" must be a string
kentcdodds commented 7 years ago

Could you provide more of your config please?

kentcdodds commented 7 years ago

Ah, yeah, looks like this needs to be updated to support objects. And we should probably add some tests for that here.

Feel free to makeapullrequest.com :smile:

leonid-bauxy commented 7 years ago

@kentcdodds sure, it's pretty big, though. Let me know what relevant parts you'd like me to extract.

webpack.config.babel.js: https://gist.github.com/leonid-bauxy/d94f54e41d67c8346caaaed3046cd9c6

./helpers/getStylesLoaders.js: https://gist.github.com/leonid-bauxy/22d70a5257e850bc1ecd68e390b62de0

./helpers/getBabelConfig.js: https://gist.github.com/leonid-bauxy/48d132157906708cc8666f8ec563a535

The utility ./helpers/hoistLoaderIfOne, that i've made just to make the validator happy. But it still covered only some of the cases): https://gist.github.com/leonid-bauxy/5e829251335f521c42547bff4d574064

Validation Result: https://gist.github.com/leonid-bauxy/de9c143c91fbd924ce136d3985244711

Edit: I re-posted this comment after removing some(probably) confidential info.

leonid-bauxy commented 7 years ago

@kentcdodds thanks for the tips! Will make a PR soon.

le0nik commented 7 years ago

PR: https://github.com/js-dxtools/webpack-validator/pull/125