Skip to content
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

babel-eslint custom parser and polyfill #881

Closed
tulsileathers opened this issue May 10, 2017 · 3 comments

Comments

@tulsileathers
Copy link

commented May 10, 2017

I'm trying to get Standard to ignore warnings for undefined variables due to using a babel polyfill (isomorphic-fetch specifically). I understand that you can use a custom parser to use experimental language features. I'm just not sure how to configure this. Can anyone give me an example of how to setup babel-eslint and standard to do this? I've searched but haven't been able to find good info. Thanks for any help.

@Flet

This comment has been minimized.

Copy link
Member

commented Jun 8, 2017

Sorry for the late reply!

There is a bit of documentation on using babel-eslint:
https://standardjs.com/#how-do-i-use-experimental-javascript-es-next-features

Its also possible to avoid "variable not defined" errors in a couple ways:
https://standardjs.com/#i-use-a-library-that-pollutes-the-global-namespace-how-do-i-prevent-variable-is-not-defined-errors

I'm going to close this issue but please feel free to respond!

@Flet Flet closed this Jun 8, 2017

@feross

This comment has been minimized.

Copy link
Member

commented Jun 22, 2017

For that library in particular (isomorphic-fetch) I recommend importing fetch explicitly and not relying on it's polyfill behavior. You want to be explicit about where fetch is coming from to satisfy standard. To do that, you have two options:

  1. Use it directly (best)
const fetch = require('isomorphic-fetch')
fetch('http://example.com')
  1. Use the global
require('isomorphic-fetch') /* global fetch */
fetch('http://example.com')

More info: #821

@karnavkumar

This comment has been minimized.

Copy link

commented Mar 21, 2018

use this global.fetch = require('node-fetch')

@lock lock bot locked as resolved and limited conversation to collaborators Jun 19, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
4 participants
You can’t perform that action at this time.