DEV Community

Cover image for Typescript ESLint Global Variables
Kazi Abdur Rakib
Kazi Abdur Rakib

Posted on

Typescript ESLint Global Variables

Eslint let us specify the global variable. This configuration allows eslint to know that a variable exists even if it is not referenced in the code. Here is an example:

{
  "globals": {
    "dataLayer": true
  }
}
Enter fullscreen mode Exit fullscreen mode

In addition to specifying it, you can declare the variable as writable or not. Here is an example:

{
  "globals": {
    "dataLayer": "writable"
  }
}
Enter fullscreen mode Exit fullscreen mode

Or only declare it as read-only:

{
  "globals": {
    "dataLayer": "readonly"
  }
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)