Skip to content

Commit

Permalink
πŸ—πŸ› Fix range in forbidden-terms-config (#37422)
Browse files Browse the repository at this point in the history
ESLint API changed so that `node.start/node.end` do not exist anymore. 

This makes the lint rule fail opaquely:

```
[13:02:52] AssertionError [ERR_ASSERTION]: Fix has invalid range: {
  "range": [
    null,
    null
  ],
  "text": ""
}
```

These values are now an array `node.range`. Correct errors after fix:

```
build-system/test-configs/forbidden-terms.js
  737:7  error  File does not exist  local/forbidden-terms-config
```
  • Loading branch information
alanorozco committed Jan 20, 2022
1 parent 5680e37 commit bc66c89
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions build-system/eslint-rules/forbidden-terms-config.js
Expand Up @@ -36,11 +36,12 @@ module.exports = {
*/
function* removeFromArray(fixer, node) {
const {text} = context.getSourceCode();
let {start} = node;
let [start] = node.range;
const [, end] = node.range;
while (/\s/.test(text[start - 1])) {
start--;
}
yield fixer.removeRange([start, node.end]);
yield fixer.removeRange([start, end]);

const after = context.getTokenAfter(node);
if (after.type === 'Punctuator' && after.value === ',') {
Expand All @@ -51,7 +52,7 @@ module.exports = {
const [nextComment] = context.getCommentsAfter(node);
if (
nextComment &&
text.substr(node.end, nextComment.start - node.end).indexOf('\n') < 0
text.substr(end, nextComment.start - end).indexOf('\n') < 0
) {
yield fixer.remove(nextComment);
}
Expand Down

0 comments on commit bc66c89

Please sign in to comment.