UNPKG

784 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.indexOf(null) > -1;
23
24 if (emptySpot) {
25 context.report(node, "Unexpected comma in middle of array.");
26 }
27 }
28
29 };
30
31};
32
33module.exports.schema = [];