# no-inconsistent-returns

Rule `sonarjs/no-inconsistent-returns`. Functions should use "return" consistently

- 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: #2151 by reach

## Linters

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

## Code examples

### Incorrect: the rule reports this

```js
function foo(a) { // Noncompliant, function exits without "return"
  if (a == 1) {
    return true;
  }
}
```

### Correct: the rule accepts this

```js
function foo(a) {
  if (a == 1) {
    return true;
  }
  return false;
}
```

Examples from the ESLint documentation.

## Enable it

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

```js
export default [
  {
    rules: {
      "sonarjs/no-inconsistent-returns": "error",
    },
  },
];
```

## Related rules

- [sonarjs/no-implicit-dependencies](https://lintradar.dev/rules/sonarjs/no-implicit-dependencies.md): Dependencies should be explicit
- [sonarjs/no-incorrect-string-concat](https://lintradar.dev/rules/sonarjs/no-incorrect-string-concat.md): Strings and non-strings should not be added
- [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-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
- [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

---

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