Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Git for Windows defaults to core.autocrlf=true, so without this every text
# file lands in the working copy with CRLF. Biome formats with LF
# (biome.json sets no lineEnding override), which fails `biome check` on
# effectively every file, and
# desktop/src/features/messages/ui/virtuaWheelModePatch.test.mjs asserts on
# patches/*.patch with `\n`-joined patterns. Normalize to LF in the working
# copy on every platform; the stored blobs are already LF.
* text=auto eol=lf
2 changes: 1 addition & 1 deletion desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"lint": "biome lint .",
"check": "biome check . && pnpm check:file-sizes && pnpm check:px-text && pnpm check:pubkey-truncation",
"format": "biome format --write .",
"test": "node --import ./test-loader.mjs --experimental-strip-types --test 'src/**/*.test.mjs'",
"test": "node --import ./test-loader.mjs --experimental-strip-types --test \"src/**/*.test.mjs\"",
"preview": "vite preview",
"tauri": "tauri",
"test:e2e": "pnpm build:e2e && playwright test",
Expand Down
21 changes: 15 additions & 6 deletions scripts/check-file-sizes-core.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ import path from "node:path";
* the two apps can never drift.
*/

// `rules[].root` and the `overrides` keys are authored with `/`, but
// path.relative yields `\` on Windows — so every comparison against them has
// to happen in posix form or it silently matches nothing.
function toPosixPath(relativePath) {
return relativePath.split(path.sep).join("/");
}

async function walkFiles(directory) {
const entries = await fs.readdir(directory, { withFileTypes: true });
const files = await Promise.all(
Expand All @@ -27,10 +34,8 @@ async function walkFiles(directory) {
}

function findRule(rules, relativePath) {
return rules.find((rule) => {
const normalizedRoot = `${rule.root}${path.sep}`;
return relativePath.startsWith(normalizedRoot);
});
const posixPath = toPosixPath(relativePath);
return rules.find((rule) => posixPath.startsWith(`${rule.root}/`));
}

function countLines(content) {
Expand Down Expand Up @@ -82,11 +87,15 @@ export async function runFileSizeCheck({
continue;
}

const limit = overrides.get(relativePath) ?? rule.maxLines;
const limit = overrides.get(toPosixPath(relativePath)) ?? rule.maxLines;
const content = await fs.readFile(filePath, "utf8");
const lineCount = countLines(content);
if (lineCount > limit) {
violations.push({ limit, lineCount, relativePath });
violations.push({
limit,
lineCount,
relativePath: toPosixPath(relativePath),
});
}
}

Expand Down
12 changes: 8 additions & 4 deletions scripts/check-px-text-core.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,14 @@ export async function runPxTextCheck({
const violations = [];

for (const filePath of candidateFiles) {
const relativePath = path.relative(projectRoot, filePath);
const rule = rules.find((r) =>
relativePath.startsWith(`${r.root}${path.sep}`),
);
// `rules[].root` and the `overrides` keys are authored with `/`, but
// path.relative yields `\` on Windows — so every comparison against them
// has to happen in posix form or it silently matches nothing.
const relativePath = path
.relative(projectRoot, filePath)
.split(path.sep)
.join("/");
const rule = rules.find((r) => relativePath.startsWith(`${r.root}/`));
if (!rule) {
continue;
}
Expand Down
Loading