hudochenkov / postcss-styled-syntax

PostCSS syntax for CSS-in-JS like styled-components
MIT License
69 stars 4 forks source link

stylelint-require-units incompatibility (false positives) #5

Closed rdgomt closed 1 year ago

rdgomt commented 1 year ago

Hi! I am trying to migrate from postcss-styled-components, but I am facing an issue with a stylelint plugin called matterialize/stylelint-require-units. Here are the false positives that are showing:

Captura de Tela 2023-01-30 às 17 30 04 Captura de Tela 2023-01-30 às 17 30 13
hudochenkov commented 1 year ago

Hey! Great to hear about more adoption :)

It should be fixed in the rule. This package produces AST (Abstract Syntax Tree) where property value is everything that comes after :. So in your case is is ${props => showBottomBorder ? 1 : 0}px. Many rules would not be prepared for such values.

In Stylelint we use isStandardSyntaxValue helper function in rules to ignore properties which have non-standard values like in your example. Then in rule we return early for non-standard syntax before rule make any checks. This approach ignores properties, which rule can't understand and produces no violations.

Please, open an issue in matterialize/stylelint-require-units repository, so they could adopt what Stylelint does.

rdgomt commented 1 year ago

Thank you for the explanation.