UNPKG

756 BJavaScriptView Raw
1/**
2 * @fileoverview Disallow construction of dense arrays using the Array constructor
3 * @author Matt DuVall <http://www.mattduvall.com/>
4 */
5
6//------------------------------------------------------------------------------
7// Rule Definition
8//------------------------------------------------------------------------------
9
10module.exports = function(context) {
11
12 "use strict";
13
14 function check(node) {
15 if (
16 node.arguments.length !== 1 &&
17 node.callee.type === "Identifier" &&
18 node.callee.name === "Array"
19 ) {
20 context.report(node, "The array literal notation [] is preferrable.");
21 }
22 }
23
24 return {
25 "CallExpression": check,
26 "NewExpression": check
27 };
28
29};