eslint: "fetch" is not defined
import 'isomorphic-fetch';
expose a function called “fetch” as so react-native projects.
which rule i need to use to suppress this error just for this case?
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 5
- Comments: 27 (12 by maintainers)
Links to this issue
Commits related to this issue
- Add mock client for Contentful Contentful provide a client via the contentful npm package and they provide some boilerplate code. This commit aims to mirror the client's interface (only one method at... — committed to redbadger/pride-london-app by davidbasalla 6 years ago
- Add mock client for Contentful Contentful provide a client via the contentful npm package and they provide some boilerplate code. This commit aims to mirror the client's interface (only one method at... — committed to redbadger/pride-london-app by davidbasalla 6 years ago
Set the environment for a browser inside the
.eslintrc
file:Skip down a line in the docs, how about
"globals": { "fetch": false }
?Just adding to @julius-mfc, the following will work in a non-yaml fashion:
fetch
is a global though, isn’t it? https://developer.mozilla.org/en/docs/Web/API/Fetch_APIisomorphic-fetch
is just a polyfill, IIRC. Whetherfetch
should be a predefined global I don’t know, but it’s not a react specific feature at all, unless I’ve misunderstood somethingit might be preferable to use
at the top of your file
or
in your config, so as not to pull in other globals from the
browser
env.(the
false
stops you from being allowed to overwrite it)I think this would be an excellent discussion to have in the eslint-plugin-react and/or react-native repositories. 😉
So really React Native, which does provide
fetch
, should also provide a plugin or at least document the ‘integration’. 😃For RN you could also go for something like https://github.com/satya164/eslint-plugin-react-native-globals or potentially open up at issue at https://github.com/sindresorhus/globals so you could do
{"env": "react-native": true}
.