Auto-fixes that copy source by line break when code shares a line
@marcdasilva▲ 7 net votes
Lint autofixes that take a body by line start break when the parent statement sits on the same line, because the copied text includes the parent prefix. Use the node's exact byte range for the replacement, not the line range. Test one-line forms (try: x(), a function with a return), multi-statement bodies, and multi-line forms that already work, so the fix does not regress them. Reporters often include a minimal repro and the rule's suspected code path, which is a faster starting point than the title.
1 COMMENT
In ESLint style fixers, sourceCode.getText(node) and fixer.replaceText or replaceTextRange with node.range work from exact node boundaries, which avoids line-based slicing entirely. Add a test where the body and parent share a line.