style: remove em/en dashes repo-wide, add CLAUDE.md rule against them (#890)
Em dashes (—) and en dashes (–) had spread across comments, docs, tests, and a few UI strings, reading as AI-generated boilerplate rather than house style. Replaced each with punctuation matching its context: colon for explanatory clauses, comma for asides, plain hyphen for numeric/legal ranges (e.g. "21-23§"), "to"/"till" for date ranges, parentheses for paired-dash asides. messages/en.json and messages/sv.json were fixed by hand together to keep sv/en in sync. Left untouched where the dash is the functional subject rather than decorative punctuation: date-range-parser.ts's separator regex, charset-repair.ts's CP1252 byte-mapping table (and its test), the SIE encoding mojibake docs, generic-csv.ts's minus-sign normalizer, the agent system-prompt files that already instruct against em dashes, and a golden iXBRL test fixture compared byte-for-byte. Also fixes two bugs surfaced along the way: an off-by-one in ApiKeysPanel's scope-label split (a leftover from an earlier partial pass), and a charset-repair test that had lost the literal en-dash it exists to verify. Regenerated the agent atom seed migration (skills:generate) since 27 SKILL.md files changed. Added a CLAUDE.md rule against em/en dashes, with an explicit carve-out for the functional-dash cases above. Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
a5154ee884
commit
ec27228a8e
@@ -4,23 +4,23 @@
|
||||
*
|
||||
* The audit found two repository-wide problems that are being remediated in
|
||||
* dedicated campaigns (A1 = route auth/MFA, D1 = money rounding). Those touch
|
||||
* hundreds of sites and won't land in one PR — so this guard makes sure the
|
||||
* hundreds of sites and won't land in one PR: so this guard makes sure the
|
||||
* count can only go DOWN, never up, while the migrations are in flight.
|
||||
*
|
||||
* Checks:
|
||||
* 1. raw-route-auth — an `app/api/**\/route.ts` that calls
|
||||
* 1. raw-route-auth : an `app/api/**\/route.ts` that calls
|
||||
* `supabase.auth.getUser()` directly instead of going through
|
||||
* `requireAuth()` / `withRouteContext()` (the only guards that enforce
|
||||
* MFA AAL2 on hosted). Tracked as a file-set so a NEW offending route
|
||||
* fails CI even if an old one was fixed in the same PR.
|
||||
* 2. naive-ore-round — `Math.round(x * 100) / 100`, which is subtly wrong on
|
||||
* 2. naive-ore-round: `Math.round(x * 100) / 100`, which is subtly wrong on
|
||||
* exact-half values (see lib/money.ts `roundOre`). Tracked as a count.
|
||||
* The canonical rounding modules are excluded.
|
||||
* 3. direct-jel-insert — a file that inserts into `journal_entry_lines`
|
||||
* 3. direct-jel-insert: a file that inserts into `journal_entry_lines`
|
||||
* outside the sanctioned writers. During the dimensions dual-write window
|
||||
* every line writer must derive cost_center/project via
|
||||
* lineDimensionColumns() from the dimensions JSONB map
|
||||
* (lib/bookkeeping/dimension-resolver.ts) — a new direct insert site can
|
||||
* (lib/bookkeeping/dimension-resolver.ts): a new direct insert site can
|
||||
* silently diverge the mirror columns. Tracked as a file-set.
|
||||
*
|
||||
* Usage:
|
||||
@@ -37,7 +37,7 @@ const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '.
|
||||
const BASELINE_PATH = path.join(ROOT, 'scripts', 'checks', 'antipatterns-baseline.json')
|
||||
|
||||
const IGNORE_DIRS = new Set(['node_modules', '.next', '.git', 'dist', 'build', 'coverage'])
|
||||
// The sanctioned home of the öre-round implementation — must not count against itself.
|
||||
// The sanctioned home of the öre-round implementation: must not count against itself.
|
||||
const ROUND_EXEMPT = new Set(['lib/money.ts', 'lib/bokslut/rounding.ts'])
|
||||
|
||||
const RAW_AUTH_RE = /\.auth\.getUser\(/
|
||||
@@ -91,7 +91,7 @@ const JEL_INSERT_SANCTIONED = new Set([
|
||||
'app/api/sandbox/seed/route.ts',
|
||||
])
|
||||
// Matches an insert CHAINED on the lines table (`.from('journal_entry_lines').insert(`,
|
||||
// with optional whitespace/newlines in the chain) — select-only readers don't count.
|
||||
// with optional whitespace/newlines in the chain): select-only readers don't count.
|
||||
const JEL_INSERT_CHAIN_RE = /\.from\(\s*['"]journal_entry_lines['"]\s*\)\s*\.\s*(insert|upsert)\(/
|
||||
|
||||
/** Files that insert into journal_entry_lines outside the sanctioned writers. */
|
||||
@@ -175,7 +175,7 @@ if (newAuthFiles.length) {
|
||||
}
|
||||
|
||||
// 1b. direct-jel-insert: allowlist lives in this file (JEL_INSERT_SANCTIONED),
|
||||
// no baseline — any unsanctioned insert site is a hard failure.
|
||||
// no baseline: any unsanctioned insert site is a hard failure.
|
||||
if (current.directJelInsert.length) {
|
||||
failed = true
|
||||
console.error(
|
||||
@@ -210,7 +210,7 @@ if (fixedAuthFiles.length || current.naiveOreRound < baseline.naiveOreRound.coun
|
||||
}
|
||||
|
||||
if (failed) {
|
||||
console.error('\nAntipattern guard failed — see above.')
|
||||
console.error('\nAntipattern guard failed: see above.')
|
||||
process.exit(1)
|
||||
}
|
||||
console.log(
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
* `npm run lint` was never wired into CI, so ~60 pre-existing errors
|
||||
* accumulated across the repo. Fixing them all in one PR is churn; gating raw
|
||||
* `eslint` would break every PR until then. So: ratchet. Error counts are
|
||||
* tracked per rule in a committed baseline and can only go DOWN, never up —
|
||||
* tracked per rule in a committed baseline and can only go DOWN, never up:
|
||||
* a PR introducing a NEW error of any rule fails CI, while legacy errors are
|
||||
* burned down independently.
|
||||
*
|
||||
* Warnings stay advisory (only `--quiet` errors are counted).
|
||||
*
|
||||
* Known tradeoff: counts are per-rule repo-wide, not per-location — a PR that
|
||||
* Known tradeoff: counts are per-rule repo-wide, not per-location: a PR that
|
||||
* fixes one legacy error of a rule can absorb one NEW error of the same rule
|
||||
* without tripping the gate. Acceptable for a burn-down ratchet; tighten to
|
||||
* per-file fingerprints if that ever bites.
|
||||
@@ -36,7 +36,7 @@ function runEslint() {
|
||||
['eslint', '.', '--quiet', '-f', 'json'],
|
||||
{ cwd: ROOT, encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 },
|
||||
)
|
||||
// ESLint exits 1 when errors exist — that's expected; only treat a missing/
|
||||
// ESLint exits 1 when errors exist: that's expected; only treat a missing/
|
||||
// unparsable report as fatal.
|
||||
if (!result.stdout) {
|
||||
console.error('no-new-lint-errors: eslint produced no JSON output')
|
||||
@@ -77,7 +77,7 @@ if (process.argv.includes('--update')) {
|
||||
BASELINE_PATH,
|
||||
JSON.stringify({ totalErrors: total, perRule: sorted }, null, 2) + '\n',
|
||||
)
|
||||
console.log(`no-new-lint-errors: baseline updated — ${total} error(s) across ${Object.keys(perRule).length} rule(s).`)
|
||||
console.log(`no-new-lint-errors: baseline updated: ${total} error(s) across ${Object.keys(perRule).length} rule(s).`)
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ for (const [rule, count] of Object.entries(perRule)) {
|
||||
}
|
||||
|
||||
if (regressions.length > 0) {
|
||||
console.error('no-new-lint-errors: FAILED — new ESLint errors beyond the baseline:\n')
|
||||
console.error('no-new-lint-errors: FAILED: new ESLint errors beyond the baseline:\n')
|
||||
for (const { rule, count, allowed } of regressions) {
|
||||
console.error(` ${rule}: ${count} (baseline ${allowed})`)
|
||||
for (const loc of (locations[rule] ?? []).slice(0, 10)) {
|
||||
@@ -105,7 +105,7 @@ if (regressions.length > 0) {
|
||||
}
|
||||
}
|
||||
console.error(`
|
||||
Fix the new error(s) — run \`npx eslint . --quiet\` locally to see them.
|
||||
Fix the new error(s): run \`npx eslint . --quiet\` locally to see them.
|
||||
(If you fixed MORE legacy errors than you added and the rule still trips,
|
||||
re-baseline with: node scripts/checks/no-new-lint-errors.mjs --update)
|
||||
`)
|
||||
@@ -114,8 +114,8 @@ re-baseline with: node scripts/checks/no-new-lint-errors.mjs --update)
|
||||
|
||||
const improved = total < (baseline.totalErrors ?? 0)
|
||||
console.log(
|
||||
`no-new-lint-errors: OK — ${total} error(s), baseline ${baseline.totalErrors}.` +
|
||||
`no-new-lint-errors: OK: ${total} error(s), baseline ${baseline.totalErrors}.` +
|
||||
(improved
|
||||
? ' Count went DOWN — ratchet it: node scripts/checks/no-new-lint-errors.mjs --update'
|
||||
? ' Count went DOWN: ratchet it: node scripts/checks/no-new-lint-errors.mjs --update'
|
||||
: ''),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user