UNPKG

674 BJavaScriptView Raw
1/**
2 * @fileoverview Rule to flag when initializing to undefined
3 * @author Ilya Volodin
4 */
5
6//------------------------------------------------------------------------------
7// Rule Definition
8//------------------------------------------------------------------------------
9
10module.exports = function(context) {
11
12 "use strict";
13
14 return {
15
16 "VariableDeclarator": function(node) {
17 var name = node.id.name;
18 var init = node.init && node.init.name;
19
20 if (init === "undefined") {
21 context.report(node, "It's not necessary to initialize '{{name}}' to undefined.", { name: name });
22 }
23 }
24 };
25
26};