style: apply prettier across the tree

One-shot prettier pass so the new format:check gate starts from a clean
baseline. Formatting only — no behaviour change. Generator-owned and
vendored artifacts stay untouched via .prettierignore.
This commit is contained in:
Marc-André Bombeck committed 2026-06-19 22:20:31 +02:00
1 parent b3fea2ef59
commit 1f4ba5939d
1000 files changed
+12130 -8385

No files matched your search

@@ -17,8 +17,7 @@ function parse(rows: string[]) {
describe("splitCsvRows", () => {
it("handles CRLF, quoted commas, escaped quotes, and a BOM", () => {
const csv =
"a,b,c\r\n1,\"x,y\",\"he said \"\"hi\"\"\"\r\n2,plain,z\r\n";
const csv = 'a,b,c\r\n1,"x,y","he said ""hi"""\r\n2,plain,z\r\n';
const grid = splitCsvRows(csv);
expect(grid).toEqual([
["a", "b", "c"],
@@ -51,9 +50,10 @@ describe("parseCsvMeasurements — header validation", () => {
it("accepts columns in any order", () => {
const out = parseCsvMeasurements(
["unit,measuredAt,type,value", "kg,2026-05-01T08:00:00Z,WEIGHT,80.5"].join(
"\n",
),
[
"unit,measuredAt,type,value",
"kg,2026-05-01T08:00:00Z,WEIGHT,80.5",
].join("\n"),
{ now: NOW },
);
expect(out.fatal).toBeUndefined();
@@ -21,7 +21,7 @@ function buildMinimalZip(filename: string, payload: Buffer): Buffer {
for (let n = 0; n < 256; n++) {
c = n;
for (let k = 0; k < 8; k++) {
c = (c & 1) ? 0xedb88320 ^ (c >>> 1) : c >>> 1;
c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;
}
table[n] = c;
}
@@ -79,14 +79,7 @@ function buildMinimalZip(filename: string, payload: Buffer): Buffer {
eocd.writeUInt32LE(30 + nameBuf.length + compressed.length, 16);
eocd.writeUInt16LE(0, 20); // comment len
return Buffer.concat([
localHeader,
nameBuf,
compressed,
cdh,
nameBuf,
eocd,
]);
return Buffer.concat([localHeader, nameBuf, compressed, cdh, nameBuf, eocd]);
}
describe("readCentralDirectory", () => {
+4 -1
View File
@@ -188,7 +188,10 @@ function convertToCanonicalUnit(
// Weight: lb → kg.
if (
type === "WEIGHT" &&
(lower === "lb" || lower === "lbs" || lower === "pound" || lower === "pounds")
(lower === "lb" ||
lower === "lbs" ||
lower === "pound" ||
lower === "pounds")
) {
return { value: value * LB_TO_KG, unit: canonical };
}
+28 -27
View File
@@ -83,23 +83,22 @@ export function extractExportXml(archivePath: string): UnzipResult {
const entries = readCentralDirectory(buf);
const exportXmlEntry = entries.find(
(e) =>
e.fileName.endsWith("/export.xml") || e.fileName === "export.xml",
(e) => e.fileName.endsWith("/export.xml") || e.fileName === "export.xml",
);
if (!exportXmlEntry) {
throw new Error(
"Archive is missing the `apple_health_export/export.xml` member"
+ " — is this a valid Apple Health export.zip?",
"Archive is missing the `apple_health_export/export.xml` member" +
" — is this a valid Apple Health export.zip?",
);
}
if (
exportXmlEntry.compressionMethod !== 0
&& exportXmlEntry.compressionMethod !== 8
exportXmlEntry.compressionMethod !== 0 &&
exportXmlEntry.compressionMethod !== 8
) {
throw new Error(
`Unsupported ZIP compression method ${exportXmlEntry.compressionMethod}`
+ " for export.xml (expected 0=stored or 8=deflate)",
`Unsupported ZIP compression method ${exportXmlEntry.compressionMethod}` +
" for export.xml (expected 0=stored or 8=deflate)",
);
}
@@ -110,20 +109,20 @@ export function extractExportXml(archivePath: string): UnzipResult {
// `extractEntry()` which trips on the actual inflate output.
if (exportXmlEntry.uncompressedSize > MAX_DECOMPRESSED_BYTES) {
throw new Error(
`export.xml declares an uncompressed size of ${exportXmlEntry.uncompressedSize} bytes`
+ ` — refusing to extract (cap is ${MAX_DECOMPRESSED_BYTES} bytes).`,
`export.xml declares an uncompressed size of ${exportXmlEntry.uncompressedSize} bytes` +
` — refusing to extract (cap is ${MAX_DECOMPRESSED_BYTES} bytes).`,
);
}
if (
exportXmlEntry.compressedSize > 0
&& exportXmlEntry.uncompressedSize / exportXmlEntry.compressedSize
> MAX_COMPRESSION_RATIO
exportXmlEntry.compressedSize > 0 &&
exportXmlEntry.uncompressedSize / exportXmlEntry.compressedSize >
MAX_COMPRESSION_RATIO
) {
throw new Error(
`export.xml advertises a ${(
exportXmlEntry.uncompressedSize / exportXmlEntry.compressedSize
).toFixed(0)}× compression ratio (cap is ${MAX_COMPRESSION_RATIO}×)`
+ " — refusing as a suspected zip bomb.",
).toFixed(0)}× compression ratio (cap is ${MAX_COMPRESSION_RATIO}×)` +
" — refusing as a suspected zip bomb.",
);
}
@@ -151,9 +150,7 @@ export function extractExportXml(archivePath: string): UnzipResult {
* Exported for unit testing the central-directory parser independently
* of the file-extraction path.
*/
export function readCentralDirectory(
buf: Buffer,
): CentralDirectoryEntry[] {
export function readCentralDirectory(buf: Buffer): CentralDirectoryEntry[] {
const eocdOffset = locateEocd(buf);
if (eocdOffset === -1) {
throw new Error("Could not locate ZIP End-Of-Central-Directory record");
@@ -167,13 +164,15 @@ export function readCentralDirectory(
// 0xFFFFFFFF / 0xFFFF sentinel, the real value lives in the Zip64
// EOCD record located by walking back through the locator.
if (
centralDirOffset === 0xffffffff
|| centralDirSize === 0xffffffff
|| entryCount === 0xffff
centralDirOffset === 0xffffffff ||
centralDirSize === 0xffffffff ||
entryCount === 0xffff
) {
const locatorOffset = eocdOffset - 20;
if (locatorOffset < 0
|| buf.readUInt32LE(locatorOffset) !== ZIP64_EOCD_LOCATOR) {
if (
locatorOffset < 0 ||
buf.readUInt32LE(locatorOffset) !== ZIP64_EOCD_LOCATOR
) {
throw new Error("Zip64 sentinels present but Zip64 locator missing");
}
const zip64EocdOffset = Number(buf.readBigUInt64LE(locatorOffset + 8));
@@ -216,9 +215,9 @@ export function readCentralDirectory(
// Zip64 extra-field walk if any of the three values is sentinel.
if (
compressedSize === 0xffffffff
|| uncompressedSize === 0xffffffff
|| localHeaderOffset === 0xffffffff
compressedSize === 0xffffffff ||
uncompressedSize === 0xffffffff ||
localHeaderOffset === 0xffffffff
) {
const extraStart = cursor + 46 + fileNameLen;
let extraCursor = extraStart;
@@ -281,7 +280,9 @@ function extractEntry(buf: Buffer, entry: CentralDirectoryEntry): Buffer {
// refuse expansion past the cap with a thrown error, defeating
// zip-bomb amplification even when the central-directory metadata
// lies about the uncompressed size.
return inflateRawSync(compressed, { maxOutputLength: MAX_DECOMPRESSED_BYTES });
return inflateRawSync(compressed, {
maxOutputLength: MAX_DECOMPRESSED_BYTES,
});
}
/**