diff --git a/.eslintrc.js b/.eslintrc.js index bf9afd39afa..5f72451ba2f 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -35,6 +35,7 @@ module.exports = defineConfig({ 'unicorn/no-null': 'off', // incompatible with TypeScript 'unicorn/no-zero-fractions': 'off', // deactivated to raise awareness of floating operations 'unicorn/number-literal-case': 'off', // incompatible with prettier + 'unicorn/prefer-ternary': 'off', // ternaries aren't always better // TODO @Shinigami92 2023-09-23: prefer-at should be turned on when we drop support for Node 14. 'unicorn/prefer-at': 'off', @@ -54,13 +55,11 @@ module.exports = defineConfig({ 'unicorn/no-object-as-default-parameter': 'off', 'unicorn/no-useless-switch-case': 'off', 'unicorn/numeric-separators-style': 'off', - 'unicorn/prefer-array-some': 'off', 'unicorn/prefer-code-point': 'off', 'unicorn/prefer-export-from': 'off', 'unicorn/prefer-module': 'off', 'unicorn/prefer-negative-index': 'off', 'unicorn/prefer-string-slice': 'off', - 'unicorn/prefer-ternary': 'off', 'unicorn/prefer-top-level-await': 'off', 'unicorn/prevent-abbreviations': 'off', 'unicorn/require-array-join-separator': 'off', diff --git a/src/modules/date/index.ts b/src/modules/date/index.ts index e93be54d90f..3ad5f438383 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 d5e2ba51583..2664cdfca11 100644 --- a/src/modules/finance/index.ts +++ b/src/modules/finance/index.ts @@ -593,14 +593,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 70e14ec7155..aecdb302a48 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;