node/tools/eslint/lib/rules/no-undef-init.js
Michaël Zasso 2d441493a4 tools: update eslint to v1.10.3
PR-URL: https://github.com/nodejs/io.js/pull/2286
Reviewed-By: Roman Reiss <me@silverwind.io>
2016-01-13 23:15:39 +01:00

31 lines
836 B
JavaScript

/**
* @fileoverview Rule to flag when initializing to undefined
* @author Ilya Volodin
* @copyright 2013 Ilya Volodin. All rights reserved.
* See LICENSE in root directory for full license.
*/
"use strict";
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
module.exports = function(context) {
return {
"VariableDeclarator": function(node) {
var name = node.id.name,
init = node.init && node.init.name;
if (init === "undefined" && node.parent.kind !== "const") {
context.report(node, "It's not necessary to initialize '{{name}}' to undefined.", { name: name });
}
}
};
};
module.exports.schema = [];