lib/rules/prefer-object-spread.js
function getParenTokens(node, leftArgumentListParen, sourceCode) {
    const parens = [sourceCode.getFirstToken(node), sourceCode.getLastToken(node)];
    let leftNext = sourceCode.getTokenBefore(node);
    let rightNext = sourceCode.getTokenAfter(node);

    // Note: don't include the parens of the argument list.
    while (
        leftNext &&
        rightNext &&
        leftNext.range[0] > leftArgumentListParen.range[0] &&
        isOpeningParenToken(leftNext) &&
        isClosingParenToken(rightNext)
    ) {
        parens.push(leftNext, rightNext);
        leftNext = sourceCode.getTokenBefore(leftNext);
        rightNext = sourceCode.getTokenAfter(rightNext);
    }

    return parens.sort((a, b) => a.range[0] - b.range[0]);
}
function getParenTokens(node, leftArgumentListParen, sourceCode) {
    const parens = [sourceCode.getFirstToken(node), sourceCode.getLastToken(node)];
    let leftNext = sourceCode.getTokenBefore(node);
    let rightNext = sourceCode.getTokenAfter(node);

    // Note: don't include the parens of the argument list.
    while (
        leftNext &&
        rightNext &&
        leftNext.range[0] > leftArgumentListParen.range[0] &&
        isOpeningParenToken(leftNext) &&
        isClosingParenToken(rightNext)
    ) {
        parens.push(leftNext, rightNext);
        leftNext = sourceCode.getTokenBefore(leftNext);
        rightNext = sourceCode.getTokenAfter(rightNext);
    }

    return parens.sort((a, b) => a.range[0] - b.range[0]);
}
function getParenTokens ( node , leftArgumentListParen , sourceCode ) { const parens = [ sourceCode . getFirstToken ( node ) , sourceCode . getLastToken ( node ) ] ; let leftNext = sourceCode . getTokenBefore ( node ) ; let rightNext = sourceCode . getTokenAfter ( node ) ; // Note: don't include the parens of the argument list. while ( leftNext && rightNext && leftNext . range [ 0 ] > leftArgumentListParen . range [ 0 ] && isOpeningParenToken ( leftNext ) && isClosingParenToken ( rightNext ) ) { parens . push ( leftNext , rightNext ) ; leftNext = sourceCode . getTokenBefore ( leftNext ) ; rightNext = sourceCode . getTokenAfter ( rightNext ) ; } return parens . sort ( ( a , b ) => a . range [ 0 ] - b . range [ 0 ] ) ; }
Get the parenthesis tokens of a given ObjectExpression node.
This incldues the braces of the object literal and enclosing parentheses.
@param {ASTNode} node The node to get.
@param {Token} leftArgumentListParen The opening paren token of the argument list.
@param {SourceCode} sourceCode The source code object to get tokens.
@returns {Token[]} The parenthesis tokens of the node. This is sorted by the location.
Get the parenthesis tokens of a given ObjectExpression node . This incldues the braces of the object literal and enclosing parentheses .