noUndeclaredVariables (since v1.0.0)
Diagnostic Category: lint/correctness/noUndeclaredVariables
Sources:
- Same as:
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 Invalidcorrectness/noUndeclaredVariables.js:1:1 lint/correctness/noUndeclaredVariables ━━━━━━━━━━━━━━━━━━━━
⚠ The foobar variable is undeclared
> 1 │ foobar;
│ ^^^^^^
2 │
correctness/noUndeclaredVariables.js:2:1 lint/correctness/noUndeclaredVariables ━━━━━━━━━━━━━━━━━━━━
⚠ The PromiseLike variable is undeclared
1 │ // throw diagnostic for JavaScript files
> 2 │ PromiseLike;
│ ^^^^^^^^^^^
3 │