consistent-date-clone
March 27, 2026 Β· View on GitHub
π Prefer passing Date directly to the constructor when cloning.
πΌ This rule is enabled in the following configs: β
recommended, βοΈ unopinionated.
π§ This rule is automatically fixable by the --fix CLI option.
The Date constructor can clone a β Date object directly when passed as an argument, making timestamp conversion unnecessary.
Note: Before ES2015,
new Date(date)converteddateto a string first, so it's not safe to clone.
Examples
// β
new Date(date.getTime());
// β
new Date(date);