Skip to content

Commit 5da4b79

Browse files
Simplify fix logic to remove unreachable code
Co-authored-by: NullVoxPopuli <[email protected]>
1 parent 085ccf0 commit 5da4b79

1 file changed

Lines changed: 2 additions & 23 deletions

File tree

lib/rules/template-no-accesskey-attribute.js

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -40,30 +40,9 @@ module.exports = {
4040
const attrStart = accessKeyAttr.range[0];
4141
const attrEnd = accessKeyAttr.range[1];
4242

43-
// Check if there's whitespace before the attribute that should be removed
43+
// Check if there's a space before the attribute that should be removed
4444
const sourceText = sourceCode.getText();
45-
let removeStart = attrStart;
46-
47-
// Look for preceding whitespace
48-
while (removeStart > 0 && /\s/.test(sourceText[removeStart - 1])) {
49-
removeStart--;
50-
// Stop if we hit a non-whitespace character that's not right before the attribute
51-
if (sourceText[removeStart] === '\n' || sourceText[removeStart] === '\r') {
52-
// Don't remove newlines, just spaces/tabs on the same line
53-
const beforeNewline = removeStart;
54-
while (removeStart > 0 && /[\t ]/.test(sourceText[removeStart - 1])) {
55-
removeStart--;
56-
}
57-
if (sourceText[removeStart] === '\n' || sourceText[removeStart] === '\r') {
58-
// If there's a newline, keep one space before
59-
removeStart = beforeNewline;
60-
}
61-
break;
62-
}
63-
}
64-
65-
// For simple case, just remove preceding space if it exists
66-
removeStart = attrStart > 0 && sourceText[attrStart - 1] === ' ' ? attrStart - 1 : attrStart;
45+
const removeStart = attrStart > 0 && sourceText[attrStart - 1] === ' ' ? attrStart - 1 : attrStart;
6746

6847
return fixer.removeRange([removeStart, attrEnd]);
6948
},

0 commit comments

Comments
 (0)