2 * @fileoverview Rule to warn when a function expression does not have a name.
3 * @author Kyle T. Nunery
4 * @copyright 2015 Brandon Mills. All rights reserved.
5 * @copyright 2014 Kyle T. Nunery. All rights reserved.
10 //------------------------------------------------------------------------------
12 //------------------------------------------------------------------------------
14 module.exports = function(context) {
17 * Determines whether the current FunctionExpression node is a get, set, or
18 * shorthand method in an object literal or a class.
19 * @returns {boolean} True if the node is a get, set, or shorthand method.
21 function isObjectOrClassMethod() {
22 var parent = context.getAncestors().pop();
24 return (parent.type === "MethodDefinition" || (
25 parent.type === "Property" && (
27 parent.kind === "get" ||
34 "FunctionExpression": function(node) {
36 var name = node.id && node.id.name;
38 if (!name && !isObjectOrClassMethod()) {
39 context.report(node, "Missing function expression name.");