Skip to content

Commit

Permalink
Chore: avoid using legacy report API in no-irregular-whitespace (#11013)
Browse files Browse the repository at this point in the history
This updates the no-irregular-whitespace rule to avoid using the legacy multi-argument `context.report` API. We have a linting rule to enforce against using the API, but the rule wasn't enforcing it in this case.

This was originally found by Aladdin-ADD in eslint-community/eslint-plugin-eslint-plugin#64.
  • Loading branch information
not-an-aardvark committed Oct 24, 2018
1 parent 5a31a92 commit 3d88b38
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions lib/rules/no-irregular-whitespace.js
Expand Up @@ -81,9 +81,7 @@ module.exports = {
const locStart = node.loc.start;
const locEnd = node.loc.end;

errors = errors.filter(error => {
const errorLoc = error[1];

errors = errors.filter(({ loc: errorLoc }) => {
if (errorLoc.line >= locStart.line && errorLoc.line <= locEnd.line) {
if (errorLoc.column >= locStart.column && (errorLoc.column <= locEnd.column || errorLoc.line < locEnd.line)) {
return false;
Expand Down Expand Up @@ -157,7 +155,7 @@ module.exports = {
column: match.index
};

errors.push([node, location, "Irregular whitespace not allowed."]);
errors.push({ node, message: "Irregular whitespace not allowed.", loc: location });
}
});
}
Expand All @@ -182,7 +180,7 @@ module.exports = {
column: sourceLines[lineIndex].length
};

errors.push([node, location, "Irregular whitespace not allowed."]);
errors.push({ node, message: "Irregular whitespace not allowed.", loc: location });
lastLineIndex = lineIndex;
}
}
Expand Down Expand Up @@ -224,9 +222,7 @@ module.exports = {
}

// If we have any errors remaining report on them
errors.forEach(error => {
context.report(...error);
});
errors.forEach(error => context.report(error));
};
} else {
nodes.Program = noop;
Expand Down

0 comments on commit 3d88b38

Please sign in to comment.