chore: add prettier formatting
All checks were successful
CI / Lint, typecheck and build (push) Successful in 9m56s

This commit is contained in:
zv
2026-06-14 20:26:56 +02:00
parent 8bbd9397a1
commit ee55521803
79 changed files with 2451 additions and 969 deletions

View File

@@ -50,19 +50,21 @@ const mazowieckieCountyTerytByName: Record<string, string> = {
};
function normalizeRegionName(value: string | null | undefined) {
return value
?.replace(/[Łł]/g, "l")
.normalize("NFD")
.replace(/[\u0300-\u036f]/g, "")
.toLocaleLowerCase("pl-PL")
.replace(/^powiat\s+/, "")
.replace(/^m\.\s*/, "")
.replace(/^miasto\s+/, "")
.replace(/\s+powiat$/, "")
.replace(/\s+/g, "_")
.replace(/[^a-z0-9_]/g, "")
.replace(/^warszawa_zachodnia$/, "warszawski_zachodni")
.trim() ?? "";
return (
value
?.replace(/[Łł]/g, "l")
.normalize("NFD")
.replace(/[\u0300-\u036f]/g, "")
.toLocaleLowerCase("pl-PL")
.replace(/^powiat\s+/, "")
.replace(/^m\.\s*/, "")
.replace(/^miasto\s+/, "")
.replace(/\s+powiat$/, "")
.replace(/\s+/g, "_")
.replace(/[^a-z0-9_]/g, "")
.replace(/^warszawa_zachodnia$/, "warszawski_zachodni")
.trim() ?? ""
);
}
function normalizeTerytCountyCode(value: string) {
@@ -70,7 +72,11 @@ function normalizeTerytCountyCode(value: string) {
return /^\d{4}/.test(code) ? code.slice(0, 4) : null;
}
export function getCountyTerytForLocation(province: string | null | undefined, district: string | null | undefined, locationName: string | null | undefined) {
export function getCountyTerytForLocation(
province: string | null | undefined,
district: string | null | undefined,
locationName: string | null | undefined,
) {
const normalizedProvince = getProvinceForSelection(province, null);
if (normalizedProvince !== "mazowieckie") return null;
@@ -79,7 +85,7 @@ export function getCountyTerytForLocation(province: string | null | undefined, d
if (districtMatch) return districtMatch;
const normalizedLocation = normalizeRegionName(locationName);
return normalizedLocation ? mazowieckieCountyTerytByName[normalizedLocation] ?? null : null;
return normalizedLocation ? (mazowieckieCountyTerytByName[normalizedLocation] ?? null) : null;
}
export function warningMatchesCounty(warning: WeatherWarning, countyTeryt: string | null | undefined) {
@@ -87,7 +93,11 @@ export function warningMatchesCounty(warning: WeatherWarning, countyTeryt: strin
return warning.terytCodes.some((code) => normalizeTerytCountyCode(code) === countyTeryt);
}
export function warningMatchesLocalSelection(warning: WeatherWarning, province: Province | null, selectedLocation?: SelectedLocation | null) {
export function warningMatchesLocalSelection(
warning: WeatherWarning,
province: Province | null,
selectedLocation?: SelectedLocation | null,
) {
if (warning.kind === "meteo" && selectedLocation?.countyTeryt) {
return warningMatchesCounty(warning, selectedLocation.countyTeryt);
}