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

Feature: sort interface properties, object keys and array values if code has annotation #400

Open
2 tasks done
sardor01 opened this issue Nov 27, 2024 · 3 comments
Open
2 tasks done
Labels
enhancement New feature or request

Comments

@sardor01
Copy link

Describe the rule

There is existing package that implements similar feature: https://github.com/ronparkdev/eslint-plugin-annotation

I personally think it would be great if eslint-plugin-perfectionist provided thie rule since it's also related to sorting.

Code example

| sort | sort-keys |

Additional comments

No response

Validations

  • Read the docs.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
@sardor01 sardor01 added the enhancement New feature or request label Nov 27, 2024
@azat-io
Copy link
Owner

azat-io commented Nov 27, 2024

Currently, you can use ESLint comments to define plugin rule settings.

/*
  eslint perfectionist/sort-objects: [
    'error',
    {
      type: 'alphabetical',
      order: 'asc',
      partitionByNewLine: true
    }
  ]
*/

Using annotations looks beautiful and convenient. But I'm not sure it will be in demand.

I would like to hear more opinions from other users.

@hugop95
Copy link
Contributor

hugop95 commented Nov 27, 2024

I understand the use case for sort-array-includes: it would allow users to sort arrays who do not have .include if the user wishes.

However, I'm not sure to understand the use case with other rules such as sort-objects: all objects get sorted if the rule is active, why would an annotation be needed?

@azat-io
Copy link
Owner

azat-io commented Nov 27, 2024

@sardor01 Perhaps the ESLint comment solves your problem?

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

3 participants