I’m looking for an ESLint rule that disallows usage like location
and only allows window.location
. I’ve combed through the rules, but didn’t find one, does anyone know?
Advertisement
Answer
The no-restricted-globals rule will help you with this.
Add this to your .eslintrc
file
"no-restricted-globals" : [ "error", "location", "history", ]
So in the above example eslint won’t throw an error if you use window.location
or window.history
. You can add more window properties to the list.