ESLint dollar($) is not defined. (no-undef)

In .eslintrc.js

Add

{
  "globals": {
    "$": true
  }
}

See https://eslint.org/docs/user-guide/configuring#specifying-globals


You are missing

"env": {
  "browser": true,
  "commonjs": true,
  "es6": true,
  "jquery": true
},

$ is not declared as a global without jquery environment enabled. Because of that, you are getting a no-undef error, saying that you are using variable that haven't been declared.


You can also add this line to the top of your js file:

/* global $ */

To prevent warning over "$", or for any other global like "varName":

/* global varName */

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

You can specify environments using a comment inside of your JavaScript file, use the following format:

Add the line below as a comment at the beginning of your JavaScript file.

    /* eslint-env jquery */

The eslinter will stop throwing undefined on '$' because it will know you are working with jQuery.

Tags:

Jquery

Eslint