1 | /**
|
2 | * @fileoverview Rule to flag when using constructor without parentheses
|
3 | * @author Ilya Volodin
|
4 | */
|
5 |
|
6 | //------------------------------------------------------------------------------
|
7 | // Rule Definition
|
8 | //------------------------------------------------------------------------------
|
9 |
|
10 | module.exports = function(context) {
|
11 |
|
12 | ;
|
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 | };
|