UNPKG

783 BJavaScriptView Raw
1/**
2 * @fileoverview Rule to flag when using constructor without parentheses
3 * @author Ilya Volodin
4 */
5
6"use strict";
7
8//------------------------------------------------------------------------------
9// Rule Definition
10//------------------------------------------------------------------------------
11
12module.exports = function(context) {
13
14 return {
15
16 "NewExpression": function(node) {
17 var tokens = context.getTokens(node);
18 var prenticesTokens = tokens.filter(function(token) {
19 return token.value === "(" || token.value === ")";
20 });
21 if (prenticesTokens.length < 2) {
22 context.report(node, "Missing '()' invoking a constructor");
23 }
24 }
25 };
26
27};
28
29module.exports.schema = [];