Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
* 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) {
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);
}
}
}
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);
}
}
}
/**
*/
offsets.setDesiredOffsets(
node.range,
firstToken,
variableIndent as number,
true,
);
} else {
offsets.setDesiredOffsets(
node.range,
firstToken,
variableIndent as number,
);
}
if (isSemicolonToken(lastToken)) {
offsets.ignoreToken(lastToken);
}
},