webpack-contrib / stylelint-webpack-plugin

A Stylelint plugin for webpack
MIT License
426 stars 72 forks source link

Stop the compilation when 'failOnError' setted to false #200

Closed Applelo closed 4 years ago

Applelo commented 4 years ago

Expected Behavior

I would like to show stylelint errors but not stop the build of my app.

Actual Behavior

Stylelint webpack plugin stop the compilation of the app when I have an error even if I have set the configuration to prevent that.

Code

new StyleLintPlugin({
          configFile: Path.resolve(__dirname, '.stylelintrc.json'),
          context: Path.join(SrcDirPath, 'stylesheets'),
          files: '**/*.scss',
          failOnError: false,
          emitErrors: true,
          syntax: 'scss',
})
ERROR in 
static/src/stylesheets/components/ui/_form.scss
  9:5  ⚠  Unexpected browser feature "flexbox" is only partially supported by IE 11        plugin/no-unsupported-browser-features
 33:3  ⚠  Unexpected browser feature "outline" is only partially supported by IE 11, IE    plugin/no-unsupported-browser-features
          Mobile 11                                                                                                              
 50:5  ⚠  Unexpected browser feature "css-resize" is not supported by IE 11, Edge 17,18,   plugin/no-unsupported-browser-features
          iOS Safari 11.3-11.4,12.0-12.1,12.2-12.3, IE Mobile 11, KaiOS Browser 2.5                                              
 52:5  ✖  Expected ".input-group:not(.input-group--error) &:invalid:focus" to      selector-max-pseudo-class             
          have no more than 2 pseudo-classes                                                                                     
 69:3  ⚠  Unexpected browser feature "flexbox" is only partially supported by IE 11        plugin/no-unsupported-browser-features

npm ERR! code ELIFECYCLE

How Do We Reproduce?

I can't share my current project but I can make a repository to reproduce the bug.

ricardogobbosouza commented 4 years ago

@Applelo If you can create a repository I appreciate

Applelo commented 4 years ago

You can find an example where I was able to reproduce this issue: https://github.com/Applelo/stylelint-webpack-plugin-issue-200

ricardogobbosouza commented 4 years ago

@Applelo come on:

failOnError if enabled will stop compilation and display errors. emitError if enabled will show all errors and warnings as errors. emitWarning if enabled will show all errors and warnings as warnings.

We cannot issue an error to webpack without failing, you can try this:

new StyleLintPlugin({
  configFile: Path.resolve(__dirname, '.stylelintrc.json'),
  context: Path.join(SrcDirPath, 'stylesheets'),
  files: '**/*.scss',
  emitWarning: true,
  syntax: 'scss',
})
Applelo commented 4 years ago

Thanks for your answer, it's this option I was looking for. Sorry for my misunderstanding but your answer is more clear than the readme and the name of the options.

Have a good year.