# no-incorrect-string-concat

Rule `sonarjs/no-incorrect-string-concat`. Strings and non-strings should not be added

- Source: sonarjs
- Technologies: JavaScript
- Kind: style
- Needs type information: yes
- Autofix: no
- Reach: 0 weekly downloads of presets that enable it
- Trend: 0% last quarter
- Rank: #2152 by reach

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `sonarjs/no-incorrect-string-concat` | no | no | package `eslint-plugin-sonarjs` | [docs](https://rules.sonarsource.com/javascript/RSPEC-3402/) |

## Code examples

### Incorrect: the rule reports this

```js
function foo() {
  let x = 5 + 8;  // okay
  let z = "8"
  return x + z;  // Noncompliant; yields string "138"
}
```

### Correct: the rule accepts this

```js
function foo() {
  let x = 5 + 8;
  let z = "8"
  return x + Number(z);
}
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
export default [
  {
    rules: {
      "sonarjs/no-incorrect-string-concat": "error",
    },
  },
];
```

## Related rules

- [sonarjs/no-inconsistent-returns](https://lintradar.dev/rules/sonarjs/no-inconsistent-returns.md): Functions should use "return" consistently
- [sonarjs/no-implicit-dependencies](https://lintradar.dev/rules/sonarjs/no-implicit-dependencies.md): Dependencies should be explicit
- [sonarjs/no-function-declaration-in-block](https://lintradar.dev/rules/sonarjs/no-function-declaration-in-block.md): Function declarations should not be made within blocks
- [sonarjs/no-mixed-completion-style](https://lintradar.dev/rules/sonarjs/no-mixed-completion-style.md): Test and hook callbacks should use a single completion style
- [sonarjs/no-for-in-iterable](https://lintradar.dev/rules/sonarjs/no-for-in-iterable.md): "for in" should not be used with iterables
- [sonarjs/no-empty-test-file](https://lintradar.dev/rules/sonarjs/no-empty-test-file.md): Test files should contain at least one test case

---

Web page: https://lintradar.dev/rules/sonarjs/no-incorrect-string-concat. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
