Disallow implicit accessing of window properties

Tags: ,

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.

Source: stackoverflow