Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
kaicataldo committed Sep 12, 2019
1 parent 0192f74 commit f92352e
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions lib/rules/indent.js
Expand Up @@ -1594,14 +1594,6 @@ module.exports = {
const mayAlignWithBefore = tokenBefore && !hasBlankLinesBetween(tokenBefore, firstTokenOfLine);
const mayAlignWithAfter = tokenAfter && !hasBlankLinesBetween(firstTokenOfLine, tokenAfter);

// If a comment matches the expected indentation of the token immediately before or after, don't report it.
if (
mayAlignWithBefore && validateTokenIndent(firstTokenOfLine, offsets.getDesiredIndent(tokenBefore)) ||
mayAlignWithAfter && validateTokenIndent(firstTokenOfLine, offsets.getDesiredIndent(tokenAfter))
) {
return;
}

/*
* If a comment precedes a line that begins with a semicolon token, align to that token, i.e.
*
Expand All @@ -1611,10 +1603,14 @@ module.exports = {
*/
if (tokenAfter && astUtils.isSemicolonToken(tokenAfter) && !astUtils.isTokenOnSameLine(firstTokenOfLine, tokenAfter)) {
offsets.setDesiredOffset(firstTokenOfLine, tokenAfter, 0);
}

if (validateTokenIndent(firstTokenOfLine, offsets.getDesiredIndent(tokenAfter))) {
return;
}
// If a comment matches the expected indentation of the token immediately before or after, don't report it.
if (
mayAlignWithBefore && validateTokenIndent(firstTokenOfLine, offsets.getDesiredIndent(tokenBefore)) ||
mayAlignWithAfter && validateTokenIndent(firstTokenOfLine, offsets.getDesiredIndent(tokenAfter))
) {
return;
}
}

Expand Down

0 comments on commit f92352e

Please sign in to comment.