unfold / eslint-config

Unfold's ESLint config

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add "no-restricted-globals"

simenbrekken opened this issue · comments

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"]