function makeFunctionShorthand(fixer, node) {
            const firstKeyToken = node.computed
                ? sourceCode.getFirstToken(node, astUtils.isOpeningBracketToken)
                : sourceCode.getFirstToken(node.key);
            const lastKeyToken = node.computed
                ? sourceCode.getFirstTokenBetween(node.key, node.value, astUtils.isClosingBracketToken)
                : sourceCode.getLastToken(node.key);
            const keyText = sourceCode.text.slice(firstKeyToken.range[0], lastKeyToken.range[1]);
            let keyPrefix = "";

            if (sourceCode.commentsExistBetween(lastKeyToken, node.value)) {
                return null;
            }

            if (node.value.async) {
                keyPrefix += "async ";
            }
            if (node.value.generator) {
                keyPrefix += "*";
            }

            if (node.value.type === "FunctionExpression") {
                const functionToken = sourceCode.getTokens(node.value).find(token => token.type === "Keyword" && token.value === "function");
                const tokenBeforeParams = node.value.generator ? sourceCode.getTokenAfter(functionToken) : functionToken;

                return fixer.replaceTextRange(
                    [firstKeyToken.range[0], node.range[1]],
                    keyPrefix + keyText + sourceCode.text.slice(tokenBeforeParams.range[1], node.value.range[1])
                );
            }
            const arrowToken = sourceCode.getTokenBefore(node.value.body, { filter: token => token.value === "=>" });
            const tokenBeforeArrow = sourceCode.getTokenBefore(arrowToken);
            const hasParensAroundParameters = tokenBeforeArrow.type === "Punctuator" && tokenBeforeArrow.value === ")";
            const oldParamText = sourceCode.text.slice(sourceCode.getFirstToken(node.value, node.value.async ? 1 : 0).range[0], tokenBeforeArrow.range[1]);
            const newParamText = hasParensAroundParameters ? oldParamText : `(${oldParamText})`;

            return fixer.replaceTextRange(
                [firstKeyToken.range[0], node.range[1]],
                keyPrefix + keyText + newParamText + sourceCode.text.slice(arrowToken.range[1], node.value.range[1])
            );

        }
function makeFunctionShorthand(fixer, node) {
            const firstKeyToken = node.computed
                ? sourceCode.getFirstToken(node, astUtils.isOpeningBracketToken)
                : sourceCode.getFirstToken(node.key);
            const lastKeyToken = node.computed
                ? sourceCode.getFirstTokenBetween(node.key, node.value, astUtils.isClosingBracketToken)
                : sourceCode.getLastToken(node.key);
            const keyText = sourceCode.text.slice(firstKeyToken.range[0], lastKeyToken.range[1]);
            let keyPrefix = "";

            if (sourceCode.commentsExistBetween(lastKeyToken, node.value)) {
                return null;
            }

            if (node.value.async) {
                keyPrefix += "async ";
            }
            if (node.value.generator) {
                keyPrefix += "*";
            }

            if (node.value.type === "FunctionExpression") {
                const functionToken = sourceCode.getTokens(node.value).find(token => token.type === "Keyword" && token.value === "function");
                const tokenBeforeParams = node.value.generator ? sourceCode.getTokenAfter(functionToken) : functionToken;

                return fixer.replaceTextRange(
                    [firstKeyToken.range[0], node.range[1]],
                    keyPrefix + keyText + sourceCode.text.slice(tokenBeforeParams.range[1], node.value.range[1])
                );
            }
            const arrowToken = sourceCode.getTokenBefore(node.value.body, { filter: token => token.value === "=>" });
            const tokenBeforeArrow = sourceCode.getTokenBefore(arrowToken);
            const hasParensAroundParameters = tokenBeforeArrow.type === "Punctuator" && tokenBeforeArrow.value === ")";
            const oldParamText = sourceCode.text.slice(sourceCode.getFirstToken(node.value, node.value.async ? 1 : 0).range[0], tokenBeforeArrow.range[1]);
            const newParamText = hasParensAroundParameters ? oldParamText : `(${oldParamText})`;

            return fixer.replaceTextRange(
                [firstKeyToken.range[0], node.range[1]],
                keyPrefix + keyText + newParamText + sourceCode.text.slice(arrowToken.range[1], node.value.range[1])
            );

        }
function makeFunctionShorthand ( fixer , node ) { const firstKeyToken = node . computed ? sourceCode . getFirstToken ( node , astUtils . isOpeningBracketToken ) : sourceCode . getFirstToken ( node . key ) ; const lastKeyToken = node . computed ? sourceCode . getFirstTokenBetween ( node . key , node . value , astUtils . isClosingBracketToken ) : sourceCode . getLastToken ( node . key ) ; const keyText = sourceCode . text . slice ( firstKeyToken . range [ 0 ] , lastKeyToken . range [ 1 ] ) ; let keyPrefix = "" ; if ( sourceCode . commentsExistBetween ( lastKeyToken , node . value ) ) { return null ; } if ( node . value . async ) { keyPrefix += "async " ; } if ( node . value . generator ) { keyPrefix += "*" ; } if ( node . value . type === "FunctionExpression" ) { const functionToken = sourceCode . getTokens ( node . value ) . find ( token => token . type === "Keyword" && token . value === "function" ) ; const tokenBeforeParams = node . value . generator ? sourceCode . getTokenAfter ( functionToken ) : functionToken ; return fixer . replaceTextRange ( [ firstKeyToken . range [ 0 ] , node . range [ 1 ] ] , keyPrefix + keyText + sourceCode . text . slice ( tokenBeforeParams . range [ 1 ] , node . value . range [ 1 ] ) ) ; } const arrowToken = sourceCode . getTokenBefore ( node . value . body , { filter : token => token . value === "=>" } ) ; const tokenBeforeArrow = sourceCode . getTokenBefore ( arrowToken ) ; const hasParensAroundParameters = tokenBeforeArrow . type === "Punctuator" && tokenBeforeArrow . value === ")" ; const oldParamText = sourceCode . text . slice ( sourceCode . getFirstToken ( node . value , node . value . async ? 1 : 0 ) . range [ 0 ] , tokenBeforeArrow . range [ 1 ] ) ; const newParamText = hasParensAroundParameters ? oldParamText : ` ${ oldParamText } ` ; return fixer . replaceTextRange ( [ firstKeyToken . range [ 0 ] , node . range [ 1 ] ] , keyPrefix + keyText + newParamText + sourceCode . text . slice ( arrowToken . range [ 1 ] , node . value . range [ 1 ] ) ) ; }
Fixes a FunctionExpression node by making it into a shorthand property.
@param {SourceCodeFixer} fixer The fixer object
@param {ASTNode} node A `Property` node that has a `FunctionExpression` or `ArrowFunctionExpression` as its value
@returns {Object} A fix for this node
Fixes a FunctionExpression node by making it into a shorthand property .
Creates a function shorthand