Skip to content

Commit 3d88b38

Browse files
Chore: avoid using legacy report API in no-irregular-whitespace (#11013)
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.
1 parent 5a31a92 commit 3d88b38

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

lib/rules/no-irregular-whitespace.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,7 @@ module.exports = {
8181
const locStart = node.loc.start;
8282
const locEnd = node.loc.end;
8383

84-
errors = errors.filter(error => {
85-
const errorLoc = error[1];
86-
84+
errors = errors.filter(({ loc: errorLoc }) => {
8785
if (errorLoc.line >= locStart.line && errorLoc.line <= locEnd.line) {
8886
if (errorLoc.column >= locStart.column && (errorLoc.column <= locEnd.column || errorLoc.line < locEnd.line)) {
8987
return false;
@@ -157,7 +155,7 @@ module.exports = {
157155
column: match.index
158156
};
159157

160-
errors.push([node, location, "Irregular whitespace not allowed."]);
158+
errors.push({ node, message: "Irregular whitespace not allowed.", loc: location });
161159
}
162160
});
163161
}
@@ -182,7 +180,7 @@ module.exports = {
182180
column: sourceLines[lineIndex].length
183181
};
184182

185-
errors.push([node, location, "Irregular whitespace not allowed."]);
183+
errors.push({ node, message: "Irregular whitespace not allowed.", loc: location });
186184
lastLineIndex = lineIndex;
187185
}
188186
}
@@ -224,9 +222,7 @@ module.exports = {
224222
}
225223

226224
// If we have any errors remaining report on them
227-
errors.forEach(error => {
228-
context.report(...error);
229-
});
225+
errors.forEach(error => context.report(error));
230226
};
231227
} else {
232228
nodes.Program = noop;

0 commit comments

Comments
 (0)