How to use the eslint-utils.isClosingParenToken function in eslint-utils

To help you get started, we’ve selected a few eslint-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sikidamjanovic / cowrite / node_modules / @typescript-eslint / eslint-plugin / dist / rules / indent-new-do-not-use / index.js View on Github external
NewExpression(node) {
                // Only indent the arguments if the NewExpression has parens (e.g. `new Foo(bar)` or `new Foo()`, but not `new Foo`
                if (node.arguments.length > 0 ||
                    (eslint_utils_1.isClosingParenToken(sourceCode.getLastToken(node)) &&
                        eslint_utils_1.isOpeningParenToken(sourceCode.getLastToken(node, 1)))) {
                    addFunctionCallIndent(node);
                }
            },
            'ObjectExpression, ObjectPattern'(node) {
github typescript-eslint / typescript-eslint / packages / eslint-plugin / src / rules / indent-new-do-not-use / index.ts View on Github external
tokens.forEach(nextToken => {
        // Accumulate a list of parenthesis pairs
        if (isOpeningParenToken(nextToken)) {
          parenStack.push(nextToken);
        } else if (isClosingParenToken(nextToken)) {
          parenPairs.unshift({ left: parenStack.pop()!, right: nextToken });
        }
      });
github typescript-eslint / typescript-eslint / packages / eslint-plugin / src / rules / indent-new-do-not-use / index.ts View on Github external
NewExpression(node) {
        // Only indent the arguments if the NewExpression has parens (e.g. `new Foo(bar)` or `new Foo()`, but not `new Foo`
        if (
          node.arguments.length > 0 ||
          (isClosingParenToken(sourceCode.getLastToken(node)!) &&
            isOpeningParenToken(sourceCode.getLastToken(node, 1)!))
        ) {
          addFunctionCallIndent(node);
        }
      },
github sikidamjanovic / cowrite / node_modules / @typescript-eslint / eslint-plugin / dist / rules / indent-new-do-not-use / index.js View on Github external
tokens.forEach(nextToken => {
                // Accumulate a list of parenthesis pairs
                if (eslint_utils_1.isOpeningParenToken(nextToken)) {
                    parenStack.push(nextToken);
                }
                else if (eslint_utils_1.isClosingParenToken(nextToken)) {
                    parenPairs.unshift({ left: parenStack.pop(), right: nextToken });
                }
            });
            parenPairs.forEach(pair => {
github sikidamjanovic / cowrite / node_modules / @typescript-eslint / eslint-plugin / dist / rules / indent-new-do-not-use / index.js View on Github external
function addBlocklessNodeIndent(node) {
            if (node.type !== 'BlockStatement') {
                const lastParentToken = sourceCode.getTokenBefore(node, eslint_utils_1.isNotOpeningParenToken);
                let firstBodyToken = sourceCode.getFirstToken(node);
                let lastBodyToken = sourceCode.getLastToken(node);
                while (eslint_utils_1.isOpeningParenToken(sourceCode.getTokenBefore(firstBodyToken)) &&
                    eslint_utils_1.isClosingParenToken(sourceCode.getTokenAfter(lastBodyToken))) {
                    firstBodyToken = sourceCode.getTokenBefore(firstBodyToken);
                    lastBodyToken = sourceCode.getTokenAfter(lastBodyToken);
                }
                offsets.setDesiredOffsets([firstBodyToken.range[0], lastBodyToken.range[1]], lastParentToken, 1);
                /*
                 * For blockless nodes with semicolon-first style, don't indent the semicolon.
                 * e.g.
                 * if (foo) bar()
                 * ; [1, 2, 3].map(foo)
                 */
                const lastToken = sourceCode.getLastToken(node);
                if (lastToken &&
                    node.type !== 'EmptyStatement' &&
                    eslint_utils_1.isSemicolonToken(lastToken)) {
                    offsets.setDesiredOffset(lastToken, lastParentToken, 0);
                }
github typescript-eslint / typescript-eslint / packages / eslint-plugin / src / rules / indent-new-do-not-use / index.ts View on Github external
function addBlocklessNodeIndent(node: TSESTree.Node): void {
      if (node.type !== AST_NODE_TYPES.BlockStatement) {
        const lastParentToken = sourceCode.getTokenBefore(
          node,
          isNotOpeningParenToken,
        )!;

        let firstBodyToken = sourceCode.getFirstToken(node)!;
        let lastBodyToken = sourceCode.getLastToken(node)!;

        while (
          isOpeningParenToken(sourceCode.getTokenBefore(firstBodyToken)!) &&
          isClosingParenToken(sourceCode.getTokenAfter(lastBodyToken)!)
        ) {
          firstBodyToken = sourceCode.getTokenBefore(firstBodyToken)!;
          lastBodyToken = sourceCode.getTokenAfter(lastBodyToken)!;
        }

        offsets.setDesiredOffsets(
          [firstBodyToken.range[0], lastBodyToken.range[1]],
          lastParentToken,
          1,
        );

        /*
         * For blockless nodes with semicolon-first style, don't indent the semicolon.
         * e.g.
         * if (foo) bar()
         * ; [1, 2, 3].map(foo)