Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eslint disable line throws error

I am having an issue with disable-line from eslint... or it might be a bad config.

here is my setup:

.eslintrc
{
  "extends": "airbnb",
  "parser": "babel-eslint",
  "parserOptions": {
    "ecmaVersion": 6,
    "ecmaFeatures": {
      "experimentalObjectRestSpread": true
    }
  }
}
    this.input.addEventListener('keypress', ({ target: { value } }) => { // eslint-disable-line
      store.dispatch(changeText({ value }));
    });

and the result:

app.tag.js 48:54 error Parsing error: Unexpected token

which is exactly the line that I tried to disable, any ideas what might be causing that?

thanks in advance :)

like image 948
Weslley Araujo Avatar asked Apr 20 '26 07:04

Weslley Araujo


1 Answers

It's a parsing error. eslint-disable-line tells ESLint to disable its rules for a line, but ESLint still has to be able to parse the code.

The line in question:

this.input.addEventListener('keypress', ({ target: { value } }) => {

...relies on the parser understanding complex ES2015 destructured arguments. Apparently the version of ESLint you're using doesn't understand how to parse those (yet). (Your syntax is valid, so it's not an issue at your end. It's the ESLint parser.)

like image 198
T.J. Crowder Avatar answered Apr 21 '26 21:04

T.J. Crowder



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!