UNPKG

813 BJavaScriptView Raw
1/**
2 * @fileoverview Disallow sparse arrays
3 * @author Nicholas C. Zakas
4 */
5"use strict";
6
7//------------------------------------------------------------------------------
8// Rule Definition
9//------------------------------------------------------------------------------
10
11module.exports = function(context) {
12
13
14 //--------------------------------------------------------------------------
15 // Public
16 //--------------------------------------------------------------------------
17
18 return {
19
20 "ArrayExpression": function(node) {
21
22 var emptySpot = node.elements.some(function(value) {
23 return value === null;
24 });
25
26 if (emptySpot) {
27 context.report(node, "Unexpected comma in middle of array.");
28 }
29 }
30
31 };
32
33};