no-implicit-globals
eslint
No autofix
eslint.config.js
export default [
{
rules: {
"no-implicit-globals": "error",
},
},
];var foo = 1;
function bar() {}foo = 1;
Bar.prototype.baz = function () {
a = 1; // Intended to be this.a = 1;
};/*global foo:readonly*/
foo = 1;
Array = [];
var Object;// explicitly set on window
window.foo = 1;
window.bar = function() {};
// intended to be scope to this file
(function() {
var foo = 1;
function bar() {}
})();// foo and bar are local to module
var foo = 1;
function bar() {}/* exported global_var */
var global_var = 42;Examples from the ESLint documentation.
no-implicit-globals
eslint
export default [
{
rules: {
"no-implicit-globals": "error",
},
},
];no-implicit-globals
eslint plugin · restriction
{
"rules": {
"no-implicit-globals": "error"
}
}Biome does not have this rule.
Disallow null comparisons without type-checking operators
Disallow use of Object.prototype.hasOwnProperty.call() and prefer use of Object.hasOwn()
Require function names to match the name of the variable or property to which they are assigned
Disallow specified modules when loaded by import
Enforce the use of u or v flag on regular expressions
Disallow specified warning terms in comments