ESLint -- 要求使用 let 或 const 而不是 var(no-var)

详细讲解请看no-var

配置文件代码:

    // require let or const instead of var
    'no-var': 'error',

Rule Details

该规则旨在阻止 var 的使用,推荐使用 const 或 let。

Examples

错误 代码示例:

/*eslint no-var: "error"*/

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

正确 代码示例:

/*eslint no-var: "error"*/
/*eslint-env es6*/

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

results matching ""

    No results matching ""