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

Deprecate rules for sorting Vue, Svelte and Astro attributes #175

Closed
azat-io opened this issue Jul 22, 2024 · 10 comments
Closed

Deprecate rules for sorting Vue, Svelte and Astro attributes #175

azat-io opened this issue Jul 22, 2024 · 10 comments
Labels
enhancement New feature or request

Comments

@azat-io
Copy link
Owner

azat-io commented Jul 22, 2024

Three rules were added in version 2.0.0:

  • sort-vue-attributes
  • sort-svelte-attributes
  • sort-astro-atttributes

At the moment I'm thinking about giving them up. There are several reasons for this:

  1. These rules use non-standard JavaScript or TypeScript syntax. For this reason, we have to use other parsers along with them:

    That's a hard thing to maintain.

  2. These rules extend beyond the plugin’s core ideology. The primary goal is to support sorting various elements that are part of the JavaScript, TypeScript, or JSX/TSX language standards.

    Supporting third-party libraries and frameworks could make the plugin unwieldy and complicated for users.

    Currently, we only plan to support standard pieces.

  3. There are already similar ESLint rules:

    These rules could serve as adequate replacements.

I have a suggestion, move the missing functionality to ESLint plugins Vue, Svelte and Astro and maintain it there. First of all, it is the ability to sort attributes not only alphabetically, but also by line length.

The Astro plugin currently lacks this rule, so it could be transferred in its entirety.

I was interested to hear @ota-meshi opinion as the author of these plugins.

I would also like to hear the opinions of other users of the plugin.

@azat-io azat-io added the enhancement New feature or request label Jul 22, 2024
@Ericlm
Copy link

Ericlm commented Jul 23, 2024

I think this is a good idea! I'm using Vue, and I already have the eslint plugin grouping Vue attributes. Adding perfectionist required to build customGroups (see #112).
A difference with eslint-vue is that perfectionist can sort elements of the same group (where eslint-vue just requires groups to be sorted). So eslint-vue cannot completely replace sort-vue-attributes.
I think this is great to separate the package-specific rules from the standard perfectionist rules. (would be also clearer on the website).
And thank you for this plugin! 😀

@idmytro
Copy link

idmytro commented Sep 10, 2024

vue/attributes-order is better than nothing.
Your rule looks like more powerful, but it doesn't work well.

@azat-io
Copy link
Owner Author

azat-io commented Sep 11, 2024

@idmytro We need to have the same rule in eslint-plugin-astro to make it all deprecated

@myrica1030
Copy link

myrica1030 commented Sep 15, 2024

vue/attributes-order can't customize matches; for example, if I want to put class and style in front relative to other tags, perfectionist supports this very well.

The only downside is that I can't ignore “:” when ordering, tags starting with “:” are always higher than other tags.

Of course, if you don't have the energy to maintain it all, I show my support for you. After all, open source projects are just generating power with love and doing what you like ~ thank you for your efforts!

@azat-io
Copy link
Owner Author

azat-io commented Sep 16, 2024

Before deprecating the rules, we plan to improve the rules in the corresponding ESLint plugins. Also we plan to add features to the vue/attributes-order rule.

@azat-io
Copy link
Owner Author

azat-io commented Oct 15, 2024

Added in 46790ea.
Releases in v3.9.0.

@azat-io azat-io closed this as completed Oct 15, 2024
@azat-io azat-io mentioned this issue Oct 27, 2024
8 tasks
@fvilers
Copy link

fvilers commented Nov 10, 2024

I'm a Svelte developer and I love perfectionist a lot as it matches my taste on code organisation. The sort-svelte-attributes suits my needs. I understand why it is deprecated and why it should be removed from this package. But I can't find how to configure svelte/sort-attributes to behave the same way than the perfectionist one does. Could you provide some guidance or a migration guide to match the same rule behavior?

@azat-io
Copy link
Owner Author

azat-io commented Nov 10, 2024

@fvilers Can you tell me what settings you have used previously? And what is missing in svelte/sort-attributes?

@fvilers
Copy link

fvilers commented Nov 10, 2024

Out of the box the natural rule was really fine. I just configured it as this:

{
    type: 'natural',
    order: 'asc',
    customGroups: { this: 'this' },
    groups: [ 'this' ]
  }

The problem with svelte/sort-attributes is that it doesn't sort non svelte attribute (html ones) or I have missed something.

@azat-io
Copy link
Owner Author

azat-io commented Nov 10, 2024

@ota-meshi Can we create an issue in https://github.com/sveltejs/eslint-plugin-svelte ?

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

No branches or pull requests

5 participants