eslint-plugin-cflint
Version:
ESLint rules for CloudFlare
21 lines (18 loc) • 527 B
JavaScript
/**
* @fileoverview Rule to flag usage of String.prototype.substr.
* @author Terin Stock
*/
;
module.exports = function (context) {
return {
MemberExpression: function (node) {
var objectType = node.object.type;
var propertyName = node.property.name;
if (objectType === 'Literal' && propertyName === 'substr') {
context.report(node, '{{property}} exists for compatibility and shouldn\'t be used in new code', {
property: propertyName
});
}
}
};
};