From 5b705d4b047640e91b690566d6e0fdbae17bb842 Mon Sep 17 00:00:00 2001 From: Shinigami Date: Wed, 1 Feb 2023 14:04:18 +0100 Subject: infra: configure lint rule array-type (#1793) --- src/modules/helpers/index.ts | 4 ++-- src/modules/internet/index.ts | 6 ++---- src/modules/random/index.ts | 6 +++--- src/modules/string/index.ts | 16 ++++++++++------ 4 files changed, 17 insertions(+), 15 deletions(-) (limited to 'src/modules') diff --git a/src/modules/helpers/index.ts b/src/modules/helpers/index.ts index a4ecdf71..c22a3612 100644 --- a/src/modules/helpers/index.ts +++ b/src/modules/helpers/index.ts @@ -284,7 +284,7 @@ export class HelpersModule { * @since 2.0.1 */ shuffle( - list: readonly T[], + list: ReadonlyArray, options?: { /** * Whether to shuffle the array in place or return a new array. @@ -351,7 +351,7 @@ export class HelpersModule { * * @since 6.0.0 */ - uniqueArray(source: readonly T[] | (() => T), length: number): T[] { + uniqueArray(source: ReadonlyArray | (() => T), length: number): T[] { if (Array.isArray(source)) { const set = new Set(source); const array = Array.from(set); diff --git a/src/modules/internet/index.ts b/src/modules/internet/index.ts index f07ab973..3287e404 100644 --- a/src/modules/internet/index.ts +++ b/src/modules/internet/index.ts @@ -320,7 +320,7 @@ export class InternetModule { const { types = Object.keys( this.faker.definitions.internet.http_status_code - ) as Array, + ) as HTTPStatusCodeType[], } = options; const httpStatusCodeType = this.faker.helpers.arrayElement(types); return this.faker.helpers.arrayElement( @@ -627,9 +627,7 @@ export class InternetModule { } = {} ): string { const { - types = Object.keys( - this.faker.definitions.internet.emoji - ) as Array, + types = Object.keys(this.faker.definitions.internet.emoji) as EmojiType[], } = options; const emojiType = this.faker.helpers.arrayElement(types); return this.faker.helpers.arrayElement( diff --git a/src/modules/random/index.ts b/src/modules/random/index.ts index d558e24b..4936fe80 100644 --- a/src/modules/random/index.ts +++ b/src/modules/random/index.ts @@ -221,7 +221,7 @@ export class RandomModule { * * @default [] */ - bannedChars?: readonly LiteralUnion[] | string; + bannedChars?: ReadonlyArray> | string; } = {} ): string { deprecated({ @@ -274,7 +274,7 @@ export class RandomModule { * * @default [] */ - bannedChars?: readonly LiteralUnion[] | string; + bannedChars?: ReadonlyArray> | string; } = {} ): string { deprecated({ @@ -325,7 +325,7 @@ export class RandomModule { * * @default [] */ - bannedDigits?: readonly LiteralUnion[] | string; + bannedDigits?: ReadonlyArray> | string; } = {} ): string { deprecated({ diff --git a/src/modules/string/index.ts b/src/modules/string/index.ts index 8f62788a..6240184c 100644 --- a/src/modules/string/index.ts +++ b/src/modules/string/index.ts @@ -4,9 +4,13 @@ import type { LiteralUnion } from '../../utils/types'; export type Casing = 'upper' | 'lower' | 'mixed'; -const UPPER_CHARS: readonly string[] = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split(''); -const LOWER_CHARS: readonly string[] = 'abcdefghijklmnopqrstuvwxyz'.split(''); -const DIGIT_CHARS: readonly string[] = '0123456789'.split(''); +const UPPER_CHARS: ReadonlyArray = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split( + '' +); +const LOWER_CHARS: ReadonlyArray = 'abcdefghijklmnopqrstuvwxyz'.split( + '' +); +const DIGIT_CHARS: ReadonlyArray = '0123456789'.split(''); export type LowerAlphaChar = | 'a' @@ -200,7 +204,7 @@ export class StringModule { * * @default [] */ - exclude?: readonly LiteralUnion[] | string; + exclude?: ReadonlyArray> | string; } = {} ): string { if (typeof options === 'number') { @@ -290,7 +294,7 @@ export class StringModule { * * @default [] */ - exclude?: readonly LiteralUnion[] | string; + exclude?: ReadonlyArray> | string; } = {} ): string { if (typeof options === 'number') { @@ -567,7 +571,7 @@ export class StringModule { * * @default [] */ - exclude?: readonly LiteralUnion[] | string; + exclude?: ReadonlyArray> | string; } = {} ): string { if (typeof options === 'number') { -- cgit v1.2.3