unicorn/prefer-temporal
eslint-plugin-unicorn
import unicorn from "eslint-plugin-unicorn";
export default [
{
plugins: { unicorn },
rules: {
"unicorn/prefer-temporal": "error",
},
},
];const now = new Date();const date = new Date(1_724_198_400_000);const date = new Date('2024-08-16');const now = Temporal.Now.instant();const date = Temporal.Instant.fromEpochMilliseconds(1_724_198_400_000);const date = Temporal.PlainDate.from('2024-08-16');Examples from the ESLint documentation.
No tracked preset enables this rule, so it has no reach yet.
None of the tracked presets enable this rule. Turn it on with the config below.
unicorn/prefer-temporal
eslint-plugin-unicorn
import unicorn from "eslint-plugin-unicorn";
export default [
{
plugins: { unicorn },
rules: {
"unicorn/prefer-temporal": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
Prefer arrow function properties over methods with a single return.
Prefer Uint8Array#toBase64() and Uint8Array.fromBase64() over legacy base64 conversions and manual postprocessing.
Prefer RegExp.escape() for escaping strings to use in regular expressions.
Prefer Uint8Array#toHex() and Uint8Array.fromHex() over manual and Buffer hex conversions.
Prefer JSON imports over reading and parsing JSON files.