noUndeclaredVariables (since v1.0.0)
Diagnostic Category: lint/correctness/noUndeclaredVariables
Source: no-undef
Prevents the usage of variables that haven’t been declared inside the document.
If you need to allow-list some global bindings, you can use the javascript.globals
configuration.
Examples
Section titled ExamplesInvalid
Section titled Invalidfoobar;
correctness/noUndeclaredVariables.js:1:1 lint/correctness/noUndeclaredVariables ━━━━━━━━━━━━━━━━━━━━
⚠ The foobar variable is undeclared
> 1 │ foobar;
│ ^^^^^^
2 │
// throw diagnostic for JavaScript filesPromiseLike;
correctness/noUndeclaredVariables.js:2:1 lint/correctness/noUndeclaredVariables ━━━━━━━━━━━━━━━━━━━━
⚠ The PromiseLike variable is undeclared
1 │ // throw diagnostic for JavaScript files
> 2 │ PromiseLike;
│ ^^^^^^^^^^^
3 │
Valid
Section titled Validtype B<T> = PromiseLike<T>