sonarjs/operation-returning-nan
eslint-plugin-sonarjs
No autofix
eslint.config.js
export default [
{
rules: {
"sonarjs/operation-returning-nan": "error",
},
},
];Arithmetic operations should not result in "NaN"
x = [1, 2];
var y = x / 4; //NoncompliantThe documentation shows no correct example for this rule.
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.
sonarjs/operation-returning-nan
eslint-plugin-sonarjs
export default [
{
rules: {
"sonarjs/operation-returning-nan": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
Arithmetic operators should only have numbers as operands
Local variables should not be declared and then immediately returned or thrown
Variables declared with "var" should be declared before they are used
Unused function parameters should be removed