Skip to content

Commit

Permalink
#Issue #446 run method devined in a service can be executed in a angu…
Browse files Browse the repository at this point in the history
…lar run method
  • Loading branch information
EmmanuelDemey committed Mar 18, 2017
1 parent 959693e commit 6768269
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion rules/utils/false-values.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

module.exports = {
config: ['jwtOptionsProvider', 'ngTableHelperProvider', '$ocLazyLoadProvider', '$route', '$localForageProvider']
config: [/Provider$/, /$route/],
run: [/mocha/, /Service$/]
};
6 changes: 3 additions & 3 deletions rules/utils/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';
var falseConfigValues = require('./false-values').config;
var falseRunValues = require('./false-values').run;

var scopeProperties = [
'$id',
Expand Down Expand Up @@ -458,8 +459,7 @@ function isAngularRunSection(node) {
return isMemberExpression(node.callee) &&
node.callee.property.type === 'Identifier' &&
node.callee.property.name === 'run' &&
(node.callee.object.type === 'Identifier' &&
node.callee.object.name !== 'mocha');
!falseRunValues.find(pattern => new RegExp(pattern).test(node.callee.object.name));
}

/**
Expand Down Expand Up @@ -488,7 +488,7 @@ function isAngularConfigSection(node) {
return isMemberExpression(node.callee) &&
node.callee.property.type === 'Identifier' &&
node.callee.property.name === 'config' &&
falseConfigValues.indexOf(node.callee.object.name) < 0;
!falseConfigValues.find(pattern => new RegExp(pattern).test(node.callee.object.name));
}

/**
Expand Down
1 change: 1 addition & 0 deletions test/module-getter.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ eslintTester.run('module-getter', rule, {
'angular.module("module").config(function(ngTableHelperProvider){' +
'ngTableHelperProvider.config({count: 10}, {});' +
'})',
'angular.module("module").controller("ctrl", function(ReportService) { ReportService.run();});',
'angular.module("module").controller("TestCtrl", function() {});',
'angular.module("module").factory("TestService", function() {});',
'angular.module("module").service("TestService", function() {});',
Expand Down

0 comments on commit 6768269

Please sign in to comment.