-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"fetch" is not defined #4015
Comments
Thanks for the issue! If you're reporting a bug, please be sure to include:
Requesting a new rule? Please see Proposing a New Rule for instructions. |
As this is react-specific feature, you might want to create an issue in eslint-plugin-react repository. Or they might already support this (not sure). ESLint doesn't support react out of the box. |
I tried to use the plugin, but this is a feature from react-native so it is not implemented. Besides that other modules could export that function, like |
If you just want to make sure ESLint knows about the global variable, check out the Specifying Globals section of our configuring docs. Will |
But I need to add this comment in every file that I use the It would be better to add a rule in |
Skip down a line in the docs, how about |
@lucasfeliciano Does @btmills suggestion helped? |
Hey guys, I'm traveling in brazil right now and didn't have a chance to On Sun, 4 Oct 2015 at 22:11, Ilya Volodin notifications@github.com wrote:
|
OK, closing this issue as there doesn't appear to be any task here. |
|
same issue, in comment it works in config doesn't, what the problem? |
Set the environment for a browser inside the
|
Just adding to @julius-mfc, the following will work in a non-yaml fashion:
|
Wow, 2015. The Ghost and @divyanshu013 are correct though, use |
it might be preferable to use /* global fetch:false */ at the top of your file or "globals": {
"fetch": false
} in your config, so as not to pull in other globals from the (the |
Thanks @SimenB but the question you asked wasn't how to get around the issue, the question was why we have to get around it at all given that fetch is a global - no?!? |
|
Ahh - thanks! :) So really the react plugin should handle this - shouldn't it? |
No, not unless React automatically polyfills |
So really React Native, which does provide |
I think this would be an excellent discussion to have in the eslint-plugin-react and/or react-native repositories. 😉 |
add below lines in .eslintrc and then edit something in file and save. Your error about "fetch" is not defined will be removed |
@maulikdhameliya you'll probably want as in // without fetch in globals
fetch = 'lol' // fetch is not defined
// with fetch: true
fetch = 'lol' // fine
// with fetch: false
fetch = 'lol' // error (if using `no-global-assign` (enabled in eslint:recommended)) |
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 the moment, for Pride events) and return data from the mock server. https://github.com/contentful/contentful.js Add `browser: true` to eslintrc file, otherwise it complains that the `fetch` method in MockClient has not been defined. See eslint/eslint#4015
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 the moment, for Pride events) and return data from the mock server. https://github.com/contentful/contentful.js Add `browser: true` to eslintrc file, otherwise it complains that the `fetch` method in MockClient has not been defined. See eslint/eslint#4015
From what I'm reading, react-native developers should prefer using
over
because apparently react-native is not 100% equivalent to browser env. One example is the atob function which is not in react-native's global, but is in the list of browser globals. |
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 |
|
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?
The text was updated successfully, but these errors were encountered: