Simply add to .eslintrc.js:

module.exports = {
  "globals": {
    "window": true,
    "document": true
  },
  ...
}

Or add next to package.json which will do the same:

"eslintConfig": {
  "globals": {
    "window": true
  }
}

Explanation of "document is not defined" and "window is not defined"

Generally, any error like document is not defined or window is not defined in javascript means that some linter is thinking that you can't use this variable because you did not define it🤨

Commonly linter program is ESLint which is widely used in custom SPA apps, or in apps created with Create React App / Vue CLI.

But in fact, you don't need to define it. Because document or window are global variables. So what you need is only to tell the linter that it is an available variable😛