UNPKG

922 BJavaScriptView Raw
1/**
2 * use the `$log` service instead of the `console` methods
3 *
4 * You should use $log service instead of console for the methods 'log', 'debug', 'error', 'info', 'warn'
5 * @version 0.1.0
6 * @category angularWrapper
7 * @sinceAngularVersion 1.x
8 */
9'use strict';
10
11module.exports = {
12 meta: {
13 docs: {
14 url: 'https://github.com/Gillespie59/eslint-plugin-angular/blob/master/docs/rules/log.md'
15 },
16 schema: []
17 },
18 create: function(context) {
19 var method = ['log', 'debug', 'error', 'info', 'warn'];
20
21 return {
22
23 MemberExpression: function(node) {
24 if (node.object.name === 'console' && method.indexOf(node.property.name) >= 0) {
25 context.report(node, 'You should use the "' + node.property.name + '" method of the AngularJS Service $log instead of the console object');
26 }
27 }
28 };
29 }
30};