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

feat(multiple rules): Do not sort unknown elements if unknown is not referenced in groups #271

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

hugop95
Copy link
Contributor

@hugop95 hugop95 commented Sep 14, 2024

Description

The large majority of the actual code added involves documentation and tests.

Extends #220 to other rules that handle the unknown group.

When the unknown group is not entered by the user in the groups option, unknown group members will not be sorted and will remain where they are rather than go at the very bottom.

  • sort-astro-attributes
  • sort-interfaces
  • sort-intersection-types
  • sort-jsx-props
  • sort-object-types
  • sort-objects
  • sort-svelte-attributes
  • sort-union-types
  • sort-vue-attributes

The sort-imports rule takes into account other complex elements such as newline separation, making it very different than other rules. Left for another PR if needed.

Rules that had a default group configuration equal to [] now have ['unknown'] (otherwise, they would not sort anything by default).

Because all those rules rely on the same code to sort groups, a sortNodesByGroups function has been extracted, greatly reducing the amount of duplicate code.

No existing unit test was impacted.

  • Add tests

What is the purpose of this pull request?

  • New Feature

@hugop95 hugop95 force-pushed the feat/no-unknown-sort branch 3 times, most recently from c75beb7 to 92972d3 Compare September 14, 2024 12:50
@hugop95 hugop95 marked this pull request as ready for review September 14, 2024 13:14
@azat-io
Copy link
Owner

azat-io commented Sep 19, 2024

Could you fix merge conflicts?

@hugop95
Copy link
Contributor Author

hugop95 commented Sep 19, 2024

@azat-io Done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants