Contactlab Stylelint extensible and sharable configuration.
Inspired by @giotramu/stylelint-config
package.
It supports CSS or PostCSS syntax and CSS-in-JS solutions, like Styled Components, Emotion.js or Linaria.
Warning! This package needs Stylelint v15 (or higher) which has deprecated some rules, removed Nodejs v12 support and made Prettier integration smoother.
Install the configuration as a npm package:
npm i -D @contactlab/stylelint-config
# --- OR ---
yarn add -D @contactlab/stylelint-config
and then add it as extension in your Stylelint configuration file:
{
"extends": ["@contactlab/stylelint-config"]
}
In order to have support for CSS-in-JS tools, use the styled
config as extension:
{
"extends": ["@contactlab/stylelint-config/styled"]
}
Stylelint Config sorts the CSS property declarations by grouping them in the following order:
You can extend the configuration or overrides some rules. More details about the loading mechanism are available in the Stylelint documentation.
{
"extends": "@contactlab/stylelint-config",
"rules": {
"selector-id-pattern": null,
"selector-class-pattern": null
}
}
add the following code to your .vscode/settings.json
:
{
"css.validate": false,
"scss.validate": false,
"editor.codeActionsOnSave": {
"source.fixAll.stylelint": true
},
"stylelint.validate": ["css"] // Add the type of file you want to validate (e.g. ["css", "scss", "typescript", "typescriptreact"])
}