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.66k stars 30 forks source link

Feature: Add a sort-intersection-types rule? #84

Closed JoshuaKGoldberg closed 2 months ago

JoshuaKGoldberg commented 8 months ago

Describe the rule

https://eslint-plugin-perfectionist.azat.io/rules/sort-union-types exists for union types, but what about intersection types?

Code example

// ❌ Incorrect
type Both =
  & { b: 1 }
  & { a: 1 }

// ✅ Correct
type Both =
  & { a: 1 }
  & { b: 1 }

Additional comments

We intentionally named https://typescript-eslint.io/rules/sort-type-constituents as "type constituents" because that refers to the constituents in both intersection and union types. Fun fact!

Validations

azat-io commented 8 months ago

Nice idea! I'll add it. ❤️️️