thingsboard/ui/node_modules/eslint-plugin-angular/rules/no-jquery-angularelement.js
2020-05-19 11:43:42 +03:00

34 lines
1.2 KiB
JavaScript

/**
* disallow to wrap `angular.element` objects with `jQuery` or `$`
*
* You should not wrap angular.element object into jQuery(), because angular.element already return jQLite element
* @version 0.1.0
* @category angularWrapper
* @sinceAngularVersion 1.x
*/
'use strict';
module.exports = {
meta: {
docs: {
url: 'https://github.com/Gillespie59/eslint-plugin-angular/blob/master/docs/rules/no-jquery-angularelement.md'
},
schema: []
},
create: function(context) {
return {
MemberExpression: function(node) {
if (node.object.name === 'angular' && node.property.name === 'element') {
if (node.parent !== undefined && node.parent.parent !== undefined &&
node.parent.parent.type === 'CallExpression' &&
node.parent.parent.callee.type === 'Identifier' &&
(node.parent.parent.callee.name === 'jQuery' || node.parent.parent.callee.name === '$')) {
context.report(node, 'angular.element returns already a jQLite element. No need to wrap with the jQuery object', {});
}
}
}
};
}
};