forked from EmmanuelDemey/eslint-plugin-angular
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeferred.js
More file actions
27 lines (23 loc) · 877 Bytes
/
Copy pathdeferred.js
File metadata and controls
27 lines (23 loc) · 877 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/**
* use `$q(function(resolve, reject){})` instead of `$q.deferred`
*
* When you want to create a new promise, you should not use the $q.deferred anymore.
* Prefer the new syntax : $q(function(resolve, reject){})
* @version 0.1.0
* @category bestPractice
* @sinceAngularVersion 1.x
*/
'use strict';
var utils = require('./utils/utils');
module.exports = function(context) {
return {
MemberExpression: function(node) {
if (node.object.type === 'Identifier' && utils.isAngularServiceImport(node.object.name, '$q')) {
if (node.property.type === 'Identifier' && node.property.name === 'defer') {
context.report(node, 'You should not create a new promise with this syntax. Use the $q(function(resolve, reject) {}) syntax.', {});
}
}
}
};
};
module.exports.schema = [];