close

no-var

Configuration

PresetConfigured Value
✅ ts.configs.recommended"error"
rslint.config.ts
import { defineConfig, js } from '@rslint/core';

export default defineConfig([
  js.configs.recommended,
  {
    rules: {
      'no-var': 'error',
    },
  },
]);

Rule Details

Requires let or const instead of var. ECMAScript 6 introduced let and const as alternatives to var for variable declarations. let and const provide block scoping, which helps avoid common issues caused by the function scoping of var.

Examples of incorrect code for this rule:

var x = 'y';
var CONFIG = {};

Examples of correct code for this rule:

let x = 'y';
const CONFIG = {};

Original Documentation