Introducing Stylelint
Stylelint is a linter for CSS files and can be extended to also understand CSS dialects such as SCSS, Sass, Less, or SugarCSS. It has over 170 built-in rules but, much like ESLint, provides support for custom rules.
To install Stylelint, we can follow the same steps as with ESLint:
- Here, it usually makes sense to rely on the standard configuration provided by Stylelint. Unlike ESLint, the standard configuration is released in a separate package and, therefore, needs to be installed as well. The command to install both packages as development dependencies looks like this:
$ npm install stylelint stylelint-config-standard
--save-dev
- In any case, we still require a configuration file. For the moment, it is sufficient to just let
stylelint
know that we want to use the configuration from thestylelint-config-standard
package. Here, we can write another configuration file next to the project’spackage.json
:
.stylelintrc...