Prefer Temporal
Date parses date-only strings as UTC, counts months from zero and mixes up moments with calendar dates. Temporal keeps them apart.
12345{ "rules": { "systomic/prefer-temporal": "warn" }}See the difference
new Date("2026-12-02")Temporal.PlainDate.from("2026-12-02")What doesn't work
4 findings1234export const dueDate = new Date(2026, 0, 15);export const birthday = new Date("2026-03-01");export const parsed = Date.parse("2026-03-01T10:00:00Z");export function isDate(value: unknown) { return value instanceof Date; }systomic/prefer-temporal new Date(year, month, …) counts months from 0. Use Temporal.PlainDate.from({ year: 2026, month: 1, day: 15 }) (or PlainDateTime), where months start at 1.
systomic/prefer-temporal new Date("2026-03-01") is parsed as UTC midnight and can show the previous day locally. Use Temporal.PlainDate.from("2026-03-01").
systomic/prefer-temporal Date.parse() depends on the string format. Use Temporal.Instant.from(...).epochMilliseconds.
systomic/prefer-temporal instanceof Date → instanceof Temporal.Instant / Temporal.PlainDate / … for the type you migrated to.
What works
No findings123456export const dueDate = Temporal.PlainDate.from({ year: 2026, month: 1, day: 15 });export const birthday = Temporal.PlainDate.from("2026-03-01");// Plain millisecond timings are allowed by default.export const startedAt = Date.now();// Converting at a boundary to an API that needs a Date.export const legacy = new Date(Temporal.Now.instant().epochMilliseconds);Details
Use Temporal instead of Date. Temporal is immutable, counts months from 1, keeps a moment in time (Instant), a moment in a zone (ZonedDateTime) and a calendar date (PlainDate) apart, and parses strings the same way everywhere.
There is no autofix: which Temporal type replaces a Date depends on what it means. Each message names the replacement for the pattern and the trap it avoids.
| Code | Message points to |
|---|---|
new Date() |
Temporal.Now.instant(), Temporal.Now.zonedDateTimeISO(), Temporal.Now.plainDateISO() |
new Date("2026-12-02") |
Parsed as UTC midnight, can show the previous day locally → Temporal.PlainDate.from(...) |
new Date("2026-12-02T10:00") |
Parsed in the local zone → Temporal.PlainDateTime.from(...) / ZonedDateTime.from(...) |
new Date(2026, 0, 15) |
Months count from 0 → Temporal.PlainDate.from({ year: 2026, month: 1, day: 15 }) (with your literals) |
new Date(ms) |
Temporal.Instant.fromEpochMilliseconds(ms) |
Date(), Date.parse(), Date.UTC() |
Temporal.Now…toString(), Temporal.Instant.from(), ZonedDateTime with timeZone: "UTC" |
: Date (props, interfaces, tuples, …) |
Pick Instant, ZonedDateTime, PlainDate or PlainDateTime |
x instanceof Date |
instanceof Temporal.Instant / … |
Not reported:
Date.now(): just a number, fine for timings and cache keys. Report it withallowDateNow: false.- Converting back at a boundary:
new Date(instant.epochMilliseconds). - A local
Date(imported, class, type alias). - Files in
ignore, e.g. database code where the ORM hands outDates.
Safari and polyfills
Chrome / Edge 144+, Firefox 139+ and Node 26+ ship Temporal. Stable Safari, and with it every browser on iOS, doesn’t yet, so browser code needs a polyfill (temporal-polyfill is small; @js-temporal/polyfill is the reference implementation, about 100KB gzipped).
With source, the global Temporal is reported and the autofix adds the import:
1"systomic/prefer-temporal": ["warn", { "source": "temporal-polyfill" }]Comparing Temporal values
a < b throws a TypeError for Temporal objects (their valueOf throws on purpose), and a === b only compares identity. Use Temporal.PlainDate.compare(a, b) and a.equals(b). This rule doesn’t check comparisons yet.
| Option | Default |
|---|---|
source |
unset: the global Temporal is fine |
allowDateNow |
true |
ignore |
[]: file globs relative to the nearest package.json; see monorepos |
See also prefer-temporal-over-libraries.