Upgrade Biome to 2.4.7 and enable 54 additional lint rules
Add rules covering bug prevention (noLeakedRender, noFloatingPromises, noImportCycles, noReactForwardRef), security (noScriptUrl, noAlert), performance (noAwaitInLoops, useTopLevelRegex), and code style (noNestedTernary, useGlobalThis, useNullishCoalescing, useSortedClasses, plus ~40 more). Fix all violations: extract top-level regex constants, guard React && renders with boolean coercion, refactor nested ternaries, replace window with globalThis, sort Tailwind classes, and introduce expectDomainError test helper to eliminate conditional expects. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@ import { createPlayerCharacter } from "../create-player-character.js";
|
||||
import type { PlayerCharacter } from "../player-character-types.js";
|
||||
import { playerCharacterId } from "../player-character-types.js";
|
||||
import { isDomainError } from "../types.js";
|
||||
import { expectDomainError } from "./test-helpers.js";
|
||||
|
||||
const id = playerCharacterId("pc-1");
|
||||
|
||||
@@ -80,10 +81,7 @@ describe("createPlayerCharacter", () => {
|
||||
|
||||
it("rejects empty name", () => {
|
||||
const result = createPlayerCharacter([], id, "", 10, 50, "blue", "sword");
|
||||
expect(isDomainError(result)).toBe(true);
|
||||
if (isDomainError(result)) {
|
||||
expect(result.code).toBe("invalid-name");
|
||||
}
|
||||
expectDomainError(result, "invalid-name");
|
||||
});
|
||||
|
||||
it("rejects whitespace-only name", () => {
|
||||
@@ -96,10 +94,7 @@ describe("createPlayerCharacter", () => {
|
||||
"blue",
|
||||
"sword",
|
||||
);
|
||||
expect(isDomainError(result)).toBe(true);
|
||||
if (isDomainError(result)) {
|
||||
expect(result.code).toBe("invalid-name");
|
||||
}
|
||||
expectDomainError(result, "invalid-name");
|
||||
});
|
||||
|
||||
it("rejects negative AC", () => {
|
||||
@@ -112,10 +107,7 @@ describe("createPlayerCharacter", () => {
|
||||
"blue",
|
||||
"sword",
|
||||
);
|
||||
expect(isDomainError(result)).toBe(true);
|
||||
if (isDomainError(result)) {
|
||||
expect(result.code).toBe("invalid-ac");
|
||||
}
|
||||
expectDomainError(result, "invalid-ac");
|
||||
});
|
||||
|
||||
it("rejects non-integer AC", () => {
|
||||
@@ -128,10 +120,7 @@ describe("createPlayerCharacter", () => {
|
||||
"blue",
|
||||
"sword",
|
||||
);
|
||||
expect(isDomainError(result)).toBe(true);
|
||||
if (isDomainError(result)) {
|
||||
expect(result.code).toBe("invalid-ac");
|
||||
}
|
||||
expectDomainError(result, "invalid-ac");
|
||||
});
|
||||
|
||||
it("allows AC of 0", () => {
|
||||
@@ -149,10 +138,7 @@ describe("createPlayerCharacter", () => {
|
||||
"blue",
|
||||
"sword",
|
||||
);
|
||||
expect(isDomainError(result)).toBe(true);
|
||||
if (isDomainError(result)) {
|
||||
expect(result.code).toBe("invalid-max-hp");
|
||||
}
|
||||
expectDomainError(result, "invalid-max-hp");
|
||||
});
|
||||
|
||||
it("rejects negative maxHp", () => {
|
||||
@@ -165,10 +151,7 @@ describe("createPlayerCharacter", () => {
|
||||
"blue",
|
||||
"sword",
|
||||
);
|
||||
expect(isDomainError(result)).toBe(true);
|
||||
if (isDomainError(result)) {
|
||||
expect(result.code).toBe("invalid-max-hp");
|
||||
}
|
||||
expectDomainError(result, "invalid-max-hp");
|
||||
});
|
||||
|
||||
it("rejects non-integer maxHp", () => {
|
||||
@@ -181,10 +164,7 @@ describe("createPlayerCharacter", () => {
|
||||
"blue",
|
||||
"sword",
|
||||
);
|
||||
expect(isDomainError(result)).toBe(true);
|
||||
if (isDomainError(result)) {
|
||||
expect(result.code).toBe("invalid-max-hp");
|
||||
}
|
||||
expectDomainError(result, "invalid-max-hp");
|
||||
});
|
||||
|
||||
it("rejects invalid color", () => {
|
||||
@@ -197,10 +177,7 @@ describe("createPlayerCharacter", () => {
|
||||
"neon",
|
||||
"sword",
|
||||
);
|
||||
expect(isDomainError(result)).toBe(true);
|
||||
if (isDomainError(result)) {
|
||||
expect(result.code).toBe("invalid-color");
|
||||
}
|
||||
expectDomainError(result, "invalid-color");
|
||||
});
|
||||
|
||||
it("rejects invalid icon", () => {
|
||||
@@ -213,10 +190,7 @@ describe("createPlayerCharacter", () => {
|
||||
"blue",
|
||||
"banana",
|
||||
);
|
||||
expect(isDomainError(result)).toBe(true);
|
||||
if (isDomainError(result)) {
|
||||
expect(result.code).toBe("invalid-icon");
|
||||
}
|
||||
expectDomainError(result, "invalid-icon");
|
||||
});
|
||||
|
||||
it("allows undefined color", () => {
|
||||
|
||||
Reference in New Issue
Block a user