diff --git a/src/modules/emblem/generator.ts b/src/modules/emblem/generator.ts index 80317ec3..35f8fe89 100644 --- a/src/modules/emblem/generator.ts +++ b/src/modules/emblem/generator.ts @@ -453,7 +453,7 @@ class EmblemGeneratorModule { // Size selection - must use sequential P() calls to match original behavior if (P(0.1)) size = "-small"; - // biome-ignore lint/suspicious/noDuplicateElseIf: + // biome-ignore lint/suspicious/noDuplicateElseIf: sequential probability selection requires repeated else-if with same condition else if (P(0.1)) size = "-smaller"; else if (P(0.01)) size = "-big"; else if (P(0.005)) size = "-smallest"; @@ -469,11 +469,11 @@ class EmblemGeneratorModule { if (P(0.2)) { t1 = "gules"; t2 = "or"; - // biome-ignore lint/suspicious/noDuplicateElseIf: + // biome-ignore lint/suspicious/noDuplicateElseIf: sequential probability selection requires repeated else-if with same condition } else if (P(0.2)) { t1 = "argent"; t2 = "sable"; - // biome-ignore lint/suspicious/noDuplicateElseIf: + // biome-ignore lint/suspicious/noDuplicateElseIf: sequential probability selection requires repeated else-if with same condition } else if (P(0.2)) { t1 = "azure"; t2 = "argent"; @@ -482,7 +482,7 @@ class EmblemGeneratorModule { if (P(0.3)) { t1 = "gules"; t2 = "argent"; - // biome-ignore lint/suspicious/noDuplicateElseIf: + // biome-ignore lint/suspicious/noDuplicateElseIf: sequential probability selection requires repeated else-if with same condition } else if (P(0.3)) { t1 = "argent"; t2 = "sable"; diff --git a/src/modules/military-generator.ts b/src/modules/military-generator.ts index daec9332..398c7d2c 100644 --- a/src/modules/military-generator.ts +++ b/src/modules/military-generator.ts @@ -430,7 +430,7 @@ class MilitaryModule { nodes.forEach((node) => { tree.remove(node); const overlap = tree.find(node.x, node.y, 20); - if (overlap && overlap.t && mergeable(node, overlap)) { + if (overlap?.t && mergeable(node, overlap)) { merge(node, overlap); return; } diff --git a/src/modules/provinces-generator.ts b/src/modules/provinces-generator.ts index 6ad3404d..76ad80a6 100644 --- a/src/modules/provinces-generator.ts +++ b/src/modules/provinces-generator.ts @@ -318,7 +318,7 @@ class ProvinceModule { if (singleIsle) return "Island"; if (isleGroup) return "Islands"; if (colony) return "Colony"; - return rw(this.forms["Wild"]); + return rw(this.forms.Wild); })(); const fullName = `${name} ${formName}`; diff --git a/src/renderers/draw-heightmap.ts b/src/renderers/draw-heightmap.ts index 7ccabd47..3d181a6c 100644 --- a/src/renderers/draw-heightmap.ts +++ b/src/renderers/draw-heightmap.ts @@ -1,6 +1,12 @@ import type { CurveFactory } from "d3"; -import * as d3 from "d3"; -import { color, line, range } from "d3"; +import { + color, + curveBasisClosed, + curveLinear, + curveStep, + line, + range, +} from "d3"; import { round } from "../utils"; declare global { @@ -28,10 +34,13 @@ const heightmapRenderer = (): void => { if (renderOceanCells) { const skip = +ocean.attr("skip") + 1 || 1; const relax = +ocean.attr("relax") || 0; - // TODO: Improve for treeshaking - const curveType: keyof typeof d3 = (ocean.attr("curve") || - "curveBasisClosed") as keyof typeof d3; - const lineGen = line().curve(d3[curveType] as CurveFactory); + const curveFactories: Record = { + curveBasisClosed, + curveLinear, + curveStep, + }; + const curveType = ocean.attr("curve") || "curveBasisClosed"; + const lineGen = line().curve(curveFactories[curveType] ?? curveBasisClosed); let currentLayer = 0; for (const i of heights) { @@ -59,9 +68,13 @@ const heightmapRenderer = (): void => { { const skip = +land.attr("skip") + 1 || 1; const relax = +land.attr("relax") || 0; - const curveType: keyof typeof d3 = (land.attr("curve") || - "curveBasisClosed") as keyof typeof d3; - const lineGen = line().curve(d3[curveType] as CurveFactory); + const curveFactories: Record = { + curveBasisClosed, + curveLinear, + curveStep, + }; + const curveType = land.attr("curve") || "curveBasisClosed"; + const lineGen = line().curve(curveFactories[curveType] ?? curveBasisClosed); let currentLayer = 20; for (const i of heights) { diff --git a/src/renderers/draw-markers.ts b/src/renderers/draw-markers.ts index edc5befd..55d827db 100644 --- a/src/renderers/draw-markers.ts +++ b/src/renderers/draw-markers.ts @@ -53,6 +53,7 @@ const pinShapes: PinShapes = { no: () => "", }; +// biome-ignore lint/suspicious/noRedeclare: const implementation satisfies the global var declaration above const getPin = (shape = "bubble", fill = "#fff", stroke = "#000"): string => { const shapeFunction = pinShapes[shape] || pinShapes.bubble; return shapeFunction(fill, stroke); diff --git a/src/types/global.ts b/src/types/global.ts index 9bfd1b58..d3fb3f0a 100644 --- a/src/types/global.ts +++ b/src/types/global.ts @@ -1,6 +1,6 @@ -import type {Selection} from "d3"; -import type {NameBase} from "../modules/names-generator"; -import type {PackedGraph} from "./PackedGraph"; +import type { Selection } from "d3"; +import type { NameBase } from "../modules/names-generator"; +import type { PackedGraph } from "./PackedGraph"; declare global { var seed: string; @@ -11,7 +11,7 @@ declare global { var TIME: boolean; var WARN: boolean; var ERROR: boolean; - var DEBUG: {stateLabels?: boolean; [key: string]: boolean | undefined}; + var DEBUG: { stateLabels?: boolean; [key: string]: boolean | undefined }; var options: any; var heightmapTemplates: any; @@ -66,9 +66,9 @@ declare global { }; var notes: any[]; var style: { - burgLabels: {[key: string]: {[key: string]: string}}; - burgIcons: {[key: string]: {[key: string]: string}}; - anchors: {[key: string]: {[key: string]: string}}; + burgLabels: { [key: string]: { [key: string]: string } }; + burgIcons: { [key: string]: { [key: string]: string } }; + anchors: { [key: string]: { [key: string]: string } }; [key: string]: any; }; @@ -81,7 +81,7 @@ declare global { message: string, autoHide?: boolean, type?: "info" | "warn" | "error" | "success", - timeout?: number + timeout?: number, ) => void; var locked: (settingId: string) => boolean; var unlock: (settingId: string) => void;