eslint-plugin-angular
Advanced tools
Comparing version 0.1.1 to 0.1.2
{ | ||
"name": "eslint-plugin-angular", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "ESLint rules for AngularJS projects", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -17,3 +17,3 @@ module.exports = function(context) { | ||
*/ | ||
function isScopeOnOrWatch(node) { | ||
function isScopeOnOrWatch(node, scopes) { | ||
if (node.type !== 'CallExpression') { | ||
@@ -43,5 +43,3 @@ return false; | ||
return (objectName === '$rootScope' || | ||
objectName === '$scope' || | ||
objectName === 'scope') && (functionName === '$on' || | ||
return scopes.indexOf(objectName) >= 0 && (functionName === '$on' || | ||
functionName === '$watch'); | ||
@@ -69,6 +67,6 @@ } | ||
'CallExpression': function(node) { | ||
if (isScopeOnOrWatch(node) && !isFirstArgDestroy(node)) { | ||
if (isScopeOnOrWatch(node, ['$rootScope']) && !isFirstArgDestroy(node)) { | ||
if (node.parent.type !== 'VariableDeclarator' && | ||
node.parent.type !== 'AssignmentExpression' && | ||
!(isScopeOnOrWatch(node.parent) && | ||
!(isScopeOnOrWatch(node.parent, ['$rootScope', '$scope', 'scope']) && | ||
isFirstArgDestroy(node.parent))) { | ||
@@ -75,0 +73,0 @@ report(node, node.callee.property.name); |
@@ -26,9 +26,10 @@ //------------------------------------------------------------------------------ | ||
'$scope.$on("$destroy", $rootScope.$on())', | ||
'$rootScope.$on("$destroy", $rootScope.$on())' | ||
'$rootScope.$on("$destroy", $rootScope.$on())', | ||
'scope.$on()', | ||
'scope.$watch()', | ||
'$scope.$on()', | ||
'$scope.$watch()' | ||
], | ||
invalid: [ | ||
{ code: 'scope.$on()', errors: [{ message: 'The "$on" call should be assigned to a variable, in order to be destroyed during the $destroy event'}] }, | ||
{ code: 'scope.$watch()', errors: [{ message: 'The "$watch" call should be assigned to a variable, in order to be destroyed during the $destroy event'}] }, | ||
{ code: '$scope.$on()', errors: [{ message: 'The "$on" call should be assigned to a variable, in order to be destroyed during the $destroy event'}] }, | ||
{ code: '$scope.$watch()', errors: [{ message: 'The "$watch" call should be assigned to a variable, in order to be destroyed during the $destroy event'}] }, | ||
{ code: '$rootScope.$on()', errors: [{ message: 'The "$on" call should be assigned to a variable, in order to be destroyed during the $destroy event'}] }, | ||
@@ -35,0 +36,0 @@ { code: '$rootScope.$watch()', errors: [{ message: 'The "$watch" call should be assigned to a variable, in order to be destroyed during the $destroy event'}] } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
144248
2589