Skip to content

Disallow implicit accessing of window properties

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?



The no-restricted-globals rule will help you with this.

Add this to your .eslintrc file

"no-restricted-globals" : [

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.

User contributions licensed under: CC BY-SA
10 People found this is helpful