ERROR: 'console is not defined. [no-undef] - Brackets

Riddick picture Riddick · Mar 28, 2018 · Viewed 19.3k times · Source

I'm basically a beginner with JavaScript. I've installed brackets and currently playing around with variables and functions. All the outputs work fine in the console, however I keep getting this error in the editor. https://i.imgur.com/SExglwR.png

How do I go about fixing this?

Answer

Amaury Liet picture Amaury Liet · Apr 5, 2019

The no-undef rule looks out for undefined variable, without any initial assumption on the environment and the global variables (console for instance).

You can specify that you are in an environment where console indeed exists, by adding browser and/or node envs in your .eslintrc:

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

More info in the rule doc