Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/sindresorhus/eslint-plugin-unicorn/llms.txt

Use this file to discover all available pages before exploring further.

Use Date.now() instead of constructing a Date object just to extract a timestamp. Date.now() is shorter, clearer, and avoids an unnecessary object allocation.
Recommendedrecommended · ☑️ unopinionated
Fixable🔧 Auto-fixable

Examples

// Using instance methods to coerce to a timestamp
const foo = new Date().getTime();
const foo = new Date().valueOf();

// Unary coercion
const foo = +new Date;

// Number() wrapper
const foo = Number(new Date());

// In arithmetic expressions
const foo = new Date() * 2;
const elapsed = new Date() - start;
This rule has no configuration options. All reported cases are auto-fixable with --fix.

Build docs developers (and LLMs) love