Skip to content

Latest commit

 

History

History
64 lines (48 loc) · 2.91 KB

prefer-modern-math-apis.md

File metadata and controls

64 lines (48 loc) · 2.91 KB

Prefer modern Math APIs over legacy patterns

This rule is part of the recommended config.

🔧 This rule is auto-fixable.

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.