Skip to content

Latest commit

 

History

History
64 lines (47 loc) · 2.93 KB

prefer-modern-math-apis.md

File metadata and controls

64 lines (47 loc) · 2.93 KB

Prefer modern Math APIs over legacy patterns

💼 This rule is enabled in the ✅ recommended config.

🔧 This rule is automatically fixable by the --fix CLI option.

Math additions in ES2015:

Currently, we only check a few known cases, but we are open to add more patterns.

If you find a suitable case for this rule, please open an issue.

Prefer Math.log10(x) over

Math.log(x) * Math.LOG10E
Math.LOG10E * Math.log(x)
Math.log(x) / Math.LN10

Prefer Math.log2(x) over

Math.log(x) * Math.LOG2E
Math.LOG2E * Math.log(x)
Math.log(x) / Math.LN2

Separate rule for Math.trunc()

See unicorn/prefer-math-trunc rule.