What is stylelint-config-sass-guidelines?
stylelint-config-sass-guidelines is a shareable configuration for Stylelint that enforces the Sass Guidelines. It helps developers maintain consistent and clean Sass code by providing a set of rules and best practices.
What are stylelint-config-sass-guidelines's main functionalities?
Enforce BEM Naming Conventions
This rule enforces the Block-Element-Modifier (BEM) naming convention for class selectors, ensuring a consistent and readable structure.
module.exports = { "rules": { "selector-class-pattern": "^[a-z0-9\-]+(__[a-z0-9\-]+)?(--[a-z0-9\-]+)?$" } };
Disallow Vendor Prefixes
These rules disallow the use of vendor prefixes in properties and values, encouraging the use of autoprefixer for handling browser compatibility.
module.exports = { "rules": { "property-no-vendor-prefix": true, "value-no-vendor-prefix": true } };
Limit Nesting Depth
This rule limits the depth of nesting in Sass files to a maximum of 3 levels, promoting simpler and more maintainable code.
module.exports = { "rules": { "max-nesting-depth": 3 } };
Disallow Important
This rule disallows the use of !important in declarations, encouraging developers to find more specific and maintainable solutions.
module.exports = { "rules": { "declaration-no-important": true } };
Other packages similar to stylelint-config-sass-guidelines
stylelint-config-standard
stylelint-config-standard is a widely-used shareable configuration for Stylelint that enforces a set of standard rules for CSS. It is less specific to Sass but provides a solid foundation for maintaining consistent and clean CSS code.
stylelint-config-recommended-scss
stylelint-config-recommended-scss is a shareable configuration for Stylelint that provides a set of recommended rules for SCSS. It is similar to stylelint-config-sass-guidelines but focuses on general best practices for SCSS rather than adhering strictly to the Sass Guidelines.
stylelint-config-prettier
stylelint-config-prettier is a shareable configuration for Stylelint that turns off all rules that are unnecessary or might conflict with Prettier. It is useful for developers who use Prettier for code formatting and want to avoid conflicts between Stylelint and Prettier.
stylelint-config-sass-guidelines
A stylelint config inspired by sass-guidelin.es.
This linter has been designed / tested with SCSS syntax based on the SCSS guidelines documented in https://sass-guidelin.es/. It is intended for use with SCSS syntax, not Sass (tab style) syntax.
This config:
Installation
Using NPM
$ npm i -D stylelint postcss stylelint-config-sass-guidelines
Using Yarn
$ yarn add -D stylelint postcss stylelint-config-sass-guidelines
Using PNPM
$ pnpm add -D stylelint postcss stylelint-config-sass-guidelines
Usage
Set your stylelint config to:
{
"extends": "stylelint-config-sass-guidelines"
}
Extending the config
Simply add a "rules"
key to your config and add your overrides there.
For example:
{
"extends": "stylelint-config-sass-guidelines",
"rules": {
"selector-max-compound-selectors": 4,
"value-no-vendor-prefix": false
}
}
Documentation
Configured lints
This is a list of the lints turned on in this configuration, and what they do.
At-Rule
Block
Color
Declaration Block
Declaration Property
declaration-property-value-disallowed-list
: Specify a list of disallowed property and value pairs within declarations.
^border
: Disallow the use of the word none
for borders, use 0
instead. The intent of this rule is to enforce consistency, rather than define which is "better."
Function
General
Media Feature
Property
Rule
rule-empty-line-before
: There must always be an empty line before multi-line rules. Except: Nested rules that are the first of their parent rule. Ignore: Rules that come after a comment.
SCSS
Selector
Stylistic
Value
Contributors
stylelint-config-sass-guidelines is maintained by Brett Jankord and contributions from the community. Without the code contributions from all these fantastic people, stylelint-config-sass-guidelines would not exist.