Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"fetch" is undefined and "localStorage" is undefined , on using eslint-config-airbnb in react.js

I want to modify my code structure using eslint of airbnb. I have follwed these instruction given in eslint-config-airbnb. After initiating the command npm run lint, results consists of 'fetch' is not defined and also, 'localStorage' is not defined.

I have gone through this github issue, but still error is shown as the same 'fetch is not defined'. Is there any solutions for it.

like image 366
Thananjaya S Avatar asked Mar 13 '18 07:03

Thananjaya S


3 Answers

No need to add it as an exception, just add this to your .eslintrc and eslint will know what it is:

  "env": {
    "browser": true
  }
like image 140
bora89 Avatar answered Sep 19 '22 14:09

bora89


You can configure your .eslintrc file with globals.

Add this to your .eslintrc file.

"globals": {
        "localStorage": true,
        "fetch": true
    }
like image 45
Vikramaditya Avatar answered Sep 20 '22 14:09

Vikramaditya


you can try to access to the fetch and localStorage through window object.

window.fetch, window.localStorage

like image 24
Evgeny Zaytsev Avatar answered Sep 20 '22 14:09

Evgeny Zaytsev