---
title: "no-negated-in-lhs"
description: "Disallow negating the left operand of `in`"
# Generated by src/codegen/lint-rule-docs.ts. Do not edit below this line.
plugin: "eslint"
aliases: ["eslint/no-negated-in-lhs"]
kind: "problem"
category: null
default: "off"
fixable: "no"
typeAware: false
deprecated: true
---

`!` binds tighter than `in`, so `!key in cache` means `(!key) in cache`. It asks whether `cache` has a property named `"true"` or `"false"`, which is almost never the question. The negation belongs around the whole test.

ESLint has deprecated this rule. Use `no-unsafe-negation` instead, which also covers `instanceof`.

## Examples

Reported:

{/* bad */}
```js
if (!key in cache) {
  cache[key] = load(key);
}
```

Not reported:

{/* good */}
```js
if (!(key in cache)) {
  cache[key] = load(key);
}
```
