quick-lint-js

Find bugs in JavaScript programs.

E0343: using '==' against a class literal always returns 'false'

In JavaScript, you can create a class in an expression. The class is a brand new class, so comparing the class using ==, ===, !=, or !== will always give the same result (false or true):

let Logger;
if (__DEBUG__) {
  Logger = class {
    log(msg) { console.log(msg); }
  };
} else {
  Logger == class {
    log(msg) { }
  };
}

To fix this error, write = instead of ==:

let Logger;
if (__DEBUG__) {
  Logger = class {
    log(msg) { console.log(msg); }
  };
} else {
  Logger = class {
    log(msg) { }
  };
}

Introduced in quick-lint-js version 2.10.0.

Documentation for other errors