Netvor's shareable collection of configs for Stylelint:
ℹ️ Note: This package is heavily based on VisionApps stylelint config
- extends stylelint-config-standard,
- adds rules to encourage low specificity and avoid nesting,
- gives preference to indentation of tab,
- includes additional configs for SCSS, CSS Modules and Kebab classes,
- uses stylelint-stylistic plugin to cover some rules that are no longer supported by Stylelint itself.
Install Stylelint and this config:
$ npm install --save-dev stylelint @ntvr/stylelint-config
Apply the config in your Stylelint config:
{
"extends": "@ntvr/stylelint-config"
}
To see the rules that this config uses, please read the main config itself.
To further extend control over coding style of your stylesheets, you can also check for properties order:
{
"extends": [
"@ntvr/stylelint-config",
"@ntvr/stylelint-config/order"
]
}
The order
config enforces properties order given by following categories:
all
properties,content
,- position,
appearance
,- box model,
- typography,
- decorations,
- effects and transforms,
- interactions,
- transitions and animations.
To see the order of individual properties this config prescribes, please read
the order
config itself.
👉 order
config is entirely independent on the main config and thus can be
listed anywhere in the extends
section of your config. However, that's not the
case with our other extending configs.
To lint SCSS files (i.e. *.scss
, not *.sass
), add the scss
config that
extends stylelint-config-standard-scss, fixes its incompatibilities with our
main config, and overrides some rules to better work with complex stylesheets:
{
"extends": [
"@ntvr/stylelint-config",
"@ntvr/stylelint-config/scss"
]
}
scss
config must come
after the main config.
To see the rules that this config uses, please read the
scss
config itself.
To lint CSS files in project that leverages CSS Modules, drop in the
cssModules
config that fixes key incompatibilities of CSS Modules syntax with
the main config:
{
"extends": [
"@ntvr/stylelint-config",
"@ntvr/stylelint-config/cssModules"
]
}
Or along with SCSS:
{
"extends": [
"@ntvr/stylelint-config",
"@ntvr/stylelint-config/scss",
"@ntvr/stylelint-config/cssModules"
]
}
cssModules
must come
after the main config, or after the scss
config, if present.
:global
pseudo selectors
are covered. All other features of CSS Modules (like composes
, :local
,
@value
, etc.) are considered non-essential as they can be implemented with
Sass (which we encourage) and thus are not recognized by this config.
To see the rules that this config uses, please read the
cssModules
config itself.
ℹ️ There is a popular stylelint-config-css-modules config that recognizes all features of CSS Modules.
To lint classnames if they follow kebab-case convention, add the kebab-classes
config. This could be used in for example bootstrap
implementation. This config
is not to be used in combination with cssModules
config.
{
"extends": [
"@ntvr/stylelint-config",
"@ntvr/stylelint-config/kebab-classes"
]
}
{
"extends": [
"@ntvr/stylelint-config",
"@ntvr/stylelint-config/scss",
"@ntvr/stylelint-config/kebab-classes"
]
}
kebab-classes
config
must come after the main config and/or after the scss
config.
To see the rules that this config uses, please read the
kebab-classes
config itself.
Example of all configs combined:
{
"extends": [
"@ntvr/stylelint-config",
"@ntvr/stylelint-config/order",
"@ntvr/stylelint-config/scss",
"@ntvr/stylelint-config/cssModules"
]
}
or
{
"extends": [
"@ntvr/stylelint-config",
"@ntvr/stylelint-config/order",
"@ntvr/stylelint-config/scss",
"@ntvr/stylelint-config/kebab-classes"
]
}