Update lint rules
This commit is contained in:
@@ -20,7 +20,7 @@ const dayjsLocales = dayjsLocaleFileNames
|
||||
|
||||
const outputFileContent = fs.readFileSync(outputFilePath, 'utf-8');
|
||||
|
||||
const updatedFileContent = outputFileContent.replace(
|
||||
const updatedFileContent = outputFileContent.replaceAll(
|
||||
/(export const DAYJS_LOCALES = \[)[\s\S]*?(])/g,
|
||||
`$1'${dayjsLocales.join("', '")}'$2`,
|
||||
);
|
||||
|
||||
@@ -23,7 +23,7 @@ const dayjsLocaleToFileName = dayjsLocaleFileNames
|
||||
|
||||
const outputFileContent = fs.readFileSync(outputFilePath, 'utf-8');
|
||||
|
||||
const updatedFileContent = outputFileContent.replace(
|
||||
const updatedFileContent = outputFileContent.replaceAll(
|
||||
/(const localesToImport: Record<\(typeof DAYJS_LOCALES\)\[number], \(\) => Promise<unknown>> = \{)[\s\S]*?(})/g,
|
||||
`$1${dayjsLocaleToFileName.map(([locale, fileName]) => `'${locale}': () => import('dayjs/locale/${fileName}')`).join(',')}$2`,
|
||||
);
|
||||
|
||||
@@ -72,7 +72,7 @@ const outputContent = readFileSync(outputFilePath, 'utf-8');
|
||||
|
||||
const mangaTypes = Object.keys(MANGA_TYPE_TO_MSG_IDS);
|
||||
const entries = mangaTypes.map((type) => {
|
||||
const tagList = translationsByMangaType[type].map((tag) => `'${tag.replace(/'/g, "\\'")}'`).join(',');
|
||||
const tagList = translationsByMangaType[type].map((tag) => `'${tag.replaceAll("'", "\\'")}'`).join(',');
|
||||
return ` [MangaType.${type}]: [\n${tagList},\n ]`;
|
||||
});
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ const createChangelogCommitLine = (commit: Commit): string => {
|
||||
return `${revision} ${commit.title} (${authorCredit})`;
|
||||
}
|
||||
|
||||
const title = commit.title.replace(/(.*) \(#[0-9]+\)$/g, '$1'); // remove the possible pr number from the title (e.g. "my commit title (#420)" => "my commit title")
|
||||
const title = commit.title.replaceAll(/(.*) \(#[0-9]+\)$/g, '$1'); // remove the possible pr number from the title (e.g. "my commit title (#420)" => "my commit title")
|
||||
const prId = commit.pullRequest.number;
|
||||
const prUrl = commit.pullRequest.url;
|
||||
const prLink = `[#${prId}](${prUrl})`;
|
||||
@@ -179,11 +179,9 @@ const createChangelogCommitLine = (commit: Commit): string => {
|
||||
|
||||
const getContributors = (commits: Commit[]): string[] => [
|
||||
...new Set(
|
||||
commits
|
||||
.map((commit) =>
|
||||
commit.authors.map((author) => author.user?.login).filter((author): author is string => !!author),
|
||||
)
|
||||
.flat(),
|
||||
commits.flatMap((commit) =>
|
||||
commit.authors.map((author) => author.user?.login).filter((author): author is string => !!author),
|
||||
),
|
||||
),
|
||||
];
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import path from 'path';
|
||||
import fs from 'fs';
|
||||
import readline from 'readline';
|
||||
import { ControlledPromise } from '@/lib/ControlledPromise.ts';
|
||||
import {
|
||||
import type {
|
||||
ActionByTranslationUrlByUserUrl,
|
||||
ContributionsByLanguage,
|
||||
LanguageNameByTranslationUrl,
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
import { ExecSyncOptions, execSync } from 'node:child_process';
|
||||
import type { ExecSyncOptions } from 'node:child_process';
|
||||
import { execSync } from 'node:child_process';
|
||||
import { writeFileSync } from 'node:fs';
|
||||
import packageJson from '../../package.json';
|
||||
|
||||
@@ -94,9 +95,9 @@ const getOutdatedDependencies = (): OutdatedDependency[] => {
|
||||
.toSorted((a, b) => a.packageType.localeCompare(b.packageType));
|
||||
};
|
||||
|
||||
const updateDependencies = () => {
|
||||
const log = (...args: Parameters<typeof console.log>) => console.log('updateDependencies:', ...args);
|
||||
const log = (...args: Parameters<typeof console.log>) => console.log('updateDependencies:', ...args);
|
||||
|
||||
const updateDependencies = () => {
|
||||
log('checking for outdated dependencies...');
|
||||
|
||||
const outdatedDependencies = getOutdatedDependencies();
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
import {
|
||||
import type {
|
||||
WeblateChangePayload,
|
||||
WeblateChangeResult,
|
||||
WeblateLanguagePayload,
|
||||
@@ -52,7 +52,7 @@ export const getUsername = async (url: string): Promise<string> => {
|
||||
|
||||
export const getLanguageName = async (url: string): Promise<string> => {
|
||||
const languagePayload = await fetchData<WeblateLanguagePayload>(url);
|
||||
return languagePayload.language.name.replace(/\(([a-zA-Z]+) Han script\)/g, '($1)');
|
||||
return languagePayload.language.name.replaceAll(/\(([a-zA-Z]+) Han script\)/g, '($1)');
|
||||
};
|
||||
|
||||
export const fetchWeblateLanguageStats = async () =>
|
||||
@@ -68,7 +68,7 @@ export const validateWeblateDates = (afterDate: string, beforeDate: string) => {
|
||||
}
|
||||
};
|
||||
|
||||
export const normalizeCode = (code: string): string => code.replace(/[-_]/g, '');
|
||||
export const normalizeCode = (code: string): string => code.replaceAll(/[-_]/g, '');
|
||||
|
||||
export const getWeblateLanguageStatsFor = (
|
||||
code: string,
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
getWeblateLanguageStatsFor,
|
||||
meetsTranslatedPercentThreshold as meetsTranslatedPercentThresholdBase,
|
||||
} from './Weblate.utils.ts';
|
||||
import { WeblateLanguageStatistic } from './Weblate.types.ts';
|
||||
import type { WeblateLanguageStatistic } from './Weblate.types.ts';
|
||||
import { TRANSLATED_PERCENT_THRESHOLD } from './Weblate.constants.ts';
|
||||
|
||||
const I18N_INDEX_PATH = 'src/i18n/index.ts';
|
||||
@@ -50,7 +50,7 @@ const formatLocalesArray = (locales: string[]): string => locales.map((locale) =
|
||||
const updateI18nIndex = (locales: string[]): void => {
|
||||
const content = fs.readFileSync(i18nIndexFilePath, 'utf-8');
|
||||
const localesArrayStr = formatLocalesArray(locales);
|
||||
const updatedContent = content.replace(
|
||||
const updatedContent = content.replaceAll(
|
||||
/(export const i18nResources = \[)[\s\S]*?(] as const)/g,
|
||||
`$1${localesArrayStr}$2`,
|
||||
);
|
||||
@@ -60,7 +60,7 @@ const updateI18nIndex = (locales: string[]): void => {
|
||||
const updateLinguiConfig = (locales: string[]): void => {
|
||||
const content = fs.readFileSync(linguiConfigFilePath, 'utf-8');
|
||||
const localesArrayStr = formatLocalesArray(locales);
|
||||
const updatedContent = content.replace(/(locales: \[)[\s\S]*?(],)/g, `$1${localesArrayStr}$2`);
|
||||
const updatedContent = content.replaceAll(/(locales: \[)[\s\S]*?(],)/g, `$1${localesArrayStr}$2`);
|
||||
fs.writeFileSync(linguiConfigFilePath, updatedContent);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user