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.__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"

I went through the link, but i'm not able to resolve this.

Could anyone know how to resolve this, instead of changing the rules?

1

4 Answers

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.

2

You can simply exclude those by providing exceptions in the config file.

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

In case you would like to disable a whole rule (for example "no-underscore-dangle"), just type in config :

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

Add the following above the line:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Robert Thorne

Robert Thorne

Automotive & Future Transportation Editor

Robert Thorne covers electric vehicle innovations, autonomous driving systems, global mobility trends, and automotive engineering developments.

Share this article
Twitter Facebook Pinterest