简体   繁体   中英

Stylelint rule to value-keyword-case to ignore camelCase variables

I am using stylelint and I have a custom color variables used in several properties such as border, background, color.

Example:

border: 1px solid t(lightGray);
background-color: t(lightBlue);
background-color: var(--lightBlue);

When I run stylelint I get the error, Expected "lightBlue" value-keyword-case to be "lightblue".

How do I create a regex to ignore any variable inside t() or var(--) or ignore camelCasing in values?

https://stylelint.io/user-guide/rules/value-keyword-case#ignorekeywords-regex-regex-non-regex

Current rules:

{
    "extends": "stylelint-config-standard",
    "rules": {
        "indentation": "tab",
        "string-quotes": "double",
        "no-duplicate-selectors": true,
        "color-hex-case": "upper",
        "color-named": "always-where-possible",
        "selector-combinator-space-after": "always",
        "selector-attribute-operator-space-before": "always",
        "selector-attribute-operator-space-after": "always",
        "declaration-block-trailing-semicolon": "always",
        "declaration-colon-space-before": "never",
        "declaration-colon-space-after": "always",
        "number-leading-zero": "always",
        "comment-empty-line-before": "always",
        "rule-empty-line-before": "always-multi-line",
        "selector-pseudo-element-colon-notation": "double",
        "media-feature-parentheses-space-inside": "always",
        "value-keyword-case": "lower"
    }
}

TIA

I just stumbled across the same problem. You might try something like this:

{
  "rules": {
    "value-keyword-case": ["lower", {
      ignoreFunctions: ["t", "var"]
    }]
  }
}

It seems like they updated their docs recently :)

https://stylelint.io/user-guide/rules/value-keyword-case#ignorekeywords-regex-regex-non-regex

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM