| Name | Size |
|---|---|
| .gitignore | 22B |
| .travis.yml | 86B |
| LICENSE | 1078B |
| README.md | 1080B |
| index.js | 1301B |
| lib/presets.js | 705B |
| lib/util.js | 635B |
| lib/validate.js | 620B |
| package.json | 857B |
| test/index.js | 3044B |
stylelint-selector-pattern
A stylelint plugin that allows to check selectors with regular expressions.
Installation
npm install stylelint-selector-pattern
Simple Usage
Add it to the plugin section in your stylelint config and specify a regular
expression in the rules section:
// .stylelintrc
{
"plugins": [
"stylelint-selector-pattern"
],
"rules": {
// ...
"xi/selector-pattern": "^\.[a-z-]+$",
// ...
}
}
Instead of a pattern, you can also use the name of one of the presets: bem,
suit, and itcss.
Options
In order to not keep the pattern readable, you can use the subpatterns option:
"xi/selector-pattern": ["^{component}({modifier}|{element})?$", {
"subpatterns": {
"component": "\.[a-z-]+",
"modifier": "--[a-z-]+",
"element": "__[a-z-]+"
}
}]
You can also filter the selectors that the rule should apply to:
"xi/selector-pattern": ["^\.[a-z-]+$", {
"filter": "^\\."
}]