简体   繁体   English

Eslint禁用行抛出错误

[英]Eslint disable line throws error

I am having an issue with disable-line from eslint... or it might be a bad config. 我在eslint上禁用线有问题...或者这可能是错误的配置。

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 app.tag.js 48:54错误解析错误: 意外的令牌

which is exactly the line that I tried to disable, any ideas what might be causing that? 这正是我尝试禁用的行,有什么想法可能会导致该行吗?

thanks in advance :) 提前致谢 :)

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. eslint-disable-line告诉ESLint禁用一行规则,但是ESLint仍然必须能够解析代码。

The line in question: 有问题的行:

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

...relies on the parser understanding complex ES2015 destructured arguments. ...依赖于解析器了解复杂的ES2015解构参数。 Apparently the version of ESLint you're using doesn't understand how to parse those (yet). 显然,您所使用的ESLint的版本不了解如何解析(至今)。 (Your syntax is valid, so it's not an issue at your end. It's the ESLint parser.) (您的语法是有效的,因此这不是问题,它是ESLint解析器。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM