No undef check error in eslint

With multi-dimensional model as the core, let the factory digital transformation and upgrading “within reach”>>>

Error report when checking with eslint after writing code

error  'window' is not defined        no-undef

This is configured in eslint to check whether global variables are available. For specific use and description, please refer to http://eslint.org/docs/rules/no-undef

But I still have to use the window object in my code. What should I do

You can add a global configuration in eslint to mark which global objects can be used

"globals":{
  "document": true,
  "localStorage": true,
  "window": true
}

Update it. In addition, you can configure it according to this document

http://eslint.org/docs/user-guide/configuring.html#specifying -environments

   "env": {
            "browser": true,
            "node": true
        }

Similar Posts: