You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
/**
|
|
|
|
* @fileoverview Rule to flag when using constructor without parentheses
|
|
|
|
* @author Ilya Volodin
|
|
|
|
*/
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// Rule Definition
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
module.exports = function(context) {
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
"NewExpression": function(node) {
|
|
|
|
var tokens = context.getTokens(node);
|
|
|
|
var prenticesTokens = tokens.filter(function(token) {
|
|
|
|
return token.value === "(" || token.value === ")";
|
|
|
|
});
|
|
|
|
if (prenticesTokens.length < 2) {
|
|
|
|
context.report(node, "Missing '()' invoking a constructor");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports.schema = [];
|