@northguild/gmt-biome
v1.1.2
Published
Biome GritQL plugins that ban the JavaScript Date object and Date-based libraries, and name the Temporal-based @northguild/gmt function to use instead.
Readme
@northguild/gmt-biome
Shared Biome configuration for @northguild/gmt projects. Enforces the Temporal-only policy by banning all Date APIs via Grit plugins.
Installation
npm
npm install --save-dev @northguild/gmt-biome @biomejs/biomeyarn
yarn add --dev @northguild/gmt-biome @biomejs/biomepnpm
pnpm add --save-dev @northguild/gmt-biome @biomejs/biomebun
bun add --save-dev @northguild/gmt-biome @biomejs/biomeUsage
Add the plugins to the plugins array in your biome.json. Biome resolves plugin paths as filesystem paths, so use the ./node_modules/ path with the .grit extension.
All rules (recommended)
Use the combined all plugin to enable every Date-ban rule in a single entry:
{
"$schema": "https://biomejs.dev/schemas/2.4.11/schema.json",
"plugins": ["./node_modules/@northguild/gmt-biome/plugins/all.grit"]
}Select specific rules
Include only the plugins you need:
{
"$schema": "https://biomejs.dev/schemas/2.4.11/schema.json",
"plugins": [
"./node_modules/@northguild/gmt-biome/plugins/no-new-date.grit",
"./node_modules/@northguild/gmt-biome/plugins/no-date-now.grit",
"./node_modules/@northguild/gmt-biome/plugins/no-date-parse.grit",
"./node_modules/@northguild/gmt-biome/plugins/no-date-utc.grit",
"./node_modules/@northguild/gmt-biome/plugins/no-date-getTimezoneOffset.grit"
]
}Note: The
.gritextension is required. When installed from npm, the typical path uses the./node_modules/prefix (as shown above), but any relative or absolute filesystem path to the.gritfile on disk will work — Biome does not resolve npm package specifiers inplugins.
Why not
extends? Biome'sextendsis for sharingbiome.jsonconfig options (formatter, linter rules, etc.). It cannot be used to distribute GritQL plugins — plugin paths in an extended config file are always resolved relative to the consuming project root, not the npm package directory. Usepluginsinstead.
Banned patterns
| Pattern | Plugin | Suggestion |
| --------------------------------------------------------------------------------- | --------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| new Date(...) | no-new-date | Use getUtcNow(), getNow(), or getZonedNow(timezone) |
| Date.now() | no-date-now | Use getUnixNow({ epochUnit: 'milliseconds' \| 'seconds' }) or getNow() |
| Date.parse(...) | no-date-parse | Use convertZonedToUnix(value) |
| Date.UTC(...) | no-date-utc | Use convertUtcToUnix('YYYY-MM-DDTHH:mm:ssZ', { epochUnit: 'milliseconds' \| 'seconds' }) |
| Importing moment, moment-timezone, dayjs, luxon, date-fns, date-fns-tz, @date-fns/tz, spacetime | no-date-library-imports | Use @northguild/gmt |
| $date.getTimezoneOffset() | no-date-getTimezoneOffset | Use getZonedNow(timezone), other gmt zoned helpers such as convertZonedToUnix(value), or Temporal.ZonedDateTime |
@js-joda/coreis deliberately allowed. It has its own value types and touchesDateonly at the boundary (reading the clock, host zone lookup,toDate()interop), so it does not carry the ambient-timezone and DST problems this ban targets.
Why Temporal?
Temporal solves fundamental issues with JavaScript's Date object:
- Immutability — no accidental mutations
- Timezone awareness — explicit, unambiguous timezone handling
- No DST bugs — proper daylight saving time logic
- Precision — nanosecond precision where needed
All banned Date APIs have Temporal equivalents that are safer, clearer, and more correct.
