aboutsummaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorST-DDT <[email protected]>2023-10-27 00:12:41 +0200
committerGitHub <[email protected]>2023-10-26 22:12:41 +0000
commit9297e5b654d3aa44ec5d8601c8947ee707687e17 (patch)
tree4721b8559a7fd0bc10619c8f383fad9966cf6ecf /src/modules
parent8a405fadcd3c4c5fb97e2069df9fc800703b9a98 (diff)
downloadfaker-9297e5b654d3aa44ec5d8601c8947ee707687e17.tar.xz
faker-9297e5b654d3aa44ec5d8601c8947ee707687e17.zip
infra(unicorn): prefer-ternary (#2464)
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/date/index.ts24
-rw-r--r--src/modules/finance/index.ts11
-rw-r--r--src/modules/internet/index.ts6
3 files changed, 12 insertions, 29 deletions
diff --git a/src/modules/date/index.ts b/src/modules/date/index.ts
index e93be54d..3ad5f438 100644
--- a/src/modules/date/index.ts
+++ b/src/modules/date/index.ts
@@ -1097,15 +1097,11 @@ export class DateModule extends SimpleDateModule {
const source = this.faker.definitions.date.month;
let type: keyof DateEntryDefinition;
if (abbreviated) {
- if (context && source['abbr_context'] != null) {
- type = 'abbr_context';
- } else {
- type = 'abbr';
- }
- } else if (context && source['wide_context'] != null) {
- type = 'wide_context';
+ const useContext = context && source['abbr_context'] != null;
+ type = useContext ? 'abbr_context' : 'abbr';
} else {
- type = 'wide';
+ const useContext = context && source['wide_context'] != null;
+ type = useContext ? 'wide_context' : 'wide';
}
return this.faker.helpers.arrayElement(source[type]);
@@ -1287,15 +1283,11 @@ export class DateModule extends SimpleDateModule {
const source = this.faker.definitions.date.weekday;
let type: keyof DateEntryDefinition;
if (abbreviated) {
- if (context && source['abbr_context'] != null) {
- type = 'abbr_context';
- } else {
- type = 'abbr';
- }
- } else if (context && source['wide_context'] != null) {
- type = 'wide_context';
+ const useContext = context && source['abbr_context'] != null;
+ type = useContext ? 'abbr_context' : 'abbr';
} else {
- type = 'wide';
+ const useContext = context && source['wide_context'] != null;
+ type = useContext ? 'wide_context' : 'wide';
}
return this.faker.helpers.arrayElement(source[type]);
diff --git a/src/modules/finance/index.ts b/src/modules/finance/index.ts
index b932ab20..99d84da3 100644
--- a/src/modules/finance/index.ts
+++ b/src/modules/finance/index.ts
@@ -599,14 +599,9 @@ export class FinanceModule {
precision: 10 ** -dec,
});
- let formattedString: string;
- if (autoFormat) {
- formattedString = randValue.toLocaleString(undefined, {
- minimumFractionDigits: dec,
- });
- } else {
- formattedString = randValue.toFixed(dec);
- }
+ const formattedString = autoFormat
+ ? randValue.toLocaleString(undefined, { minimumFractionDigits: dec })
+ : randValue.toFixed(dec);
return symbol + formattedString;
}
diff --git a/src/modules/internet/index.ts b/src/modules/internet/index.ts
index 70e14ec7..aecdb302 100644
--- a/src/modules/internet/index.ts
+++ b/src/modules/internet/index.ts
@@ -1475,11 +1475,7 @@ export class InternetModule {
}
if (memorable) {
- if (consonant.test(prefix)) {
- pattern = vowel;
- } else {
- pattern = consonant;
- }
+ pattern = consonant.test(prefix) ? vowel : consonant;
}
const n = this.faker.number.int(94) + 33;