src/content/docs/linter/rules/no-var.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="JavaScript (and super languages)" icon="seti:javascript"> ## Summary - Rule available since: `v1.0.0` - Diagnostic Category: [`lint/suspicious/noVar`](/reference/diagnostics#diagnostic-category) - This rule isn't recommended, so you need to enable it. - This rule has an [**unsafe**](/linter/#unsafe-fixes) fix. - The default severity of this rule is [**warning**](/reference/diagnostics#warning). - Sources: - Same as [`no-var`](https://eslint.org/docs/latest/rules/no-var){
"linter": {
"rules": {
"suspicious": {
"noVar": "error"
}
}
}
}
Disallow the use of var
ECMAScript 6 allows programmers to create variables with block scope instead of function scope using the let and const keywords.
Block scope is common in many other programming languages and helps programmers avoid mistakes.
var foo = 1;
const foo = 1;
let bar = 1;