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 onlyselfwill work. In Node.js none of these work, and you must instead useglobal(c) MDN
🐊Putout plugin adds ability to find and apply globalThis.
Check out in 🐊Putout Editor.
npm i @putout/plugin-apply-global-this
{
"rules": {
"apply-global-this": "on"
}
}globalThis.__putout_debug = debugFn;
globalThis.CloudCmd = {};globalThis.__putout_debug = debugFn;
globalThis.CloudCmd = {};| Linter | Rule | Fix |
|---|---|---|
| 🐊 Putout | apply-global-this |
✅ |
| ⏣ ESLint | no-node-globals |
❌ |
MIT