Socket
Socket
Sign inDemoInstall

eslint-plugin-angular

Package Overview
Dependencies
Maintainers
1
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-angular - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

2

package.json
{
"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'}] }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc