stylex icon indicating copy to clipboard operation
stylex copied to clipboard

ESLint should fail when using background or border property

Open skovhus opened this issue 10 months ago • 3 comments

Describe the issue

ESLint plugin doesn't warn about using background or border.

Expected behavior

It should warn

Steps to reproduce

Just add background or border as a property to stylex.props

Test case

No response

Additional comments

No response

skovhus avatar Jan 22 '26 12:01 skovhus

Hi! I'd like to work on this issue. I'm planning to check how the valid-styles ESLint rule handles background and border shorthands, then add the appropriate validation and tests. Is this approach okay, and is anyone already working on it?

anishsinghhh3-bit avatar Oct 26 '26 17:10 anishsinghhh3-bit

Thanks @anishsinghhh3-bit.

Just add background or border as a property to stylex.props

I assume it meant stylex.create?

From what I can see @stylexjs/valid-styles does flag using border but not background. The @stylexjs/valid-shorthands will flag either if they are multi-value. If looks like you can back background with @stylexjs/valid-styles by passing propLimits config:

'@stylexjs/valid-styles': ['error', {
  propLimits: {
    background: {
      limit: null,
      reason: 'Use backgroundColor, backgroundImage, etc. instead.',
    },
  },
}],

If you understand the issue enough it would be great to have some more examples/steps to recreate because it's not clear. Thanks!

henryqdineen avatar Oct 26 '26 20:10 henryqdineen

Thanks for checking this! I think I got the idea, I'll look into how these rules works and try to reproduce the issue with some simple examples. I'll also check the propLimits thing you mentioned and see if thats already enough to fix it. Once I figure it out properly, I'll share the steps here.

anishsinghhh3-bit avatar Oct 27 '26 07:10 anishsinghhh3-bit