diff --git a/.eslintrc.js b/.eslintrc.js index 5a69444ee80..b3d50623771 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -15,7 +15,7 @@ module.exports = defineConfig({ reportUnusedDisableDirectives: true, extends: [ 'eslint:recommended', - 'plugin:@typescript-eslint/recommended-type-checked', + 'plugin:@typescript-eslint/strict-type-checked', 'plugin:prettier/recommended', 'plugin:deprecation/recommended', 'plugin:jsdoc/recommended-typescript-error', @@ -91,6 +91,7 @@ module.exports = defineConfig({ 'error', { ignoreParameters: true }, ], + '@typescript-eslint/no-unnecessary-condition': 'off', // requires `strictNullChecks` to be enabled '@typescript-eslint/no-unsafe-assignment': 'off', '@typescript-eslint/no-unsafe-call': 'off', '@typescript-eslint/no-unsafe-member-access': 'off', @@ -104,6 +105,11 @@ module.exports = defineConfig({ { allowNumber: true, allowBoolean: true }, ], '@typescript-eslint/unbound-method': 'off', + '@typescript-eslint/unified-signatures': 'off', // incompatible with our api docs generation + + // TODO @ST-DDT 2023-10-10: The following rules currently conflict with our code. + // Each rule should be checked whether it should be enabled/configured and the problems fixed, or stay disabled permanently. + '@typescript-eslint/no-confusing-void-expression': 'off', 'jsdoc/require-jsdoc': 'off', // Enabled only for src/**/*.ts 'jsdoc/require-returns': 'off', diff --git a/src/modules/finance/index.ts b/src/modules/finance/index.ts index 2664cdfca11..b381e16c44f 100644 --- a/src/modules/finance/index.ts +++ b/src/modules/finance/index.ts @@ -815,7 +815,7 @@ export class FinanceModule { const normalizedIssuer = issuer.toLowerCase(); if (normalizedIssuer in localeFormat) { format = this.faker.helpers.arrayElement(localeFormat[normalizedIssuer]); - } else if (/#/.test(issuer)) { + } else if (issuer.includes('#')) { // The user chose an optional scheme format = issuer; } else { diff --git a/src/modules/image/index.ts b/src/modules/image/index.ts index a93f181e131..b1c9c6922e3 100644 --- a/src/modules/image/index.ts +++ b/src/modules/image/index.ts @@ -232,17 +232,16 @@ export class ImageModule { length: { min: 5, max: 10 }, })}/${width}/${height}`; - const hasValidGrayscale = grayscale === true; const hasValidBlur = typeof blur === 'number' && blur >= 1 && blur <= 10; - if (hasValidGrayscale || hasValidBlur) { + if (grayscale || hasValidBlur) { url += '?'; - if (hasValidGrayscale) { + if (grayscale) { url += `grayscale`; } - if (hasValidGrayscale && hasValidBlur) { + if (grayscale && hasValidBlur) { url += '&'; } diff --git a/src/modules/word/filter-word-list-by-length.ts b/src/modules/word/filter-word-list-by-length.ts index 106e98589bc..60c6fae93c9 100644 --- a/src/modules/word/filter-word-list-by-length.ts +++ b/src/modules/word/filter-word-list-by-length.ts @@ -13,12 +13,12 @@ const STRATEGIES = { wordList: ReadonlyArray, length: { min: number; max: number } ): string[] => { - const wordsByLength = wordList.reduce( + const wordsByLength = wordList.reduce>( (data, word) => { (data[word.length] = data[word.length] ?? []).push(word); return data; }, - {} as Record + {} ); const lengths = Object.keys(wordsByLength).map(Number); diff --git a/test/modules/helpers.spec.ts b/test/modules/helpers.spec.ts index e683d1d818c..3f850086770 100644 --- a/test/modules/helpers.spec.ts +++ b/test/modules/helpers.spec.ts @@ -95,6 +95,7 @@ describe('helpers', () => { enum MixedFoo { Foo = 0, Bar = 1, + // eslint-disable-next-line @typescript-eslint/no-mixed-enums FooName = 'Foo', BarName = 'Bar', } @@ -256,6 +257,7 @@ describe('helpers', () => { enum FooMixedEnum { Foo = 0, Bar = 1, + // eslint-disable-next-line @typescript-eslint/no-mixed-enums StrFoo = 'FOO', StrBar = 'BAR', } diff --git a/test/scripts/apidoc/module.example.ts b/test/scripts/apidoc/module.example.ts index b3f43a8602b..0e5d9d89613 100644 --- a/test/scripts/apidoc/module.example.ts +++ b/test/scripts/apidoc/module.example.ts @@ -1,3 +1,5 @@ +/* eslint-disable @typescript-eslint/no-extraneous-class -- required for tests */ + /** * A simple module without anything special. */ diff --git a/test/scripts/apidoc/verify-jsdoc-tags.spec.ts b/test/scripts/apidoc/verify-jsdoc-tags.spec.ts index 64cbcdb4ee5..a924c268213 100644 --- a/test/scripts/apidoc/verify-jsdoc-tags.spec.ts +++ b/test/scripts/apidoc/verify-jsdoc-tags.spec.ts @@ -47,7 +47,7 @@ describe('verify JSDoc tags', () => { } const allowedReferences = new Set( - Object.values(modules).reduce((acc, [module, methods]) => { + Object.values(modules).reduce((acc, [module, methods]) => { const moduleFieldName = extractModuleFieldName(module); return [ ...acc, @@ -55,10 +55,10 @@ describe('verify JSDoc tags', () => { (methodName) => `faker.${moduleFieldName}.${methodName}` ), ]; - }, [] as string[]) + }, []) ); const allowedLinks = new Set( - Object.values(modules).reduce((acc, [module, methods]) => { + Object.values(modules).reduce((acc, [module, methods]) => { const moduleFieldName = extractModuleFieldName(module); return [ ...acc, @@ -68,7 +68,7 @@ describe('verify JSDoc tags', () => { `/api/${moduleFieldName}.html#${methodName.toLowerCase()}` ), ]; - }, [] as string[]) + }, []) ); function assertDescription(description: string, isHtml: boolean): void {