diff --git a/scripts/generateLocales.ts b/scripts/generateLocales.ts index ae898de9db0..0d3d2fd285b 100644 --- a/scripts/generateLocales.ts +++ b/scripts/generateLocales.ts @@ -1,5 +1,6 @@ import { readdirSync, readFileSync, writeFileSync } from 'node:fs'; import { resolve } from 'node:path'; +import type { Options } from 'prettier'; import { format } from 'prettier'; import options from '../.prettierrc.cjs'; import type { LocaleDefinition } from '../src'; @@ -16,6 +17,8 @@ const pathDocsApiLocalization = resolve( ); const scriptCommand = 'pnpm run generate:locales'; +const prettierTsOptions: Options = { ...options, parser: 'typescript' }; +const prettierMdOptions: Options = { ...options, parser: 'markdown' }; const locales = readdirSync(pathLocales); locales.splice(locales.indexOf('index.ts'), 1); @@ -32,6 +35,7 @@ const autoGeneratedCommentHeader = `/* */`; for (const locale of locales) { + // eslint-disable-next-line @typescript-eslint/no-var-requires const localeDef: LocaleDefinition = require('../src/locales/' + locale).default; const localeTitle = localeDef.title; @@ -42,7 +46,7 @@ for (const locale of locales) { localizationLocales += `| ${locale} | ${localeTitle} |\n`; // src/locale/.ts - let content: string = ` + let content = ` ${autoGeneratedCommentHeader} import { Faker } from '..'; @@ -61,7 +65,7 @@ for (const locale of locales) { export = faker; `; - content = format(content, { ...options, parser: 'typescript' }); + content = format(content, prettierTsOptions); writeFileSync(resolve(pathLocale, locale + '.ts'), content); } @@ -81,16 +85,13 @@ let indexContent = ` export default locales; `; -indexContent = format(indexContent, { ...options, parser: 'typescript' }); +indexContent = format(indexContent, prettierTsOptions); writeFileSync(pathLocalesIndex, indexContent); // docs/api/localization.md -localizationLocales = format(localizationLocales, { - ...options, - parser: 'markdown', -}); +localizationLocales = format(localizationLocales, prettierMdOptions); let localizationContent = readFileSync(pathDocsApiLocalization, 'utf-8'); localizationContent = localizationContent.replace(