diff options
| author | Shinigami <[email protected]> | 2023-02-01 14:04:18 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-02-01 14:04:18 +0100 |
| commit | 5b705d4b047640e91b690566d6e0fdbae17bb842 (patch) | |
| tree | a179a77cca1b72e2c730607def2786a5531b531f /src/modules | |
| parent | be77179faf097383763eaa6414cf7b6a1a8b131a (diff) | |
| download | faker-5b705d4b047640e91b690566d6e0fdbae17bb842.tar.xz faker-5b705d4b047640e91b690566d6e0fdbae17bb842.zip | |
infra: configure lint rule array-type (#1793)
Diffstat (limited to 'src/modules')
| -rw-r--r-- | src/modules/helpers/index.ts | 4 | ||||
| -rw-r--r-- | src/modules/internet/index.ts | 6 | ||||
| -rw-r--r-- | src/modules/random/index.ts | 6 | ||||
| -rw-r--r-- | src/modules/string/index.ts | 16 |
4 files changed, 17 insertions, 15 deletions
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<T>( - list: readonly T[], + list: ReadonlyArray<T>, 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<T>(source: readonly T[] | (() => T), length: number): T[] { + uniqueArray<T>(source: ReadonlyArray<T> | (() => T), length: number): T[] { if (Array.isArray(source)) { const set = new Set<T>(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<HTTPStatusCodeType>, + ) 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<EmojiType>, + 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<AlphaChar>[] | string; + bannedChars?: ReadonlyArray<LiteralUnion<AlphaChar>> | string; } = {} ): string { deprecated({ @@ -274,7 +274,7 @@ export class RandomModule { * * @default [] */ - bannedChars?: readonly LiteralUnion<AlphaNumericChar>[] | string; + bannedChars?: ReadonlyArray<LiteralUnion<AlphaNumericChar>> | string; } = {} ): string { deprecated({ @@ -325,7 +325,7 @@ export class RandomModule { * * @default [] */ - bannedDigits?: readonly LiteralUnion<NumericChar>[] | string; + bannedDigits?: ReadonlyArray<LiteralUnion<NumericChar>> | 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<string> = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split( + '' +); +const LOWER_CHARS: ReadonlyArray<string> = 'abcdefghijklmnopqrstuvwxyz'.split( + '' +); +const DIGIT_CHARS: ReadonlyArray<string> = '0123456789'.split(''); export type LowerAlphaChar = | 'a' @@ -200,7 +204,7 @@ export class StringModule { * * @default [] */ - exclude?: readonly LiteralUnion<AlphaChar>[] | string; + exclude?: ReadonlyArray<LiteralUnion<AlphaChar>> | string; } = {} ): string { if (typeof options === 'number') { @@ -290,7 +294,7 @@ export class StringModule { * * @default [] */ - exclude?: readonly LiteralUnion<AlphaNumericChar>[] | string; + exclude?: ReadonlyArray<LiteralUnion<AlphaNumericChar>> | string; } = {} ): string { if (typeof options === 'number') { @@ -567,7 +571,7 @@ export class StringModule { * * @default [] */ - exclude?: readonly LiteralUnion<NumericChar>[] | string; + exclude?: ReadonlyArray<LiteralUnion<NumericChar>> | string; } = {} ): string { if (typeof options === 'number') { |
