Add stylelint to builds and watch #1885
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Stylelint is an awesome tool that brings the many benefits of linting to CSS and Sass. In Sage, we already use Eslint for JavaScript and PHPCS for the back end. I find that often times, our Sass files are left with no coding standards. Poorly written Sass can be very difficult to understand and can leave you with unforeseen bugs and duplicate code.
This PR adds Stylelint to the build and watch processes via the stylelint-webpack-plugin and extends Stylelint's recommended config as a base. To be friendly for CI builds, Stylelint will fail on error when running a build, but will only emit errors while watching, ensuring that it does not break the watch task.
Adding Stylelint is a no-brainer. However, the implementation could use some discussion. The easiest way is with the stylelint-webpack-plugin which seems to have a smaller community and moderate support at best. I am willing to discuss other options, but have been used the plugin on development of 4 highly custom sites across my team with no issues. It has really helped clean up our Sass code style as a whole!