unicorn/prefer-global-this
eslint-plugin-unicorn
Safe autofix
eslint.config.js
import unicorn from "eslint-plugin-unicorn";
export default [
{
plugins: { unicorn },
rules: {
"unicorn/prefer-global-this": "error",
},
},
];window;window.foo;global;globalThis;globalThis.foo;globalThis;Examples from the ESLint documentation.
unicorn/prefer-global-this
eslint-plugin-unicorn
import unicorn from "eslint-plugin-unicorn";
export default [
{
plugins: { unicorn },
rules: {
"unicorn/prefer-global-this": "error",
},
},
];unicorn/prefer-global-this
unicorn plugin · style
{
"rules": {
"unicorn/prefer-global-this": "error"
}
}style/useGlobalThis
style · since 2.3.14
{
"linter": {
"rules": {
"style": {
"useGlobalThis": "error"
}
}
}
}Disallow unnecessary .toArray() on iterators.
Prefer using the String.raw tag to avoid escaping \.
Prefer top-level await over top-level promises and async function calls.
Prefer drawing canvases directly instead of converting them to images.