diff --git a/rules/sort-classes.types.ts b/rules/sort-classes.types.ts index b84dffc4b..78839c14a 100644 --- a/rules/sort-classes.types.ts +++ b/rules/sort-classes.types.ts @@ -1,6 +1,6 @@ import type { JSONSchema4 } from '@typescript-eslint/utils/json-schema' -import type { Join } from '../typings' +import type { JoinWithDash } from '../typings' import { buildCustomGroupModifiersJsonSchema, @@ -36,6 +36,18 @@ export type SingleCustomGroup = | BaseSingleCustomGroup | AdvancedSingleCustomGroup +export type NonDeclarePropertyGroup = JoinWithDash< + [ + PublicOrProtectedOrPrivateModifier, + StaticOrAbstractModifier, + OverrideModifier, + ReadonlyModifier, + DecoratedModifier, + OptionalModifier, + PropertySelector, + ] +> + export type Selector = | AccessorPropertySelector | FunctionPropertySelector @@ -47,27 +59,27 @@ export type Selector = | PropertySelector | MethodSelector -export type NonDeclarePropertyGroup = Join< +export type FunctionPropertyGroup = JoinWithDash< [ PublicOrProtectedOrPrivateModifier, - StaticOrAbstractModifier, + StaticModifier, OverrideModifier, ReadonlyModifier, DecoratedModifier, - OptionalModifier, - PropertySelector, + AsyncModifier, + FunctionPropertySelector, ] > -export type FunctionPropertyGroup = Join< +export type MethodGroup = JoinWithDash< [ PublicOrProtectedOrPrivateModifier, - StaticModifier, + StaticOrAbstractModifier, OverrideModifier, - ReadonlyModifier, DecoratedModifier, AsyncModifier, - FunctionPropertySelector, + OptionalModifier, + MethodSelector, ] > @@ -82,19 +94,7 @@ export type Modifier = | StaticModifier | AsyncModifier -export type MethodGroup = Join< - [ - PublicOrProtectedOrPrivateModifier, - StaticOrAbstractModifier, - OverrideModifier, - DecoratedModifier, - AsyncModifier, - OptionalModifier, - MethodSelector, - ] -> - -export type DeclarePropertyGroup = Join< +export type DeclarePropertyGroup = JoinWithDash< [ DeclareModifier, PublicOrProtectedOrPrivateModifier, @@ -105,7 +105,7 @@ export type DeclarePropertyGroup = Join< ] > -export type GetMethodOrSetMethodGroup = Join< +export type GetMethodOrSetMethodGroup = JoinWithDash< [ PublicOrProtectedOrPrivateModifier, StaticOrAbstractModifier, @@ -115,7 +115,7 @@ export type GetMethodOrSetMethodGroup = Join< ] > -export type AccessorPropertyGroup = Join< +export type AccessorPropertyGroup = JoinWithDash< [ PublicOrProtectedOrPrivateModifier, StaticOrAbstractModifier, @@ -125,11 +125,11 @@ export type AccessorPropertyGroup = Join< ] > -export type IndexSignatureGroup = Join< +export type IndexSignatureGroup = JoinWithDash< [StaticModifier, ReadonlyModifier, IndexSignatureSelector] > -export type ConstructorGroup = Join< +export type ConstructorGroup = JoinWithDash< [PublicOrProtectedOrPrivateModifier, ConstructorSelector] > diff --git a/rules/sort-modules.types.ts b/rules/sort-modules.types.ts index eebc526e6..fa1af6bb5 100644 --- a/rules/sort-modules.types.ts +++ b/rules/sort-modules.types.ts @@ -1,6 +1,6 @@ import type { JSONSchema4 } from '@typescript-eslint/utils/json-schema' -import type { Join } from '../typings' +import type { JoinWithDash } from '../typings' import { buildCustomGroupModifiersJsonSchema, @@ -99,27 +99,27 @@ interface BaseSingleCustomGroup { selector?: T } -type NonDefaultClassGroup = Join< +type NonDefaultClassGroup = JoinWithDash< [ExportModifier, DeclareModifier, DecoratedModifier, ClassSelector] > -type DefaultFunctionGroup = Join< +type DefaultFunctionGroup = JoinWithDash< [ExportModifier, DefaultModifier, AsyncModifier, FunctionSelector] > -type DefaultClassGroup = Join< +type DefaultClassGroup = JoinWithDash< [ExportModifier, DefaultModifier, DecoratedModifier, ClassSelector] > -type NonDefaultInterfaceGroup = Join< +type NonDefaultInterfaceGroup = JoinWithDash< [ExportModifier, DeclareModifier, InterfaceSelector] > -type NonDefaultFunctionGroup = Join< +type NonDefaultFunctionGroup = JoinWithDash< [ExportModifier, DeclareModifier, FunctionSelector] > -type DefaultInterfaceGroup = Join< +type DefaultInterfaceGroup = JoinWithDash< [ExportModifier, DefaultModifier, InterfaceSelector] > @@ -131,9 +131,9 @@ interface ElementNamePatternFilterCustomGroup { elementNamePattern?: string } -type TypeGroup = Join<[ExportModifier, DeclareModifier, TypeSelector]> +type TypeGroup = JoinWithDash<[ExportModifier, DeclareModifier, TypeSelector]> -type EnumGroup = Join<[ExportModifier, DeclareModifier, EnumSelector]> +type EnumGroup = JoinWithDash<[ExportModifier, DeclareModifier, EnumSelector]> type DecoratedModifier = 'decorated' diff --git a/rules/sort-object-types.types.ts b/rules/sort-object-types.types.ts index 14d9d8681..5f26f6023 100644 --- a/rules/sort-object-types.types.ts +++ b/rules/sort-object-types.types.ts @@ -1,6 +1,6 @@ import type { JSONSchema4 } from '@typescript-eslint/utils/json-schema' -import type { Join } from '../typings' +import type { JoinWithDash } from '../typings' import { buildCustomGroupModifiersJsonSchema, @@ -75,7 +75,7 @@ type CustomGroup = ( groupName: string } -type IndexSignatureGroup = Join< +type IndexSignatureGroup = JoinWithDash< [ OptionalModifier, RequiredModifier, @@ -101,22 +101,22 @@ interface BaseSingleCustomGroup { selector?: T } -type PropertyGroup = Join< +type PropertyGroup = JoinWithDash< [OptionalModifier, RequiredModifier, MultilineModifier, PropertySelector] > -type MemberGroup = Join< +type MemberGroup = JoinWithDash< [OptionalModifier, RequiredModifier, MultilineModifier, MemberSelector] > -type MethodGroup = Join< +type MethodGroup = JoinWithDash< [OptionalModifier, RequiredModifier, MultilineModifier, MethodSelector] > /** * @deprecated For {@link `MultilineModifier`} */ -type MultilineGroup = Join< +type MultilineGroup = JoinWithDash< [OptionalModifier, RequiredModifier, MultilineSelector] > diff --git a/typings/index.ts b/typings/index.ts index a754e0285..6beb32cd7 100644 --- a/typings/index.ts +++ b/typings/index.ts @@ -1,2 +1,2 @@ +export type { JoinWithDash } from './join-with-dash' export type { SortingNode } from './sorting-node' -export type { Join } from './join' diff --git a/typings/join.ts b/typings/join-with-dash.ts similarity index 59% rename from typings/join.ts rename to typings/join-with-dash.ts index c901beebf..e7a73c247 100644 --- a/typings/join.ts +++ b/typings/join-with-dash.ts @@ -1,10 +1,10 @@ -export type Join = T extends [ +export type JoinWithDash = T extends [ infer First extends string, ...infer Rest extends string[], ] ? Rest extends [] ? `${First}` - : `${WithDashSuffixOrEmpty}${Join}` + : `${WithDashSuffixOrEmpty}${JoinWithDash}` : never type WithDashSuffixOrEmpty = `${T}-` | ''