stylex: [Bug] Properties not recognized by eslint-plugin
The problem
The outlineOffset
property is not recognized by the eslint-plugin.
How to reproduce
With the following code:
import * as stylex from '@stylexjs/stylex';
export const styles = stylex.create({
container: {
outlineOffset: '2px', // eslint(@stylexjs/valid-styles) error here
},
});
I have the following eslint error from @stylex/valid-styles
:
outlineOffset value must be one of:
'outlineOffset' is not supported yet. Please use 'outline' instead
But outline
syntax does not allow an offset:
outline =
<'outline-color'> ||
<'outline-style'> ||
<'outline-width'>
Cf. https://developer.mozilla.org/en-US/docs/Web/CSS/outline
About this issue
- Original URL
- State: open
- Created 7 months ago
- Reactions: 1
- Comments: 20 (9 by maintainers)
Commits related to this issue
- Update stylex-valid-styles.js issue-:#135 — committed to xonx4l/stylex by xonx4l 7 months ago
NOTE: A few properties are intentionally not allowed by the ESLint plugin even though they will work correctly in the Babel plugin:
background
transition
animation
border
,border[Direction]
.flex
This decision was made for a few reasons:
transitions
,animations
, andbackground
are all properties where many combinations of the same values may be used.We are going to be discussing and reconsidering this decision.
Any other missing property is an unknown bug so please report!
Here’s a running list so far:
outline
longhandsplaceItems
placeContent
textDecorationThickness
@nmn This is perfect valid CSS.
@nmn I posted about this on Workplace too, but we should probably add
zoom
. It has some caveats but can be more useful thantransform: scale(...)
because it also affects the layout size of the element. The CSS WG recognises the value it provides and are working on standardising it, and today it works in all major browsers, except Firefox where it’s gated by anabout:config
setting.scrollSnapStop
Both scrollbarWidth and “::-webkit-scrollbar”
scrollbarWidth: “none”, “::-webkit-scrollbar”: { display: “none”, },
transition
won’t be allowed becuase…One of the other reasons not mentioned is that we want to have consistent merging rules for properties (like React Native), and that doesn’t mix with allowing shorthands that can set values for several different properties (which also has an impact on the usefulness of their Types).
outline
shouldn’t be allowed in source code, and if there’s a browser compat issue then the compiler can convert tooutline
in the output.flex
should be allowed, but only with support for a single numeric value>=0
(e.g.,flex: 1
), as is done in React Native (excluding the-1
value allowed in RN)@olivierpascal I’ll add them to the list of missing properties in the ESLint plugin that should be allowed.
placeContent
andplaceItems
are not intentionally disallowed.https://github.com/facebook/stylex/blob/f968076548895dd1adc9736f1bfc371057beb94e/packages/eslint-plugin/src/stylex-valid-styles.js#L932
lineHeight
could be a string tooThere’s a few other missing properties in the ESLint rule. You can find them and create a PR to add them.
I can work on this , looks interesting
Well noted, thanks. Maybe the eslint error message should be more explicit about it, encouraging using individual properties like transitionProperty, transitionDuration and transitionTimingFunction?
Same for
transition
: