no-negated-in-lhs

Disallow negating the left operand of in

deprecated

! 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#

example.js1 problem
if (!key in cache) {
  cache[key] = load(key);
}
example.jsNo problems
if (!(key in cache)) {
  cache[key] = load(key);
}