Skip to content

eslint/no-var Restriction

🛠️ An auto-fix is available for this rule.

What it does

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.

Why is this bad?

Using var in an es6 environment triggers this error

Example

javascript
// error
var x = "y";
var CONFIG = {};

// success
let x = "y";
const CONFIG = {};

References

Released under the MIT License.