noUndeclaredVariables
Summary
Section titled Summary- Rule available since:
v1.0.0
- Diagnostic Category:
lint/correctness/noUndeclaredVariables
- This rule doesn’t have a fix.
- The default severity of this rule is information.
- Sources:
- Same as
no-undef
- Same as
Description
Section titled DescriptionPrevents 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.
Options
Section titled OptionsThe rule provides a checkTypes
option that make the rule checks undeclared types.
The option defaults to false
.
{ "options": { "checkTypes": true }}
Examples
Section titled ExamplesInvalid
Section titled Invalidfoobar;
code-block.js:1:1 lint/correctness/noUndeclaredVariables ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ The foobar variable is undeclared.
> 1 │ foobar;
│ ^^^^^^
2 │
ℹ By default, Biome recognizes browser and Node.js globals.
You can ignore more globals using the javascript.globals configuration.
// throw diagnostic for JavaScript filesPromiseLike;
code-block.js:2:1 lint/correctness/noUndeclaredVariables ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ The PromiseLike variable is undeclared.
1 │ // throw diagnostic for JavaScript files
> 2 │ PromiseLike;
│ ^^^^^^^^^^^
3 │
ℹ By default, Biome recognizes browser and Node.js globals.
You can ignore more globals using the javascript.globals configuration.
Valid
Section titled Validtype B<T> = PromiseLike<T>
How to configure
Section titled How to configure{ "linter": { "rules": { "correctness": { "noUndeclaredVariables": "error" } } }}