summaryrefslogtreecommitdiff
path: root/tools/node_modules/eslint/lib/rules/no-sparse-arrays.js
diff options
context:
space:
mode:
Diffstat (limited to 'tools/node_modules/eslint/lib/rules/no-sparse-arrays.js')
-rw-r--r--tools/node_modules/eslint/lib/rules/no-sparse-arrays.js43
1 files changed, 43 insertions, 0 deletions
diff --git a/tools/node_modules/eslint/lib/rules/no-sparse-arrays.js b/tools/node_modules/eslint/lib/rules/no-sparse-arrays.js
new file mode 100644
index 0000000000..3044896c61
--- /dev/null
+++ b/tools/node_modules/eslint/lib/rules/no-sparse-arrays.js
@@ -0,0 +1,43 @@
+/**
+ * @fileoverview Disallow sparse arrays
+ * @author Nicholas C. Zakas
+ */
+"use strict";
+
+//------------------------------------------------------------------------------
+// Rule Definition
+//------------------------------------------------------------------------------
+
+module.exports = {
+ meta: {
+ docs: {
+ description: "disallow sparse arrays",
+ category: "Possible Errors",
+ recommended: true
+ },
+
+ schema: []
+ },
+
+ create(context) {
+
+
+ //--------------------------------------------------------------------------
+ // Public
+ //--------------------------------------------------------------------------
+
+ return {
+
+ ArrayExpression(node) {
+
+ const emptySpot = node.elements.indexOf(null) > -1;
+
+ if (emptySpot) {
+ context.report({ node, message: "Unexpected comma in middle of array." });
+ }
+ }
+
+ };
+
+ }
+};