From 3e4cd493caab4cbbdc2243d3b2b6b9e7cde17aa4 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Wed, 15 Nov 2023 17:53:17 +0100 Subject: [PATCH] lint --- src/index.ts | 16 ++++++++-------- src/types.ts | 19 +++++++++---------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/index.ts b/src/index.ts index a274f4c..a32e360 100644 --- a/src/index.ts +++ b/src/index.ts @@ -19,11 +19,11 @@ export function isUppercase(char = ""): boolean | undefined { export function splitByCase(string_: T): SplitByCase; export function splitByCase< T extends string, - Separator extends readonly string[] + Separator extends readonly string[], >(string_: T, separators: Separator): SplitByCase; export function splitByCase< T extends string, - Separator extends readonly string[] + Separator extends readonly string[], >(string_: T, separators?: Separator) { const splitters = separators ?? STR_SPLITTERS; const parts: string[] = []; @@ -91,7 +91,7 @@ export function lowerFirst(string_: S): Uncapitalize { export function pascalCase(): ""; export function pascalCase( - string_: T + string_: T, ): PascalCase; export function pascalCase(string_?: T) { return string_ @@ -103,7 +103,7 @@ export function pascalCase(string_?: T) { export function camelCase(): ""; export function camelCase( - string_: T + string_: T, ): CamelCase; export function camelCase(string_?: T) { return lowerFirst(pascalCase(string_ || "")) as CamelCase; @@ -111,15 +111,15 @@ export function camelCase(string_?: T) { export function kebabCase(): ""; export function kebabCase( - string_: T + string_: T, ): KebabCase; export function kebabCase< T extends string | readonly string[], - Joiner extends string + Joiner extends string, >(string_: T, joiner: Joiner): KebabCase; export function kebabCase< T extends string | readonly string[], - Joiner extends string + Joiner extends string, >(string_?: T, joiner?: Joiner) { return string_ ? ((Array.isArray(string_) ? string_ : splitByCase(string_ as string)) @@ -130,7 +130,7 @@ export function kebabCase< export function snakeCase(): ""; export function snakeCase( - string_: T + string_: T, ): SnakeCase; export function snakeCase(string_?: T) { return kebabCase(string_ || "", "_") as SnakeCase; diff --git a/src/types.ts b/src/types.ts index 0a9e812..fcf36d4 100644 --- a/src/types.ts +++ b/src/types.ts @@ -102,14 +102,14 @@ export type SplitByCase< type JoinByCase = string extends T ? string : string[] extends T - ? string - : T extends string - ? SplitByCase extends readonly string[] - ? JoinLowercaseWords, Joiner> - : never - : T extends readonly string[] - ? JoinLowercaseWords - : never; + ? string + : T extends string + ? SplitByCase extends readonly string[] + ? JoinLowercaseWords, Joiner> + : never + : T extends readonly string[] + ? JoinLowercaseWords + : never; export type PascalCase = string extends T ? string @@ -129,10 +129,9 @@ export type CamelCase = string extends T ? string : Uncapitalize>; - export type KebabCase< T extends string | readonly string[], - Joiner extends string = "-" + Joiner extends string = "-", > = JoinByCase; export type SnakeCase = JoinByCase<