1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | module.exports = function(context) {
|
12 |
|
13 | "use strict";
|
14 |
|
15 | return {
|
16 | "NewExpression": function(node) {
|
17 | var constructorName = "";
|
18 |
|
19 | if (node.callee.type === "MemberExpression") {
|
20 | constructorName = node.callee.property.name;
|
21 | } else {
|
22 | constructorName = node.callee.name;
|
23 | }
|
24 |
|
25 | if (constructorName && constructorName.charAt(0) === constructorName.charAt(0).toLowerCase()) {
|
26 | context.report(node, "A constructor name should start with an uppercase letter.");
|
27 | }
|
28 | }
|
29 | };
|
30 |
|
31 | };
|