diff options
| author | ST-DDT <[email protected]> | 2023-11-04 10:40:06 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-11-04 09:40:06 +0000 |
| commit | 358572d9e76f4cd22bfcb09c092a1eaf3a31f005 (patch) | |
| tree | 836d9b14d2c7e338610dc36073e799a7723af8c8 | |
| parent | 22003bbac9518befeaacfc75c9360a273f0ea6b4 (diff) | |
| download | faker-358572d9e76f4cd22bfcb09c092a1eaf3a31f005.tar.xz faker-358572d9e76f4cd22bfcb09c092a1eaf3a31f005.zip | |
infra(typescript-eslint): strict-type-checked (#2467)
| -rw-r--r-- | .eslintrc.js | 8 | ||||
| -rw-r--r-- | src/modules/finance/index.ts | 2 | ||||
| -rw-r--r-- | src/modules/image/index.ts | 7 | ||||
| -rw-r--r-- | src/modules/word/filter-word-list-by-length.ts | 4 | ||||
| -rw-r--r-- | test/modules/helpers.spec.ts | 2 | ||||
| -rw-r--r-- | test/scripts/apidoc/module.example.ts | 2 | ||||
| -rw-r--r-- | test/scripts/apidoc/verify-jsdoc-tags.spec.ts | 8 |
7 files changed, 21 insertions, 12 deletions
diff --git a/.eslintrc.js b/.eslintrc.js index 5a69444e..b3d50623 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 2664cdfc..b381e16c 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 a93f181e..b1c9c692 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 106e9858..60c6fae9 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<string>, length: { min: number; max: number } ): string[] => { - const wordsByLength = wordList.reduce( + const wordsByLength = wordList.reduce<Record<number, string[]>>( (data, word) => { (data[word.length] = data[word.length] ?? []).push(word); return data; }, - {} as Record<number, string[]> + {} ); const lengths = Object.keys(wordsByLength).map(Number); diff --git a/test/modules/helpers.spec.ts b/test/modules/helpers.spec.ts index e683d1d8..3f850086 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 b3f43a86..0e5d9d89 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 64cbcdb4..a924c268 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<string[]>((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<string[]>((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 { |
