1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | 'use strict';
|
12 |
|
13 | module.exports = {
|
14 | meta: {
|
15 | schema: [{
|
16 | enum: ['$apply', '$digest']
|
17 | }]
|
18 | },
|
19 | create: function(context) {
|
20 | var method = context.options[0] || '$digest';
|
21 | var methods = ['$apply', '$digest'];
|
22 | return {
|
23 |
|
24 | MemberExpression: function(node) {
|
25 | var forbiddenMethod = methods.filter(function(m) {
|
26 | return m !== method;
|
27 | });
|
28 | if (forbiddenMethod.length > 0 && node.property.type === 'Identifier' && forbiddenMethod.indexOf(node.property.name) >= 0) {
|
29 | context.report(node, 'Instead of using the {{forbidden}}() method, you should prefer {{method}}()', {
|
30 | forbidden: node.property.name,
|
31 | method: method
|
32 | });
|
33 | }
|
34 | }
|
35 | };
|
36 | }
|
37 | };
|