# Set eslint to understand the p5.js library calls and not flag them as undefined

**URL:** <https://discourse.processing.org/t/set-eslint-to-understand-the-p5-js-library-calls-and-not-flag-them-as-undefined/3487>\
**Category:** p5.js\
**Created:** [September 12, 2018, 3:07pm UTC](https://discourse.processing.org/t/set-eslint-to-understand-the-p5-js-library-calls-and-not-flag-them-as-undefined/3487 "2018-09-12T15:07:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![atoro](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/atoro/32/1351_2.png) [@atoro](https://discourse.processing.org/u/atoro)\
**Post date:** [September 12, 2018, 3:07pm UTC](https://discourse.processing.org/t/set-eslint-to-understand-the-p5-js-library-calls-and-not-flag-them-as-undefined/3487/1 "2018-09-12T15:07:33Z")

</div>

**Option 1: Use `/* eslint no-undef: 0 */` at the top of your file**  
That will stop warnings for variables that are accessed but not defined within the same file.  
Example:

```auto
/* eslint no-undef: 0 */
setup = function() {
  createCanvas(400, 400);
}
draw = function() {
  ellipse(width / 2, height / 2, 100);
}

```

**Option 2: Define globals**  
Example:

```auto
/* eslint no-unused-vars: 0 */
/* globals setup: true, draw: true, createCanvas, ellipse, width, height */
setup = function() {
  createCanvas(400, 400);
}
draw = function() {
  ellipse(width / 2, height / 2, 100);
}

```

**Option 3: Use the `globals` key and define global variables in `.eslintrc` file for your project**  
Example:

````auto
{
  ... ... ... 
  "globals": {
    "setup": true,
    "draw": true,
    "createCanvas": true,
    "ellipse": true,
    "width": true,
    ... ... ... 
  }
}```

Refer to the eslint documentation about these true/false flags. Basically, they allow/disallow overwriting of the variables.

Hope, the things above will be helpful :+1:
````

---

<div class="post-metadata">

**Author:** ![dan850](https://avatars.discourse-cdn.com/v4/letter/d/e9c0ed/32.png) [@dan850](https://discourse.processing.org/u/dan850)\
**Post date:** [September 13, 2018, 6:28am UTC](https://discourse.processing.org/t/set-eslint-to-understand-the-p5-js-library-calls-and-not-flag-them-as-undefined/3487/2 "2018-09-13T06:28:15Z")

</div>

Hi, Do you have a question regarding the library calls? or is this a suggestion?

---

<div class="post-metadata">

**Author:** ![atoro](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/atoro/32/1351_2.png) [@atoro](https://discourse.processing.org/u/atoro)\
**Post date:** [September 13, 2018, 8:54am UTC](https://discourse.processing.org/t/set-eslint-to-understand-the-p5-js-library-calls-and-not-flag-them-as-undefined/3487/3 "2018-09-13T08:54:08Z")

</div>

Hi dan850!  
No, I don’t have any questions about that. Above I’ve listed 3 possible ways how these eslint “issues” can be resolved. Probably, there are some other ways to do that. It turns out that this is very common question, so I decided to share my opinion.
