# prefer-single-boolean-return

Rule `sonarjs/prefer-single-boolean-return`. Return of boolean expressions should not be wrapped into an "if-then-else" statement

- Source: sonarjs
- Technologies: JavaScript
- Kind: style
- Needs type information: no
- Autofix: yes, in at least one linter
- Reach: 6.2M weekly downloads of presets that enable it
- Trend: +62.1% last quarter
- Rank: #1349 by reach, #650 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `sonarjs/prefer-single-boolean-return` | yes | suggestion | package `eslint-plugin-sonarjs` | [docs](https://rules.sonarsource.com/javascript/RSPEC-1126/) |

## Code examples

### Correct: the rule accepts this

```js
return expression;
```

```js
return !!expression;
```

Examples from the ESLint documentation.

## Enable it

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

```js
export default [
  {
    rules: {
      "sonarjs/prefer-single-boolean-return": "error",
    },
  },
];
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [SonarJS recommended](https://lintradar.dev/presets/sonarjs-recommended.md) | ESLint | `eslint-plugin-sonarjs` | 230 | 6.2M | +62.1% |

## Related rules

- [sonarjs/prefer-regexp-exec](https://lintradar.dev/rules/sonarjs/prefer-regexp-exec.md): "RegExp.exec()" should be preferred over "String.match()"
- [sonarjs/prefer-specific-assertions](https://lintradar.dev/rules/sonarjs/prefer-specific-assertions.md): The most specific assertion should be used
- [sonarjs/prefer-read-only-props](https://lintradar.dev/rules/sonarjs/prefer-read-only-props.md): React props should be read-only
- [sonarjs/prefer-type-guard](https://lintradar.dev/rules/sonarjs/prefer-type-guard.md): Type predicates should be used
- [sonarjs/prefer-promise-shorthand](https://lintradar.dev/rules/sonarjs/prefer-promise-shorthand.md): Shorthand promises should be used
- [sonarjs/production-debug](https://lintradar.dev/rules/sonarjs/production-debug.md): Debugging features should not be enabled in production

---

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