UNPKG

1.09 kBJavaScriptView Raw
1/**
2 * disallow to wrap `angular.element` objects with `jQuery` or `$`
3 *
4 * You should not wrap angular.element object into jQuery(), because angular.element already return jQLite element
5 * @version 0.1.0
6 * @category angularWrapper
7 * @sinceAngularVersion 1.x
8 */
9'use strict';
10
11module.exports = {
12 meta: {
13 schema: []
14 },
15 create: function(context) {
16 return {
17
18 MemberExpression: function(node) {
19 if (node.object.name === 'angular' && node.property.name === 'element') {
20 if (node.parent !== undefined && node.parent.parent !== undefined &&
21 node.parent.parent.type === 'CallExpression' &&
22 node.parent.parent.callee.type === 'Identifier' &&
23 (node.parent.parent.callee.name === 'jQuery' || node.parent.parent.callee.name === '$')) {
24 context.report(node, 'angular.element returns already a jQLite element. No need to wrap with the jQuery object', {});
25 }
26 }
27 }
28 };
29 }
30};