How to use the eslint-utils.isSemicolonToken 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
* var foo = {
                     *     ok: true,
                     *   },
                     *   bar = 1;
                     *
                     * Account for when exiting the AST (after indentations have already been set for the nodes in
                     * the declaration) by manually increasing the indentation level of the tokens in this declarator
                     * on the same line as the start of the declaration, provided that there are declarators that
                     * follow this one.
                     */
                    offsets.setDesiredOffsets(node.range, firstToken, variableIndent, true);
                }
                else {
                    offsets.setDesiredOffsets(node.range, firstToken, variableIndent);
                }
                if (eslint_utils_1.isSemicolonToken(lastToken)) {
                    offsets.ignoreToken(lastToken);
                }
            },
            VariableDeclarator(node) {
github typescript-eslint / typescript-eslint / packages / eslint-plugin / src / rules / indent-new-do-not-use / index.ts View on Github external
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 !== AST_NODE_TYPES.EmptyStatement &&
          isSemicolonToken(lastToken)
        ) {
          offsets.setDesiredOffset(lastToken, lastParentToken, 0);
        }
      }
    }
github sikidamjanovic / cowrite / node_modules / @typescript-eslint / eslint-plugin / dist / rules / indent-new-do-not-use / index.js View on Github external
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
*/
          offsets.setDesiredOffsets(
            node.range,
            firstToken,
            variableIndent as number,
            true,
          );
        } else {
          offsets.setDesiredOffsets(
            node.range,
            firstToken,
            variableIndent as number,
          );
        }

        if (isSemicolonToken(lastToken)) {
          offsets.ignoreToken(lastToken);
        }
      },