Skip to content

Add global variables to ESLint and JSDoc annotations validated by Typescript

Michael FIG edited this page Jun 16, 2021 · 2 revisions

How to add globals to ESLint

Add an entry in the globals object in the eslint-config package settings:

  "globals": {
    "globalThis": "readonly",
    "BigInt": "readonly",
    ...
  },

Make sure to remove any /* global */ comments as they will cause a linting error (no-redeclare) due to the variable already being declared.

How to add globals to JSDoc annotations validated by TypeScript

Find or add a globals.d.ts to your package. Within the file, add a line, like:

declare global {
  var makeKind: function;
}

In the jsconfig.json for your package, make sure the globals.d.ts is included:

  "include": ["src/**/*.js", "exported.js", "globals.d.ts"],
Clone this wiki locally