# useless-string-operation

Rule `sonarjs/useless-string-operation`. Results of operations on strings should not be ignored

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

## Linters

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

## Code examples

### Incorrect: the rule reports this

```js
var str = "..."
str.toUpperCase(); // Noncompliant
```

### Correct: the rule accepts this

```js
var str = "..."
str = str.toUpperCase();
```

Examples from the ESLint documentation.

## Enable it

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

```js
export default [
  {
    rules: {
      "sonarjs/useless-string-operation": "error",
    },
  },
];
```

## Related rules

- [sonarjs/unicode-aware-regex](https://lintradar.dev/rules/sonarjs/unicode-aware-regex.md): Regular expressions using Unicode character classes or property escapes should enable the unicode flag
- [sonarjs/values-not-convertible-to-numbers](https://lintradar.dev/rules/sonarjs/values-not-convertible-to-numbers.md): Values not convertible to numbers should not be used in numeric comparisons
- [sonarjs/too-many-break-or-continue-in-loop](https://lintradar.dev/rules/sonarjs/too-many-break-or-continue-in-loop.md): Loops should not contain more than a single "break" or "continue" statement
- [sonarjs/variable-name](https://lintradar.dev/rules/sonarjs/variable-name.md): Variable, property and parameter names should comply with a naming convention
- [sonarjs/strings-comparison](https://lintradar.dev/rules/sonarjs/strings-comparison.md): Comparison operators should not be used with strings
- [sonarjs/shorthand-property-grouping](https://lintradar.dev/rules/sonarjs/shorthand-property-grouping.md): Shorthand object properties should be grouped at the beginning or end of an object declaration

---

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