Skip to content
This repository has been archived by the owner on Apr 20, 2018. It is now read-only.

Add "no-restricted-globals" #38

Open
simenbrekken opened this issue Apr 7, 2017 · 0 comments
Open

Add "no-restricted-globals" #38

simenbrekken opened this issue Apr 7, 2017 · 0 comments

Comments

@simenbrekken
Copy link
Contributor

The following won't produce an error because event and history among others are globally defined in the browser.

onClick() => {
  event.preventDefault()
  doStuff()
  history.replace('/')
}

Correct code (this example assumes withRouter from "react-router"):

onClick(event) => {
  event.preventDefault()
  doStuff()
  this.props.history.replace('/')
}

I'm suggesting that we introduce no-restricted-globals along with a list of global variables we don't consider "global".

"no-restricted-globals": ["error", "event", "history", "location"]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant