Registry / testing / eslint-plugin-date

eslint-plugin-date

JSON →
library0.0.0jsnpmunverified

An ESLint plugin that enforces safe Date usage in JavaScript to prevent timezone-related bugs. It bans direct usage of `new Date()`, `moment`, `dayjs`, and `date-fns` in favor of safer alternatives. The current version is 0.0.0 and has not seen active development. It is forked from Skyscanner's eslint-plugin-skyscanner-dates with business-specific changes. The plugin provides three config presets: recommended, error, and warn.

npm install eslint-plugin-date
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-DATE
E
eslint-plugin-date
testingjavascriptv0.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

plugin
✓ import date from 'eslint-plugin-date'
✗ const date = require('eslint-plugin-date')
ESM-only package. Use import for ES modules.
configs
✓ import { configs } from 'eslint-plugin-date'
✗ const { configs } = require('eslint-plugin-date')
Configs are exported as named exports. CommonJS require is not supported.
rules
✓ import { rules } from 'eslint-plugin-date'
✗ const rules = require('eslint-plugin-date').rules
Rules are also named exports. Direct require of property works but dispreferred.

Configures ESLint to use the date plugin with recommended settings and custom rule overrides.

// .eslintrc.js module.exports = { plugins: ['date'], extends: ['plugin:date/recommended'], rules: { 'date/no-date-fns': 'off', 'date/no-moment-dayjs': 'error', 'date/no-new-date-with-args': 'error', 'date/no-new-date-without-args': 'off' } };
Debug
Known issues
breakingPlugin uses ESM exports only; CommonJS require may fail in older Node versions.
fix
Use import syntax or enable ESM in your project.
affects: >=0.0.0
gotchaRules like 'no-date-fns' and 'no-moment-dayjs' are loosely named; they prevent any usage including safe patterns.
fix
Use the plugin's recommended config or selectively disable rules for allowed libraries.
affects: >=0.0.0
gotchaThe plugin does not provide automatic fixes; it only reports errors.
fix
Manually replace forbidden Date patterns with approved date handling utilities.
affects: >=0.0.0
deprecatedThe plugin is based on an older fork of Skyscanner's dates plugin and may not receive updates.
fix
Consider using a maintained alternative like eslint-plugin-date-rules or a custom rule.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Failed to load plugin 'date' declared in '.eslintrc': Cannot find module 'eslint-plugin-date'
Plugin not installed or missing from package.json.
fix
npm install --save-dev eslint-plugin-date
TypeError: date is not a function
Incorrect import of plugin; using require instead of import.
fix
Use `import date from 'eslint-plugin-date'` or adjust ESLint config to use string 'date'.
ESLint: 'date/no-date-fns' rule has been removed or is not found
Using a rule name that doesn't exist in the plugin.
fix
Check available rules: 'date/no-new-date-with-args', 'date/no-new-date-without-args', 'date/no-date-fns', 'date/no-moment-dayjs'.
Upgrade
Version history
0.0.0latest on npm
Audit
Dependencies
eslintrequiredPeer dependency; ESLint plugin requires ESLint to run.
Agent activity
5 hits · last 30 days
node
5
Resources
homepagehttps:// ↗
eslint-plugin-date — npm install eslint-plugin-date · libregistry