Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

1.7 KB
Raw Blame
// Datetime formatting must go through lib/datetime so locale, timezone,
// and hour-cycle preferences are applied consistently (RAL-1244).
// The allowlist below is the escape hatch: lib/datetime itself, zone
// detection (timezone-schema, date-time-utils), zone abbreviations (timezone-utils), tests
// (which format independently of the app to act as an oracle, matching the
// tests exemption in the biome.json overrides), repo scripts (tooling that
// renders no user-facing UI), screenshot capture scripts (which seed
// fixtures in a fixed zone), and files still pending migration. Shrink it
// as RAL-1247 proceeds.
// packages/ui and apps/landing are exempt entirely: lib/datetime is an
// apps/web app-layer concept, and neither a shared UI package nor another
// app can import it (wrong layering direction). Both format dates only via
// a caller-passed `locale`, which is a legitimate, narrower contract.
language js

or {
  `new Intl.DateTimeFormat($_)` as $match,
  `Intl.DateTimeFormat($_)` as $match,
  `$obj.toLocaleString($_)` as $match,
  `$obj.toLocaleDateString($_)` as $match,
  `$obj.toLocaleTimeString($_)` as $match
} where {
  $filename <: not or {
    r".*/src/lib/datetime/.*",
    r".*/src/lib/utils/timezone-schema\.ts",
    r".*/src/lib/utils/date-time-utils\.ts",
    r".*/src/components/time-zone-picker/timezone-utils\.ts",
    r".*/src/features/poll/components/manage-poll/use-csv-exporter\.ts",
    r".*/tests/.*",
    r".*/scripts/.*",
    r".*/packages/screenshots/.*",
    r".*/packages/ui/.*",
    r".*/apps/landing/.*"
  },
  register_diagnostic(span=$match, message="Do not format dates inline. Use the formatters in `@/lib/datetime` so locale, timezone, and hour-cycle preferences are applied consistently.")
}