azat-io / eslint-plugin-perfectionist

☂️ ESLint plugin for sorting various data such as objects, imports, types, enums, JSX props, etc.
https://perfectionist.dev
MIT License
1.87k stars 37 forks source link

Bug: sort-union-types broken #33

Closed k-teplyakov closed 1 year ago

k-teplyakov commented 1 year ago

Describe the bug

sort-union-types considers an inline comment as part of a union type and breaks it by sorting it

Code example

This case is ok

-    accountTypeIds?: (1 | 2 | 3 | 4 | 5 | 100)[]; // Specific Account type Ids to filter accounts. Example: 2
+    accountTypeIds?: (100 | 5 | 4 | 3 | 2 | 1)[]; // Specific Account type Ids to filter accounts. Example: 2

And here is the problem

-    accountTypeId: 1 | 2 | 3 | 4 | 5 | 100; // Account type ID. Example: 3
+    accountTypeId: 100 | // Account type ID. Example: 3 5 | 4 | 3 | 2 | 1;

ESLint version

8.21.0

ESLint Plugin Perfectionist version

1.5.0

Additional comments

No response

Validations

azat-io commented 1 year ago

Thank you for issue. I think I can look into this more on Friday.

azat-io commented 1 year ago

Fixed in 95560abdad35184a3d88598fccc7e45956804a4b.

Release is coming soon.

azat-io commented 1 year ago

Released in v2.0.0