简体   繁体   English

ESLint在'__place'中没有下划线悬挂的意外悬空'_'

[英]ESLint Unexpected dangling '_' in '__place' no-underscore-dangle

I have the below JSON response, to validate the __place, i used responseData.search[0].edges[0].node. 我有以下JSON响应,为了验证__place,我使用了responseData.search [0] .edges [0] .node。 __place __地点

{
  "data": {
    "search": [
      {
        "__place": "SearchResultItemConnection",
        "edges": [
          {
            "cursor": "New",
            "node": {
              "__place": "Delhi",
              "name": "AIIMS"
            }
          }
        ]
      }
    ]
  }
}

I'm getting the ESLint error stating "error Unexpected dangling '_' in '__typename' no-underscore-dangle" 我收到ESLint错误,指出“错误意外悬空'_'在'__typename'no-underscore-dangle中”

I went through the link, http://eslint.org/docs/rules/no-underscore-dangle but i'm not able to resolve this. 我浏览了链接http://eslint.org/docs/rules/no-underscore-dangle,但我无法解决这个问题。

Could anyone know how to resolve this, instead of changing the rules? 谁能知道如何解决这个问题,而不是改变规则?

You can add the following comment before the code line which yields the error: 您可以在产生错误的代码行之前添加以下注释:

/* eslint no-underscore-dangle: ["error", { "allow": ["__place"] }]*/
responseData.search[0].edges[0].node.__place

or add 或添加

/* eslint no-underscore-dangle: 0 */

to disable this specific rule for that script file. 禁用该脚本文件的此特定规则。

您可以通过在配置文件中提供例外来简单地排除这些。

"no-underscore-dangle":  ["error", { "allow": ["_place"] }]

In case you would like to disable a whole rule (for example "no-underscore-dangle"), just type in config : 如果您想要禁用整个规则(例如“no-underscore-dangle”),只需输入config:

{    
   rules: {        
      "no-underscore-dangle": 'off'
   },
};

在行上方添加以下内容:

// eslint-disable-next-line no-underscore-dangle

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

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