AndyOGo / stylelint-declaration-strict-value

Specify properties for which a variable, function, keyword or value must be used.
MIT License
133 stars 10 forks source link

Support CSS-in-JS with postcss-styled-syntax #326

Closed EvgenyOrekhov closed 10 months ago

EvgenyOrekhov commented 10 months ago

I use postcss-styled-syntax and I get false warnings.

Config:

{
  "customSyntax": "postcss-styled-syntax",

  "plugins": [
    "stylelint-scales"
  ],

  "rules": {
    "scale-unlimited/declaration-strict-value": [
      "/color$/",
      {
        "ignoreVariables": true,
        "ignoreFunctions": false,
        "ignoreKeywords": ["currentColor", "transparent", "inherit"],
        "disableFix": true
      }
    ]
  }
}

Code:

import styled from "styled-components";

export const Button = styled.button`
  color: ${(props) => props.theme.colors.button};
`;
stylelint --fix '**/*.tsx'

test.tsx
 4:3  ✖  Expected variable, function or keyword for "=>" of "color"  scale-unlimited/declaration-strict-value
AndyOGo commented 10 months ago

Thanks for your issue.

Though to support CCS-in-JS, this plugin would need a parser for ECMAScript and that is out of the scope of this plugin.