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: sort-intersection-types and anonymous types #128

Open Evalon opened 1 month ago

Evalon commented 1 month ago

What rule do you want to change?

sort-intersection-types

Describe the problem

Consider this type: { apiKey: string | null } & Config I think it's better for readability if named (aliased) types (Config) are followed by anonymous types ({ apiKey: string | null }). Also, it feels more explicit in intention.

Code example

constructor(props: { apiKey: string | null } & Config) {
    super(props)
    this.apiKey = props.apiKey
}
--- VS
constructor(props: Config & { apiKey: string | null }) {
    super(props)
    this.apiKey = props.apiKey
}

Additional comments

No response

Validations