1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | 'use strict';
|
12 |
|
13 | var utils = require('./utils/utils');
|
14 |
|
15 | module.exports = {
|
16 | meta: {
|
17 | schema: []
|
18 | },
|
19 | create: function(context) {
|
20 | function report(node, name) {
|
21 | context.report(node, 'The {{ctrl}} controller is useless because empty. You can remove it from your Router configuration or in one of your view', {
|
22 | ctrl: name
|
23 | });
|
24 | }
|
25 |
|
26 | return {
|
27 |
|
28 | CallExpression: function(node) {
|
29 | if (utils.isAngularControllerDeclaration(node)) {
|
30 | var name = node.arguments[0].value;
|
31 |
|
32 | var fn = node.arguments[1];
|
33 | if (utils.isArrayType(node.arguments[1])) {
|
34 | fn = node.arguments[1].elements[node.arguments[1].elements.length - 1];
|
35 | }
|
36 | if (utils.isFunctionType(fn) && utils.isEmptyFunction(fn)) {
|
37 | report(node, name);
|
38 | }
|
39 | }
|
40 | }
|
41 | };
|
42 | }
|
43 | };
|