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

# no-duplicate-logical-operands

Unreleased
## Configuration

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


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

export default defineConfig([
  unicornPlugin.configs.recommended,
  {
    rules: {
      'unicorn/no-duplicate-logical-operands': 'error',
    },
  },
]);
```

## Rule Details

Disallow adjacent duplicate operands in logical expressions.

Using the same reference on adjacent sides of `&&` or `||` is usually a copy-paste mistake or redundant code. `foo && foo` and `foo || foo` evaluate the same reference twice and can be simplified to `foo`.

The rule only checks adjacent operands. It does not check non-adjacent repeats such as `foo && bar && foo`, self-comparisons such as `foo > foo`, or constant short-circuit expressions such as `true && foo`.

Examples of **incorrect** code:

```javascript
if (isReady && isReady) {
}

const result = value || value;

if (object.isReady && object.isReady) {
}
```

Examples of **correct** code:

```javascript
if (isReady) {
}

const result = value;

if (object.isReady) {
}
```

## Fixes

Duplicate identifiers and `this` expressions are autofixed.

Member expressions, and operands wrapped in TypeScript `as`, `satisfies`, `<Type>` or `!` expressions, are reported with an editor suggestion instead of an autofix because property reads can trigger getters or proxy traps.

No fix or suggestion is offered when the logical expression contains a comment outside the retained left operand.

No fix or suggestion is offered either when the logical expression is called, used as a template tag, or deleted, such as `(object.method || object.method)()`. There the expression is a plain value, while the retained operand would be a reference that changes `this`, direct `eval` or `delete` behavior. A `new` target is still fixed.

No fix or suggestion is offered when the retained operand would become the bare identifier operand of `typeof`, such as `typeof (missing || missing)`: the original throws a `ReferenceError` for an undeclared global, while `typeof missing` evaluates to `"undefined"`.

The rule skips calls, optional chains, assignments, updates, complex computed keys, and code inside `with` statements because removing one side could change runtime behavior.

## Differences from upstream

eslint-plugin-unicorn v80.0.0 autofixes `typeof (missing || missing)` to `typeof (missing)`, which changes a `ReferenceError` into `"undefined"` when `missing` is not declared. Rslint still reports the duplicate but withholds the edit when the retained operand is a bare identifier under `typeof`. Member operands such as `typeof (a.b || a.b)` keep their suggestion.

## Original Documentation

- [eslint-plugin-unicorn: no-duplicate-logical-operands](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v80.0.0/docs/rules/no-duplicate-logical-operands.md)
- [Source code](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v80.0.0/rules/no-duplicate-logical-operands.js)
