build: add BEM style lint rule

This commit is contained in:
Emil Zhai 2021-12-10 16:41:59 +08:00
parent 09f567f509
commit b4ed1be170
No known key found for this signature in database
GPG Key ID: 780B385DB72F1EBD
1 changed files with 8 additions and 0 deletions

View File

@ -24,6 +24,14 @@ module.exports = {
"no-empty-source": null, "no-empty-source": null,
"no-descending-specificity": null, "no-descending-specificity": null,
"number-leading-zero": "never", "number-leading-zero": "never",
"selector-class-pattern": [
// Matches class name likes this: block__elem--mod or block1__elem1--mod1-block2__elem2--mod2-...
/^(?:(weui|ant|BraftEditor)-[a-zA-Z-_]+|(?:(?:(?:^|(?!^)-)[a-z]+\d*|-[a-z]*\d+)(?:__[a-z]+\d*|__[a-z]*\d+){0,1}(?:--[a-z]+\d*|--[a-z]*\d+){0,1})*)$/u, {
"severity": "error",
"resolveNestedSelectors": true,
"message": "Selector should be written in BEM style (selector-class-pattern)",
},
],
"selector-id-pattern": /^\$?[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u, "selector-id-pattern": /^\$?[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,
"selector-max-compound-selectors": null, "selector-max-compound-selectors": null,
"selector-no-qualifying-type": null, "selector-no-qualifying-type": null,