stylex
stylex copied to clipboard
[eslint-plugin] Update `valid-styles` rule to use a strict CSS value parser
The ESlint valid-styles rules was initially created by refactoring static types. As such, in many cases it allows arbitrary strings when only a particular CSS type should be allowed.
We have some occasional use regular expressions, but, overall, the the rule is far too permissive and easily allows invalid CSS values.
The Task
The ESLint rule should be updated to use a proper CSS value parser to properly validate the values used with StyleX. For example, a width must be a valid length, CSS variable or calc expression and not just any arbitrary string.
The nmn/css-value-parser can be used as the parser for this use-case. (See also, #721 and #722)