ESLint – “window” is not defined. How to allow global variables in package.json

I am assigning a property to the global window object, but when I run eslint, I get this:

“window” is not defined

I see this here in the eslint docs:

the following defines window as a global variable for code that should not trigger the rule being tested:

valid: [
  {
    code: "window.alert()",
    globals: [ "window" ]
  }
]

I’ve tried adding something like this to the package.json file to have eslint allow “window” as a global variable, but I must be doing something wrong. From the docs it seems like I might need to do something like this in a separate file, but is there a way to define some allowed global variables right in the package.json file?

6 Answers
6

Leave a Comment