@northguild/gmt-eslint
v1.1.2
Published
ESLint config that bans the JavaScript Date object and Date-based libraries, and names the Temporal-based @northguild/gmt function to use instead.
Readme
@northguild/gmt-eslint
Shared ESLint flat configuration for @northguild/gmt projects. Enforces the Temporal-only policy by banning all Date APIs via ESLint rules.
Installation
npm
npm install --save-dev @northguild/gmt-eslint eslint @typescript-eslint/parseryarn
yarn add --dev @northguild/gmt-eslint eslint @typescript-eslint/parserpnpm
pnpm add --save-dev @northguild/gmt-eslint eslint @typescript-eslint/parserbun
bun add --save-dev @northguild/gmt-eslint eslint @typescript-eslint/parserUsage
Modern ESLint (Flat Config)
// eslint.config.mjs
import gmtEslintConfig from "@northguild/gmt-eslint";
export default [...gmtEslintConfig];ESLint RC (.eslintrc.js)
// .eslintrc.js
const gmtEslintConfig = require("@northguild/gmt-eslint");
module.exports = [...gmtEslintConfig];ESLint RC (CommonJS)
// .eslintrc.cjs
const gmtEslintConfig = require("@northguild/gmt-eslint");
module.exports = [...gmtEslintConfig];ESLint RC (JSON)
// .eslintrc.json
{
"extends": ["@northguild/gmt-eslint"]
}Note: JSON format requires the package to export a named configuration. For best compatibility, use the
eslint.config.mjs(flat config) approach or.eslintrc.js/.eslintrc.cjswith CommonJS require.
Banned patterns
| Pattern | Rule | Suggestion |
| --------------------------------------------------------------------------------- | -------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| Date (global reference) | no-restricted-globals | Use getUtcNow(), getNow(), getUnixNow(), or getZonedNow(timezone) |
| new Date(...) | no-restricted-syntax | Use getUtcNow(), getNow(), or getZonedNow(timezone) |
| Date.now() | no-restricted-properties | Use getUnixNow({ epochUnit: 'milliseconds' \| 'seconds' }) or getNow() |
| Date.UTC(...) | no-restricted-properties | Use convertUtcToUnix('YYYY-MM-DDTHH:mm:ssZ', { epochUnit: 'milliseconds' \| 'seconds' }) |
| Date.parse(...) | no-restricted-properties | Use convertZonedToUnix(value) |
| Importing moment, moment-timezone, dayjs, luxon, date-fns, date-fns-tz, @date-fns/tz, spacetime | no-restricted-imports | Use @northguild/gmt |
| $date.getTimezoneOffset() | no-restricted-syntax | 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.
