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)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay