// Requirements
//------------------------------------------------------------------------------
-const lodash = require("lodash");
const astUtils = require("./utils/ast-utils");
+const { upperCaseFirst } = require("../shared/string-utils");
//------------------------------------------------------------------------------
// Helpers
} else if (node.type === "ArrowFunctionExpression") {
// `=>` token
- loc = context.getSourceCode().getTokenBefore(node.body, astUtils.isArrowToken).loc.start;
+ loc = context.getSourceCode().getTokenBefore(node.body, astUtils.isArrowToken).loc;
} else if (
node.parent.type === "MethodDefinition" ||
(node.parent.type === "Property" && node.parent.method)
) {
// Method name.
- loc = node.parent.key.loc.start;
+ loc = node.parent.key.loc;
} else {
// Function name or `function` keyword.
- loc = (node.id || node).loc.start;
+ loc = (node.id || context.getSourceCode().getFirstToken(node)).loc;
}
if (!name) {
funcInfo.data = {
name: funcInfo.node.type === "Program"
? "Program"
- : lodash.upperFirst(astUtils.getFunctionNameWithKind(funcInfo.node))
+ : upperCaseFirst(astUtils.getFunctionNameWithKind(funcInfo.node))
};
} else if (funcInfo.hasReturnValue !== hasReturnValue) {
context.report({