ESLint doesn't allow logical assignment operators

Logical assignment operators are unsupported by ESLint, but work when the site is run.

The operators:

  • ??=
  • ||=
  • &&=

I have tried editing the .eslintrc.json file, but the ESLint option is unavailable.

Thanks!

2 Likes

I have noticed a few more missing things:

  • Private class variables/functions along with static variables:
class example {
  static staticVariable = 5;

  constructor() {
    this.#privateVariable = 0;
  }
}
  • If you make a file with a .js extension (test.js), then rename it to have a .html extension (test.html) it will still keep the .js extension colour.
  • Making a file with errors, then renaming it to having an extension without linting (.txt, .md) will still keep the errors.

Possible Reason

The initial problem and the first one on the above list may have one simple reason: The JSLint version is too old.


Welp, that’s all I have for now, have a good rest of your day!

Using logical assignment operators (e.g. ||=, &&=) causes a “Unexpected token =” error message to be shown in the editor, but is supported by all browsers (per MDN) and works perfectly fine when the site is run.

Not really a big deal, but my OCD gets annoyed when I see the red circle next to the line from using &&=, so can this be updated?

Hi @Haizlbliek, @import_coder - I’ve filed a ticket for the team to look into making these operators not throw a linting error. Thanks for flagging!

Thanks for noticing!

It will be a glorious day when this gets fixed.