Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@stylexjs/eslint-plugin shows error for @stylexjs/valid-styles when using stylex.firstThatWorks #699

Open
lifeiscontent opened this issue Sep 27, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@lifeiscontent
Copy link

Describe the issue

when using stylex.firstThatWorks on a property, I'm seeing ESLint errors for @stylexjs/valid-styles

e.g.

const styles = stylex.create({
  example: {
    position: stylex.firstThatWorks("sticky", "fixed") // errors, but shouldn't
  }
})

Expected behavior

using the above code should work with ESLint Rule

Steps to reproduce

  1. use the example
  2. see ESLint showing error, even though the styles are valid.

Test case

No response

Additional comments

No response

@lifeiscontent lifeiscontent added the bug Something isn't working label Sep 27, 2024
@RavenColEvol
Copy link
Contributor

Thinking out loud here on possible solution, ofc there could be problems with it but still it's better to initiate a thought process on it.
From my assumption firstThatWorks may receive 2 types of values either variables or absolute values.
I have not seen code but 2 things might change

  1. firstThatWorks method: to have generic return type based on input. So it will make sure that scenarios like above are solved and it won't harm properties which don't expect strict unions ( like string | number )
  2. eslint valid-styles: we could have a case where position may receive value in form of variable. In that case it's a valid situation but still as a code we are unsure so maybe we can provide warning that it may not be the proper value or bypass variables from it.

What you say @nmn ?

@nmn
Copy link
Contributor

nmn commented Oct 1, 2024

This is an issue in the ESLint valid-styles rule. It is not correctly parsing firstThatWork and checking the arguments passed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants