Skip to content

Latest commit

 

History

History

README.md

@putout/plugin-apply-global-this NPM version

Historically, accessing the global object has required different syntax in different JavaScript environments. On the web you can use window, self, or frames - but in Web Workers only self will work. In Node.js none of these work, and you must instead use global

(c) MDN

🐊Putout plugin adds ability to find and apply globalThis.

Check out in 🐊Putout Editor.

Install

npm i @putout/plugin-apply-global-this

Rule

{
    "rules": {
        "apply-global-this": "on"
    }
}

❌ Example of incorrect code

globalThis.__putout_debug = debugFn;
globalThis.CloudCmd = {};

✅ Example of correct code

globalThis.__putout_debug = debugFn;
globalThis.CloudCmd = {};

Comparison

Linter Rule Fix
🐊 Putout apply-global-this
ESLint no-node-globals

License

MIT