Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xi/stylelint-selector-pattern
A stylelint plugin that allows to check selectors with regular expressions.
https://github.com/xi/stylelint-selector-pattern
stylelint
Last synced: about 1 month ago
JSON representation
A stylelint plugin that allows to check selectors with regular expressions.
- Host: GitHub
- URL: https://github.com/xi/stylelint-selector-pattern
- Owner: xi
- License: mit
- Created: 2017-02-17T08:39:31.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-07-12T21:37:12.000Z (over 7 years ago)
- Last Synced: 2024-11-14T11:23:21.884Z (about 2 months ago)
- Topics: stylelint
- Language: JavaScript
- Homepage:
- Size: 6.84 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# stylelint-selector-pattern
A [stylelint](https://github.com/stylelint/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": "^\\."
}]