JavaScript Global Identifiers Registry

17.5.0 · active · verified Sun Apr 19

`globals` is a comprehensive registry of global identifiers found across various JavaScript environments, including browsers, Node.js, Web Workers, and specific frameworks like Vue, Svelte, and Astro. Currently stable at version 17.5.0, the package maintains a frequent release cadence, often monthly, to incorporate updated global lists and introduce new environment definitions. Its core utility is a JSON file (`globals.json`) that maps global variable names to a boolean value, indicating whether the variable is considered writable (`true`) or read-only (`false`), aiding static analysis tools like ESLint. This differentiation is a key feature, allowing linters to flag incorrect assignments to built-in read-only globals. While ESLint 8 and earlier implicitly bundled this package, users of ESLint 9 and later are expected to include `globals` as a direct dependency.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to import the `globals` object and access environment-specific global identifiers, showing examples for browser and Node.js environments and how to inspect their writability status.

import globals from 'globals';

// Access all browser-specific globals
console.log('Browser globals example:');
console.log(Object.keys(globals.browser).slice(0, 5));
// Expected output: [ 'addEventListener', 'applicationCache', 'ArrayBuffer', 'atob', 'Audio' ]

// Access all Node.js built-in globals (excluding CommonJS module scope)
console.log('\nNode.js built-in globals example:');
console.log(Object.keys(globals.nodeBuiltin).slice(0, 5));
// Expected output: [ '__dirname', '__filename', 'Buffer', 'clearImmediate', 'clearInterval' ]

// Check if a specific global is read-only or writable (e.g., 'window' in browser)
console.log(`\n'window' is writable in browser: ${globals.browser.window}`);
// Expected output: 'window' is writable in browser: false (or true depending on exact env config)

view raw JSON →