识别(gulp-)eslint错误原因 [英] Identifying (gulp-)eslint error reason

查看:866
本文介绍了识别(gulp-)eslint错误原因的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这段代码:

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

我使用eslint并设置了对象简写规则。

 object-shorthand:[
2,
always
],

并得到这个错误:

 < code --- --- 
消息:'Unexpected token}'
严重性:错误
数据:
行:39
列:14
ruleId:''
...

但是为什么?任何其他方式来找到违反规则?



如果我这样做:

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

我得到这个:

  --- 
消息:期望的财产速记。
严重性:错误
数据:
行:38
列:17
ruleId:对象简写
...

很明显什么是错的。很好。



那么,我怎么能找到发生了什么事? eslint正在要求对象简写(正如我告诉的那样),但它不接受它们......出于某种其他原因?

这些错误总是显示出来



(我正在使用最新版的gulp-eslint: 1.0.0)

解决方案

我的猜测是eslint表示 ruleId:''指向eslint中的一个错误,而不是在你的代码中。您应该


  1. 搜索eslint的未解决问题(我已经尝试了,但什么都没找到)。这个bug没有被报告,产生了一个显示错误的最小代码(对不起,我没有时间自己设置这些东西)

  2. 如果成功,请打开一个新问题


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)

解决方案

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

这篇关于识别(gulp-)eslint错误原因的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆