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

[eslint-plugin] sort keys rule should sort object keys when applying fix #787

Open
nmn opened this issue Nov 30, 2024 · 5 comments
Open
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@nmn
Copy link
Contributor

nmn commented Nov 30, 2024

The sort-keys rule in @stylexjs/eslint-plugin correctly detects any key in a style object that is not sorted as it should be. (This is not alphabetical, but ordered according to style specificity).

The issue is with the auto-fix offered. It only moves the particular key that is not sorted correctly, but it can often leave behind additional lint warnings in the same style object.

Expected behaviour"
When the auto-fix is applied, the entire object should be sorted as expected such that there are no lint warnings after the auto-fix.

@nmn nmn added good first issue Good for newcomers help wanted Extra attention is needed labels Nov 30, 2024
@yousoumar
Copy link
Contributor

yousoumar commented Nov 30, 2024

Hi @nmn ! I'm looking at it but cannot reproduce it. Do you have an example?

@nmn
Copy link
Contributor Author

nmn commented Dec 1, 2024

Here's a screen recording of the problem.

Screen.Recording.2024-12-01.at.2.05.46.PM.mov

Expected behavior: auto-fixing any error should sort all keys in the object.

@yousoumar
Copy link
Contributor

yousoumar commented Dec 2, 2024

Thanks for the example. You are clicking on “fix this line”, isn't that what's supposed to do? Can ESLint itself do otherwise? Also, what about the fact that on save in Visual Studio Code with the ESLint plugin, all the warnings are being fixed at once (at least in my case)?

@nmn
Copy link
Contributor Author

nmn commented Dec 4, 2024

@yousoumar The problem is that fixing one problem can create another problem. Notice how when I fix the left, it opacity becomes a problem again.

The only way an autofix for sorting keys can work is if all the keys on the current level are sorted.

@yousoumar
Copy link
Contributor

yousoumar commented Dec 8, 2024

I see @nmn, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants