Stylelint rule to disallow specified syntax, similar to ESLint
no-restricted-syntax
.
npm install stylelint-no-restricted-syntax --save
Add this config to your .stylelintrc
:
{
"plugins": ["stylelint-no-restricted-syntax"],
"rules": {
"plugin/no-restricted-syntax": [
[
{
"selector": "rule[selector='a']",
"message": "Anchors not allowed."
},
{
"selector": "decl[prop='z-index']",
"message": "z-index not allowed."
}
]
]
}
}
Each restricted syntax rule consists of the following properties:
Property | Type | Description |
---|---|---|
selector |
string |
Selector for querying PostCSS AST. |
message |
string |
Error message for queried PostCSS node. |
a {
z-index: 10;
}
/** ↑
* Previous line will be considered as restricted syntax */
b {
font-weight: bold;
}
MIT © Ivan Nikolić