Sha256: c9e0cdc349df16c8563c103b8f2d4f91e962c93328a22d500cdae5eb7eb0c2da
Contents?: true
Size: 1.3 KB
Versions: 2
Compression:
Stored size: 1.3 KB
Contents
/** * @fileoverview Rule to warn when a function expression does not have a name. * @author Kyle T. Nunery * @copyright 2015 Brandon Mills. All rights reserved. * @copyright 2014 Kyle T. Nunery. All rights reserved. */ "use strict"; //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ module.exports = function(context) { /** * Determines whether the current FunctionExpression node is a get, set, or * shorthand method in an object literal or a class. * @returns {boolean} True if the node is a get, set, or shorthand method. */ function isObjectOrClassMethod() { var parent = context.getAncestors().pop(); return (parent.type === "MethodDefinition" || ( parent.type === "Property" && ( parent.method || parent.kind === "get" || parent.kind === "set" ) )); } return { "FunctionExpression": function(node) { var name = node.id && node.id.name; if (!name && !isObjectOrClassMethod()) { context.report(node, "Missing function expression name."); } } }; }; module.exports.schema = [];
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
eslint_node_modules-1.6.0.1 | vendor/node_modules/eslint/lib/rules/func-names.js |
eslint_node_modules-1.6.0 | vendor/node_modules/eslint/lib/rules/func-names.js |