> For AI agents: the complete documentation index is available at https://rslint.rs/llms.txt, the full documentation bundle is available at https://rslint.rs/llms-full.txt.

# consistent-return

[Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14)
## Configuration


```ts title=rslint.config.ts
import { defineConfig, ts } from '@rslint/core';

export default defineConfig([
  ts.configs.recommended,
  {
    rules: {
      '@typescript-eslint/consistent-return': 'error',
    },
  },
]);
```

## Rule Details

Require `return` statements to either always or never specify values. This is the TypeScript-enhanced version of the ESLint `consistent-return` rule. It uses type information to allow valid return patterns for functions with `void`, `undefined`, or `Promise<void>` return types.

A function with inconsistent return statements (some returning a value and some not) is typically a mistake.

Examples of **incorrect** code for this rule:

```typescript
function foo(flag: boolean): string | undefined {
  if (flag) {
    return 'hello';
  }
  return;
}

function bar(x: number) {
  if (x > 0) {
    return x;
  }
  return;
}
```

Examples of **correct** code for this rule:

```typescript
function foo(flag: boolean): string | undefined {
  if (flag) {
    return 'hello';
  }
  return undefined;
}

function bar(): void {
  if (Math.random() > 0.5) {
    return;
  }
  console.log('done');
}
```

## Original Documentation

- [typescript-eslint: consistent-return](https://typescript-eslint.io/rules/consistent-return)
- [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/consistent-return.ts)
