Identifying (gulp-)eslint error reason

心已入冬 提交于 2019-12-24 08:38:00

问题


I have this piece of code:

sendMessage(message) {
    let data = {
        message
    };
    this.socket.send('message', data);
}

I'm using eslint and set the object-shorthand rule.

    "object-shorthand": [
        2,
        "always"
    ],

And get this error:

  ---
  message: 'Unexpected token }'
  severity: error
  data:
    line: 39
    column: 14
    ruleId: ''
  ...

But why? Any other way to find what rule is being violated?

If I do this:

sendMessage(message) {
    let data = {
        message: message
    };
    this.socket.send('message', data);
}

I get this:

  ---
  message: Expected property shorthand.
  severity: error
  data:
    line: 38
    column: 17
    ruleId: object-shorthand
  ...

It's clear what's wrong. Great.

So, how can I find what's going on? eslint is asking for object shorthands (as I told it to) but it is not accepting them... For some other reason?

Having these errors showing up all the time is distracting.

Any help is highly appreciated.

(I'm using the latest gulp-eslint: 1.0.0)


回答1:


My guess is that the fact that eslint says ruleId: '' points to a bug in eslint, not in your code. You should

  1. search in eslint's open issues (I have tried, but found nothing)
  2. if this bug is not reported, produce a minimal code displaying the bug (sorry, I don't have the time to setup things to do so myself)
  3. if successful, open a new issue


来源:https://stackoverflow.com/questions/31898616/identifying-gulp-eslint-error-reason

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!