|
18 | 18 | var angularRule = require('./utils/angular-rule');
|
19 | 19 |
|
20 | 20 |
|
21 |
| -module.exports = angularRule(function(context) { |
22 |
| - var limit = context.options[0] || 1; |
23 |
| - var count = 0; |
24 |
| - var msg = 'There may be at most {{limit}} AngularJS {{component}} per file, but found {{number}}'; |
| 21 | +module.exports = { |
| 22 | + meta: { |
| 23 | + schema: [{ |
| 24 | + type: 'integer' |
| 25 | + }] |
| 26 | + }, |
| 27 | + create: angularRule(function(context) { |
| 28 | + var limit = context.options[0] || 1; |
| 29 | + var count = 0; |
| 30 | + var msg = 'There may be at most {{limit}} AngularJS {{component}} per file, but found {{number}}'; |
25 | 31 |
|
26 |
| - function checkLimit(callee) { |
27 |
| - count++; |
28 |
| - if (count > limit) { |
29 |
| - context.report(callee, msg, { |
30 |
| - limit: limit, |
31 |
| - component: limit === 1 ? 'component' : 'components', |
32 |
| - number: count |
33 |
| - }); |
| 32 | + function checkLimit(callee) { |
| 33 | + count++; |
| 34 | + if (count > limit) { |
| 35 | + context.report(callee, msg, { |
| 36 | + limit: limit, |
| 37 | + component: limit === 1 ? 'component' : 'components', |
| 38 | + number: count |
| 39 | + }); |
| 40 | + } |
34 | 41 | }
|
35 |
| - } |
36 | 42 |
|
37 |
| - return { |
38 |
| - 'angular:animation': checkLimit, |
39 |
| - 'angular:config': checkLimit, |
40 |
| - 'angular:controller': checkLimit, |
41 |
| - 'angular:directive': checkLimit, |
42 |
| - 'angular:factory': checkLimit, |
43 |
| - 'angular:filter': checkLimit, |
44 |
| - 'angular:provider': checkLimit, |
45 |
| - 'angular:run': checkLimit, |
46 |
| - 'angular:service': checkLimit, |
47 |
| - 'angular:component': checkLimit |
48 |
| - }; |
49 |
| -}); |
50 |
| - |
51 |
| -module.exports.schema = [{ |
52 |
| - type: 'integer' |
53 |
| -}]; |
| 43 | + return { |
| 44 | + 'angular:animation': checkLimit, |
| 45 | + 'angular:config': checkLimit, |
| 46 | + 'angular:controller': checkLimit, |
| 47 | + 'angular:directive': checkLimit, |
| 48 | + 'angular:factory': checkLimit, |
| 49 | + 'angular:filter': checkLimit, |
| 50 | + 'angular:provider': checkLimit, |
| 51 | + 'angular:run': checkLimit, |
| 52 | + 'angular:service': checkLimit, |
| 53 | + 'angular:component': checkLimit |
| 54 | + }; |
| 55 | + }) |
| 56 | +}; |
0 commit comments