noRestrictedGlobals
Ce contenu n’est pas encore disponible dans votre langue.
Diagnostic Category: lint/style/noRestrictedGlobals
Since: v1.0.0
Sources:
- Same as:
no-restricted-globals
Description
Section titled “Description”This rule allows you to specify global variable names that you don’t want to use in your application.
Disallowing usage of specific global variables can be useful if you want to allow a set of global variables by enabling an environment, but still want to disallow some of those.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”console.log(event)
code-block.js:1:13 lint/style/noRestrictedGlobals ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ Do not use the global variable event.
> 1 │ console.log(event)
│ ^^^^^
2 │
ℹ Use a local variable instead.
function f(event) { console.log(event)}
Options
Section titled “Options”Use the options to specify additional globals that you want to restrict in your source code.
{ "//": "...", "options": { "deniedGlobals": ["$", "MooTools"] }}
In the example above, the rule will emit a diagnostics if tried to use $
or MooTools
without
creating a local variable.
How to configure
Section titled “How to configure”{ "linter": { "rules": { "style": { "noRestrictedGlobals": "error" } } }}