| Linters |
Provides stylelint, configured with |
|---|---|
| Commands |
|
Table of Contents
Description
Stylelint is a wonderful tool to lint CSS in according to your rules, we have a custom configuration preset for Stylelint that comes pre-configured.
Installation
@swissquote/crafty-preset-stylelintis also automatically provided by@swissquote/crafty-preset-postcss. No need to add it manually ifcrafty-preset-postcssis already in your presets.
npm install @swissquote/crafty-preset-stylelint --save
module.exports = {
presets: ["@swissquote/crafty-preset-stylelint"],
};
Commands
crafty cssLint
This command will lint CSS files using Stylelint’s CLI too, you can get it’s documentation here.
The additions made by this command are:
- Pre-configured rules, defined by
stylelint-config-swissquoteactivated using--preset. - Set the syntax to
scss.
there are 3 presets available for you :
-
recommended: Contains all BEM specific rules. -
legacy: Contains rules specific to legacy code. -
common: Enforces the styleguide of the CSS. (included in bothrecommendedandlegacy)
Setting presets is done with the --preset option
The order of the presets is important as some rules might override previous ones.
It can be used the following way:
crafty cssLint css/**/*.scss --preset recommended
If no preset is specified recommended is used.
Linting options
You can read about the linting options in the page about CSS Linting