function isScopeOnOrWatch()

in rules/on-watch.js [30:57]


        function isScopeOnOrWatch(node, scopes) {
            if (node.type !== 'CallExpression') {
                return false;
            }

            var calledFunction = node.callee;
            if (calledFunction.type !== 'MemberExpression') {
                return false;
            }

            // can only easily tell what name was used if a simple
            // identifiers were used to access it.
            var parentObject = calledFunction.object;
            var accessedFunction = calledFunction.property;

            // cannot check name of the parent object if it is returned from a
            // complex expression.
            if (parentObject.type !== 'Identifier' ||
                accessedFunction.type !== 'Identifier') {
                return false;
            }

            var objectName = parentObject.name;
            var functionName = accessedFunction.name;

            return scopes.indexOf(objectName) >= 0 && (functionName === '$on' ||
                functionName === '$watch');
        }