1 | /**
|
2 | * @fileoverview Rule to flag when using constructor for wrapper objects
|
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 wrapperObjects = ["String", "Number", "Boolean", "Math", "JSON"];
|
18 | if (wrapperObjects.indexOf(node.callee.name) > -1) {
|
19 | context.report(node, "Do not use {{fn}} as a constructor.", { fn: node.callee.name });
|
20 | }
|
21 | }
|
22 | };
|
23 |
|
24 | };
|