quick-lint-js icon indicating copy to clipboard operation
quick-lint-js copied to clipboard

10$: warn on 'x == []'

Open strager opened this issue 2 years ago • 3 comments

x == [] is always false. Warn when comparing against an array literal, object literal, class literal, [arrow] function, or regexp literal.

strager avatar Aug 12 '22 08:08 strager

I think this is wrong. It's not always false.

const x = "";
console.log(x == []); // prints true
const x = 0;
console.log(x == []); // prints true
class Custom {
  static valueOf() {
    return 1;
  }
}
const x = 1;
console.log(x == Custom); // prints true

clegoz avatar Aug 15 '22 22:08 clegoz

I think this is wrong. It's not always false.

You are correct. We should only warn for === or !==.

strager avatar Aug 15 '22 22:08 strager

May I get this issue assigned to me, please? (I do not want the payment).

Rebraws avatar Sep 06 '22 03:09 Rebraws