mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-19 13:36:48 +00:00
658807b1ac
rtl-lint compared its own path with argv[1] to decide whether it was
the command being run. Started through a symlink or with a path that
differs in its form, it printed nothing and exited 0. The check now
lives in scripts/lib/rtl.mjs and the command file always runs it.
A broken rtl-baseline.json read as empty, so --update would have
written {} over it. It now stops the run with its reason, like
size-baseline.json.
The rtl-lint-disable marker skipped a line wherever it appeared, inside
a string literal too, and nothing bounded how often it was used. It is
now honoured only inside a comment, and the marked lines are counted
per file against scripts/rtl-disable-baseline.json. Today that is the
four map overlay positions in PlanMapStage.tsx. A side that is geometry
on purpose still gets its marker, but its entry is raised by hand, where
review sees it, instead of the marker quietly replacing the logical
forms.
35 lines
1.8 KiB
JavaScript
35 lines
1.8 KiB
JavaScript
#!/usr/bin/env node
|
|
/*
|
|
* lint:rtl: keeps the layout following the reading direction.
|
|
*
|
|
* Arabic runs the app with dir="rtl". A physical class or style (ml-2,
|
|
* text-left, paddingLeft, left: 0) stays on the same side in either direction,
|
|
* so a gap, an indent or an alignment that follows the text in English lands
|
|
* on the wrong side in Arabic. The logical forms (ms-2, text-start,
|
|
* paddingInlineStart, insetInlineStart) follow the direction, and in a
|
|
* left-to-right language they are exactly the physical ones.
|
|
*
|
|
* Some things are physical on purpose: a map, a chart axis, a drag handle, a
|
|
* popover placed at measured coordinates. Those stay. Every file's physical
|
|
* uses are counted against scripts/rtl-baseline.json, and the check fails when
|
|
* a file holds more than its entry (a file without an entry holds none), so
|
|
* new code reaches for the logical forms. A line that is physical on purpose
|
|
* carries `rtl-lint-disable` in a comment (in a string it is no marker). The
|
|
* marked lines are counted too, against scripts/rtl-disable-baseline.json, so
|
|
* the marker cannot quietly take the place of the logical forms: a new one
|
|
* raises its file's entry by hand, where review sees it.
|
|
*
|
|
* npm run lint:rtl check against the baselines (CI)
|
|
* npm run lint:rtl -- --list print every counted use, file by file
|
|
* npm run lint:rtl -- --update lower both baselines to what the files hold now;
|
|
* it never raises an entry
|
|
*
|
|
* The matching lives in scripts/lib/rtl.mjs.
|
|
*/
|
|
import { fileURLToPath } from 'node:url'
|
|
import { runCli } from './lib/ratchet.mjs'
|
|
import { check } from './lib/rtl.mjs'
|
|
|
|
const root = fileURLToPath(new URL('..', import.meta.url))
|
|
await runCli('lint:rtl', (args) => check({ root, update: args.includes('--update'), list: args.includes('--list') }))
|