/**
* use `angular.isObject` instead of `typeof` comparisons
*
* You should use the angular.isObject method instead of the default JavaScript implementation (typeof {} === "[object Object]").
*
* @version 0.1.0
* @category angularWrapper
*/
'use strict';
var utils = require('./utils/utils');
module.exports = function(context) {
function recordError(node, origin) {
Eif (node.type === 'Literal' && (node.value === 'object' || node.value === '[object Object]')) {
context.report(origin, 'You should use the angular.isObject method', {});
}
}
return {
BinaryExpression: function(node) {
Eif (node.operator === '===' || node.operator === '!==') {
if (utils.isTypeOfStatement(node.left) || utils.isToStringStatement(node.left)) {
recordError(node.right, node);
} else Eif (utils.isTypeOfStatement(node.right) || utils.isToStringStatement(node.right)) {
recordError(node.left, node);
}
}
}
};
};
module.exports.schema = [
// JSON Schema for rule options goes here
];
|