![](/img/trans.png)
[英]How to solve no-underscore-dangle error without making the error off in config
[英]ESLint Unexpected dangling '_' in '__place' no-underscore-dangle
我有以下JSON响应,为了验证__place,我使用了responseData.search [0] .edges [0] .node。 __地点
{
"data": {
"search": [
{
"__place": "SearchResultItemConnection",
"edges": [
{
"cursor": "New",
"node": {
"__place": "Delhi",
"name": "AIIMS"
}
}
]
}
]
}
}
我收到ESLint错误,指出“错误意外悬空'_'在'__typename'no-underscore-dangle中”
我浏览了链接http://eslint.org/docs/rules/no-underscore-dangle,但我无法解决这个问题。
谁能知道如何解决这个问题,而不是改变规则?
您可以在产生错误的代码行之前添加以下注释:
/* eslint no-underscore-dangle: ["error", { "allow": ["__place"] }]*/
responseData.search[0].edges[0].node.__place
或添加
/* eslint no-underscore-dangle: 0 */
禁用该脚本文件的此特定规则。
您可以通过在配置文件中提供例外来简单地排除这些。
"no-underscore-dangle": ["error", { "allow": ["_place"] }]
如果您想要禁用整个规则(例如“no-underscore-dangle”),只需输入config:
{
rules: {
"no-underscore-dangle": 'off'
},
};
在行上方添加以下内容:
// eslint-disable-next-line no-underscore-dangle
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.