Skip to content

Conversation

@saada
Copy link

@saada saada commented Jul 9, 2017

The props URL, fetch, location, addEventListener are available under the global window object in the browser. This was previously unclear to linter plugins such as standardjs. The solution is to either prepend all of those variables with window.* OR destructure them from the window object as shown in this commit.

Tested the code change locally and got no console or hot-reload errors.

The props `URL`, `fetch`, `location`, `addEventListener` are available under the global `window` object in the browser. This was previously unclear to linter plugins such as `standardjs`. The solution is to either prepend all of those variables with `window.*` OR destructure them from the `window` object as shown in this commit.
@facebook-github-bot
Copy link

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!


// To learn more about the benefits of this model, read https://goo.gl/KwvDNy.
// This link also includes instructions on opting out of this behavior.
const {URL, fetch, location, addEventListener} = window;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer we just explicitly keep referring to them as window.<whatever> rather than destructure here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Me too, at least window.location and window.addEventListener

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback. Made changes accordingly.

@gaearon
Copy link
Contributor

gaearon commented Jul 9, 2017

Thanks! Left a style nit but otherwise it's good to go.

@gaearon gaearon added this to the 1.0.11 milestone Jul 9, 2017
function checkValidServiceWorker(swUrl) {
// Check if the service worker can be found. If it can't reload the page.
fetch(swUrl)
window.fetch(swUrl)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. I don't think we want to do this. Pretty much all tutorials use fetch without qualifier and I don't want to confuse readers.

I'm fine with other changes but I'd rather keep this one as is. If somebody uses Standard they can feel free to change it by hand in their project.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a standard user also has the option of adding

"standard": { "globals": "fetch" }

to their package.json

@Timer Timer modified the milestones: 1.0.x, 1.0.11 Aug 9, 2017
@gaearon
Copy link
Contributor

gaearon commented Jan 9, 2018

Closing as stale

@gaearon gaearon closed this Jan 9, 2018
@lock lock bot locked and limited conversation to collaborators Jan 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants