1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | 'use strict';
|
17 |
|
18 | var angularRule = require('./utils/angular-rule');
|
19 |
|
20 |
|
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}}';
|
31 |
|
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 | }
|
41 | }
|
42 |
|
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 | };
|