all files / eslint-plugin-angular/rules/ no-private-call.js

100% Statements 9/9
100% Branches 8/8
100% Functions 3/3
100% Lines 9/9
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44                        38× 38×   77× 26×     38×     77×                                    
/**
 * disallow use of internal angular properties prefixed with $$
 *
 * All scope's properties/methods starting with $$ are used internally by AngularJS.
 * You should not use them directly.
 * Exception can be allowed with this option: {allow:['$$watchers']}
 *
 * @version 0.1.0
 * @category possibleError
 */
'use strict';
 
module.exports = function(context) {
    var options = context.options[0] || {};
    var allowed = options.allow || [];
 
    function check(node, name) {
        if (name.slice(0, 2) === '$$' && allowed.indexOf(name) < 0) {
            context.report(node, 'Using $$-prefixed Angular objects/methods are not recommended', {});
        }
    }
    return {
 
        Identifier: function(node) {
            check(node, node.name);
        }
    };
};
 
module.exports.schema = [
    {
        type: 'object',
        properties: {
            allow: {
                type: 'array',
                items: {
                    type: 'string'
                }
            }
        },
        additionalProperties: false
    }
];