summaryrefslogtreecommitdiff
path: root/tools/eslint/lib/rules/no-undef-init.js
diff options
context:
space:
mode:
Diffstat (limited to 'tools/eslint/lib/rules/no-undef-init.js')
-rw-r--r--tools/eslint/lib/rules/no-undef-init.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/tools/eslint/lib/rules/no-undef-init.js b/tools/eslint/lib/rules/no-undef-init.js
new file mode 100644
index 0000000000..60ad5700f8
--- /dev/null
+++ b/tools/eslint/lib/rules/no-undef-init.js
@@ -0,0 +1,26 @@
+/**
+ * @fileoverview Rule to flag when initializing to undefined
+ * @author Ilya Volodin
+ */
+
+"use strict";
+
+//------------------------------------------------------------------------------
+// Rule Definition
+//------------------------------------------------------------------------------
+
+module.exports = function(context) {
+
+ return {
+
+ "VariableDeclarator": function(node) {
+ var name = node.id.name;
+ var init = node.init && node.init.name;
+
+ if (init === "undefined") {
+ context.report(node, "It's not necessary to initialize '{{name}}' to undefined.", { name: name });
+ }
+ }
+ };
+
+};