sonarjs/inconsistent-function-call
eslint-plugin-sonarjs
No autofixRecommended
eslint.config.js
export default [
{
rules: {
"sonarjs/inconsistent-function-call": "error",
},
},
];Functions should be called consistently with or without "new"
function getNum() {
return 5;
}
function Num(numeric, alphabetic) {
this.numeric = numeric;
this.alphabetic = alphabetic;
}
var myFirstNum = getNum();
var my2ndNum = new getNum(); // Noncompliant. An empty object is returned, NOT 5
var myNumObj1 = new Num();
var myNumObj2 = Num(); // Noncompliant. undefined is returned, NOT an objectThe documentation shows no correct example for this rule.
Examples from the ESLint documentation.
sonarjs/inconsistent-function-call
eslint-plugin-sonarjs
export default [
{
rules: {
"sonarjs/inconsistent-function-call": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
"in" should not be used with primitive types
"indexOf" checks should not be for positive numbers
Lifecycle hooks should not be interleaved with test cases or nested suites
JWT should be signed and verified with strong cipher algorithms