sonarjs/no-incorrect-string-concat
eslint-plugin-sonarjs
No autofix
eslint.config.js
export default [
{
rules: {
"sonarjs/no-incorrect-string-concat": "error",
},
},
];Strings and non-strings should not be added
function foo() {
let x = 5 + 8; // okay
let z = "8"
return x + z; // Noncompliant; yields string "138"
}function foo() {
let x = 5 + 8;
let z = "8"
return x + Number(z);
}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/no-incorrect-string-concat
eslint-plugin-sonarjs
export default [
{
rules: {
"sonarjs/no-incorrect-string-concat": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
Function declarations should not be made within blocks
Test and hook callbacks should use a single completion style