forked from eslint/eslint
/
no-var.js
35 lines (27 loc) · 795 Bytes
/
no-var.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
* @fileoverview Rule to check for the usage of var.
* @author Jamund Ferguson
*/
"use strict";
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
module.exports = {
meta: {
docs: {
description: "require `let` or `const` instead of `var`",
category: "ECMAScript 6",
recommended: false
},
schema: []
},
create: function(context) {
return {
VariableDeclaration: function(node) {
if (node.kind === "var") {
context.report(node, "Unexpected var, use let or const instead.");
}
}
};
}
};