> 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.

# getter-return

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

| Preset                   | Configured Value |
| ------------------------ | ---------------- |
| ✅ js.configs.recommended | `"error"`        |


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

export default defineConfig([
  js.configs.recommended,
  {
    rules: {
      'getter-return': 'error',
    },
  },
]);
```

## Rule Details

Enforces that property getters contain a `return` statement that returns a value. This applies to getter methods in object literals, class declarations, and property descriptors passed to `Object.defineProperty`, `Object.defineProperties`, `Reflect.defineProperty`, and `Object.create`.

### Options

- `allowImplicit` (default: `false`): When set to `true`, allows getters to implicitly return `undefined` by using `return;` without a value.

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

```javascript
var obj = {
  get name() {
    // no return
  },
};

class Foo {
  get bar() {
    // no return
  }
}

Object.defineProperty(obj, 'prop', {
  get: function () {
    // no return
  },
});
```

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

```javascript
var obj = {
  get name() {
    return 'foo';
  },
};

class Foo {
  get bar() {
    return this._bar;
  }
}

Object.defineProperty(obj, 'prop', {
  get: function () {
    return this._prop;
  },
});

// Throw statements are valid exit paths
class AbstractFoo {
  get value() {
    throw new Error('Not implemented');
  }
}

// All code paths must return or throw
class Bar {
  get value() {
    if (condition) {
      return this._value;
    } else {
      throw new Error('Invalid state');
    }
  }
}
```

Examples of **correct** code with `{ allowImplicit: true }`:

```javascript
var obj = {
  get name() {
    return;
  },
};
```

## Original Documentation

- [ESLint: getter-return](https://eslint.org/docs/latest/rules/getter-return)
- [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/getter-return.js)
