chore: sweep em dashes from our own source and README (#13)

This commit was merged in pull request #13.
This commit is contained in:
2026-10-03 22:03:00 +00:00
parent 95edbcd20b
commit f5d1ced4d6
7 changed files with 70 additions and 32 deletions
+38
View File
@@ -0,0 +1,38 @@
import { readFileSync, readdirSync } from "node:fs";
import path from "node:path";
import { describe, expect, it } from "vitest";
const EM_DASH = "\u2014";
const SRC = path.resolve(__dirname, "..");
const README = path.resolve(__dirname, "../../README.md");
function sourceFiles(directory: string): string[] {
return readdirSync(directory, { withFileTypes: true }).flatMap((entry) => {
if (entry.isDirectory()) {
// Tests are skipped: unicode test data legitimately contains an em dash,
// and the rule is about what we ship rather than about our fixtures.
return entry.name === "__tests__" ? [] : sourceFiles(path.join(directory, entry.name));
}
return /\.tsx?$/.test(entry.name) ? [path.join(directory, entry.name)] : [];
});
}
describe("voice", () => {
it("ships no em dashes in the source", () => {
// The default prompt tells the model never to write one, so the extension
// should not ship one either. Guarding the whole tree rather than picking
// out UI strings by hand keeps the rule simple enough to actually hold, and
// comment rewrites are cheap next to a documented standard that quietly
// drifts.
const offenders = sourceFiles(SRC)
.filter((file) => readFileSync(file, "utf8").includes(EM_DASH))
.map((file) => path.relative(SRC, file));
expect(offenders).toEqual([]);
});
it("ships no em dashes in the README", () => {
expect(readFileSync(README, "utf8")).not.toContain(EM_DASH);
});
});