oxc/approx-constant Suspicious ​
What it does ​
Disallows the use of approximate constants, instead preferring the use of the constants in the Math
object.
Why is this bad? ​
Approximate constants are not as accurate as the constants in the Math
object.
Example ​
Examples of incorrect code for this rule:
javascript
let log10e = 0.434294;
Examples of correct code for this rule:
javascript
let log10e = Math.LOG10E;
How to use ​
To enable this rule in the CLI or using the config file, you can use:
bash
oxlint --deny oxc/approx-constant
json
{
"rules": {
"oxc/approx-constant": "error"
}
}