Skip to content

Commit

Permalink
refactor: renames Join to JoinWithDash
Browse files Browse the repository at this point in the history
  • Loading branch information
hugop95 committed Dec 13, 2024
1 parent 7da0ce5 commit 65d08bd
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 44 deletions.
52 changes: 26 additions & 26 deletions rules/sort-classes.types.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -36,6 +36,18 @@ export type SingleCustomGroup =
| BaseSingleCustomGroup<ConstructorSelector>
| AdvancedSingleCustomGroup<MethodSelector>

export type NonDeclarePropertyGroup = JoinWithDash<
[
PublicOrProtectedOrPrivateModifier,
StaticOrAbstractModifier,
OverrideModifier,
ReadonlyModifier,
DecoratedModifier,
OptionalModifier,
PropertySelector,
]
>

export type Selector =
| AccessorPropertySelector
| FunctionPropertySelector
Expand All @@ -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,
]
>

Expand All @@ -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,
Expand All @@ -105,7 +105,7 @@ export type DeclarePropertyGroup = Join<
]
>

export type GetMethodOrSetMethodGroup = Join<
export type GetMethodOrSetMethodGroup = JoinWithDash<
[
PublicOrProtectedOrPrivateModifier,
StaticOrAbstractModifier,
Expand All @@ -115,7 +115,7 @@ export type GetMethodOrSetMethodGroup = Join<
]
>

export type AccessorPropertyGroup = Join<
export type AccessorPropertyGroup = JoinWithDash<
[
PublicOrProtectedOrPrivateModifier,
StaticOrAbstractModifier,
Expand All @@ -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]
>

Expand Down
18 changes: 9 additions & 9 deletions rules/sort-modules.types.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -99,27 +99,27 @@ interface BaseSingleCustomGroup<T extends Selector> {
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]
>

Expand All @@ -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'

Expand Down
12 changes: 6 additions & 6 deletions rules/sort-object-types.types.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -75,7 +75,7 @@ type CustomGroup = (
groupName: string
}

type IndexSignatureGroup = Join<
type IndexSignatureGroup = JoinWithDash<
[
OptionalModifier,
RequiredModifier,
Expand All @@ -101,22 +101,22 @@ interface BaseSingleCustomGroup<T extends Selector> {
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]
>

Expand Down
2 changes: 1 addition & 1 deletion typings/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export type { JoinWithDash } from './join-with-dash'
export type { SortingNode } from './sorting-node'
export type { Join } from './join'
4 changes: 2 additions & 2 deletions typings/join.ts → typings/join-with-dash.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export type Join<T extends string[]> = T extends [
export type JoinWithDash<T extends string[]> = T extends [
infer First extends string,
...infer Rest extends string[],
]
? Rest extends []
? `${First}`
: `${WithDashSuffixOrEmpty<First>}${Join<Rest>}`
: `${WithDashSuffixOrEmpty<First>}${JoinWithDash<Rest>}`
: never

type WithDashSuffixOrEmpty<T extends string> = `${T}-` | ''

0 comments on commit 65d08bd

Please sign in to comment.