Skip to content

Commit

Permalink
chore: fix lint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ST-DDT committed Jan 29, 2022
1 parent 2e12105 commit e683893
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions scripts/generateLocales.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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);
Expand All @@ -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;
Expand All @@ -42,7 +46,7 @@ for (const locale of locales) {
localizationLocales += `| ${locale} | ${localeTitle} |\n`;

// src/locale/<locale>.ts
let content: string = `
let content = `
${autoGeneratedCommentHeader}
import { Faker } from '..';
Expand All @@ -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);
}

Expand All @@ -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(
Expand Down

0 comments on commit e683893

Please sign in to comment.