all files / eslint-plugin-angular/rules/ log.js

100% Statements 6/6
100% Branches 4/4
100% Functions 2/2
100% Lines 6/6
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                  18×   18×     16×                
/**
 * use the `$log` service instead of the `console` methods
 *
 * You should use $log service instead of console for the methods 'log', 'debug', 'error', 'info', 'warn'
 * @version 0.1.0
 * @category angularWrapper
 */
'use strict';
 
module.exports = function(context) {
    var method = ['log', 'debug', 'error', 'info', 'warn'];
 
    return {
 
        MemberExpression: function(node) {
            if (node.object.name === 'console' && method.indexOf(node.property.name) >= 0) {
                context.report(node, 'You should use the "' + node.property.name + '" method of the AngularJS Service $log instead of the console object');
            }
        }
    };
};
 
module.exports.schema = [
    // JSON Schema for rule options goes here
];