Skip to content

Commit

Permalink
Fix: no-multi-spaces to avoid reporting consecutive tabs (fixes #9079) (
Browse files Browse the repository at this point in the history
#9087)

An unintended side-effect of the refactor in 0f97279 caused `no-multi-spaces` to start reporting any consecutive whitespace characters between tokens, rather than just reporting consecutive spaces. This commit fixes the rule to only report consecutive spaces.
  • Loading branch information
not-an-aardvark authored and kaicataldo committed Aug 7, 2017
1 parent a113cd3 commit ec93614
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 5 additions & 2 deletions lib/rules/no-multi-spaces.js
Expand Up @@ -76,8 +76,11 @@ module.exports = {
}
const rightToken = tokensAndComments[leftIndex + 1];

// Ignore tokens that have less than 2 spaces between them or are on different lines
if (leftToken.range[1] + 2 > rightToken.range[0] || leftToken.loc.end.line < rightToken.loc.start.line) {
// Ignore tokens that don't have 2 spaces between them or are on different lines
if (
!sourceCode.text.slice(leftToken.range[1], rightToken.range[0]).includes(" ") ||
leftToken.loc.end.line < rightToken.loc.start.line
) {
return;
}

Expand Down
4 changes: 3 additions & 1 deletion tests/lib/rules/no-multi-spaces.js
Expand Up @@ -101,7 +101,9 @@ ruleTester.run("no-multi-spaces", rule, {
"foo\n \f bar",

// https://github.com/eslint/eslint/issues/9001
"a".repeat(2e5)
"a".repeat(2e5),

"foo\t\t+bar"
],

invalid: [
Expand Down

0 comments on commit ec93614

Please sign in to comment.