From b35ff4ee6d2be5f78a379d9ca354089d5e024224 Mon Sep 17 00:00:00 2001 From: Todd Christensen Date: Fri, 15 Apr 2016 08:05:53 -0700 Subject: [PATCH] Correct indentation checks when using CRLFs. Otherwise we think there's an extra indent and mixed tabs. --- lib/rules/indentation.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/rules/indentation.js b/lib/rules/indentation.js index 0d7d4fea..f1991990 100644 --- a/lib/rules/indentation.js +++ b/lib/rules/indentation.js @@ -16,7 +16,8 @@ module.exports = { prevNode, space, spaceLength, - count; + count, + newlineLength; level = level || 0; @@ -35,16 +36,18 @@ module.exports = { if (n.type === 'space') { // Test for CRLF first, since it includes LF space = n.content.lastIndexOf('\r\n'); + newlineLength = 2; if (space === -1) { space = n.content.lastIndexOf('\n'); + newlineLength = 1; } if (space >= 0) { - spaceLength = n.content.slice(space + 1).length; + spaceLength = n.content.slice(space + newlineLength).length; try { - count = n.content.slice(space + 1).match(/ /g).length; + count = n.content.slice(space + newlineLength).match(/ /g).length; } catch (e) { count = 0;