mirror of https://github.com/lukechilds/node.git
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.
40 lines
1.0 KiB
40 lines
1.0 KiB
/**
|
|
* @fileoverview Rule to flag when using constructor without parentheses
|
|
* @author Ilya Volodin
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
//------------------------------------------------------------------------------
|
|
// Rule Definition
|
|
//------------------------------------------------------------------------------
|
|
|
|
module.exports = {
|
|
meta: {
|
|
docs: {
|
|
description: "require parentheses when invoking a constructor with no arguments",
|
|
category: "Stylistic Issues",
|
|
recommended: false
|
|
},
|
|
|
|
schema: []
|
|
},
|
|
|
|
create: 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");
|
|
}
|
|
}
|
|
};
|
|
|
|
}
|
|
};
|
|
|