azat-io / eslint-plugin-perfectionist

🦄 ESLint plugin for sorting various data such as objects, imports, types, enums, JSX props, etc.
https://eslint-plugin-perfectionist.azat.io
MIT License
1.62k stars 28 forks source link

Feature: Add partition-by-comment option to sort-enums #111

Closed JoshuaKGoldberg closed 2 months ago

JoshuaKGoldberg commented 2 months ago

What rule do you want to change?

sort-enums

Describe the problem

23 added a partition-by-comment option to the sort-objects rule (thanks again!). Which is great. No complaints for objects!

But, TypeScript enums also experience the same root behavior as #22. Could we also add the option to the sort-enums rule please?

https://github.com/typescript-eslint/typescript-eslint/blob/25ea953cc60b118bd385c71e0a9b61c286c26fcf/packages/ast-spec/src/ast-token-types.ts has an example enum that intentionally moves some properties to the end.

Code example

export enum AST_TOKEN_TYPES {
  Boolean = 'Boolean',
  Identifier = 'Identifier',
  JSXIdentifier = 'JSXIdentifier',
  JSXText = 'JSXText',
  Keyword = 'Keyword',
  Null = 'Null',
  Numeric = 'Numeric',
  Punctuator = 'Punctuator',
  RegularExpression = 'RegularExpression',
  String = 'String',
  Template = 'Template',

  // comment types
  Block = 'Block',
  Line = 'Line',
}

Additional comments

I'd be happy to send this PR if it's essentially a copy & paste of #23! 🙂

Validations

azat-io commented 2 months ago

Released in v2.7.0.

JoshuaKGoldberg commented 2 months ago

Awesome, thanks @azat-io! 🙏

azat-io commented 2 months ago

Thanks to @chirokas ❤️