mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
964 B
38 lines
964 B
/**
|
|
* @fileoverview Rule to flag when initializing to undefined
|
|
* @author Ilya Volodin
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
//------------------------------------------------------------------------------
|
|
// Rule Definition
|
|
//------------------------------------------------------------------------------
|
|
|
|
module.exports = {
|
|
meta: {
|
|
docs: {
|
|
description: "disallow initializing variables to `undefined`",
|
|
category: "Variables",
|
|
recommended: false
|
|
},
|
|
|
|
schema: []
|
|
},
|
|
|
|
create: 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 });
|
|
}
|
|
}
|
|
};
|
|
|
|
}
|
|
};
|
|
|