prefer-exponentiation-operator
eslint
Safe autofix
eslint.config.js
export default [
{
rules: {
"prefer-exponentiation-operator": "error",
},
},
];Disallow the use of Math.pow in favor of the ** operator
const foo = Math.pow(2, 8);
const bar = Math.pow(a, b);
let baz = Math.pow(a + b, c + d);
let quux = Math.pow(-1, n);const foo = 2 ** 8;
const bar = a ** b;
let baz = (a + b) ** (c + d);
let quux = (-1) ** n;Examples from the ESLint documentation.
prefer-exponentiation-operator
eslint
export default [
{
rules: {
"prefer-exponentiation-operator": "error",
},
},
];prefer-exponentiation-operator
eslint plugin · style
{
"rules": {
"prefer-exponentiation-operator": "error"
}
}style/useExponentiationOperator
style · since 1.0.0
{
"linter": {
"rules": {
"style": {
"useExponentiationOperator": "error"
}
}
}
}Require template literals instead of string concatenation
Disallow returning value from constructor
Disallow parseInt() and Number.parseInt() in favor of binary, octal, and hexadecimal literals
Disallow variable or function declarations in nested blocks
Disallow unnecessary calls to .call() and .apply()
Enforce the use of the radix argument when using parseInt()