fix: more linting

This commit is contained in:
TrèsAbhi committed 2025-09-27 18:01:20 -05:00
1 parent 766801826c
commit 6261dfc9cd
10 files changed
+377 -383

No files matched your search

File diff suppressed because it is too large. Load diff
+12 -15
View File
@@ -1,29 +1,26 @@
import {
DEFAULT_LOCALE,
SUPPORTED_LOCALES,
TranslationTree,
} from '@blitzkit/i18n';
import { writeFile } from 'fs/promises';
import { type TranslationTree } from "@blitzkit/i18n";
import locales from "@blitzkit/i18n/locales.json";
import { writeFile } from "fs/promises";
const ROOT = '@blitzkit/i18n/strings';
const WORKING_ROOT = '../../packages/i18n/strings';
const ROOT = "@blitzkit/i18n/strings";
const WORKING_ROOT = "../../packages/i18n/strings";
const defaultStrings = require(`${ROOT}/${DEFAULT_LOCALE}.json`).default;
const nonDefaultLocales = SUPPORTED_LOCALES.filter(
(locale) => locale !== DEFAULT_LOCALE,
const defaultStrings = require(`${ROOT}/${locales.default}.json`).default;
const nonDefaultLocales = locales.supported.filter(
({ locale }) => locale !== locales.default
);
function prune(defaultStrings: TranslationTree, strings: TranslationTree) {
for (const key in strings) {
if (key in defaultStrings) {
if (typeof defaultStrings[key] === typeof strings[key]) {
if (typeof strings[key] === 'string') {
if (typeof strings[key] === "string") {
if (
// are equivalent regardless of %s flavor
(defaultStrings[key] as string).replaceAll(/%s\d/g, '%s') ===
(strings[key] as string).replaceAll(/%s\d/g, '%s') ||
(defaultStrings[key] as string).replaceAll(/%s\d/g, "%s") ===
(strings[key] as string).replaceAll(/%s\d/g, "%s") ||
// string is empty
strings[key] === '' ||
strings[key] === "" ||
// string has old flavor of %s
strings[key].match(/%s([^\d]|$)/g) !== null
) {