Normalize newline characters so Linux and Windows trim error context consistently.

This commit is contained in:
David Anson 2025-05-04 23:39:38 -07:00
parent cdfa934d8d
commit 4ecbf9d945

View file

@ -308,9 +308,9 @@ module.exports.addErrorDetailIf = addErrorDetailIf;
* @param {RuleOnErrorFixInfo} [fixInfo] RuleOnErrorFixInfo instance. * @param {RuleOnErrorFixInfo} [fixInfo] RuleOnErrorFixInfo instance.
* @returns {void} * @returns {void}
*/ */
function addErrorContext( function addErrorContext(onError, lineNumber, context, start, end, range, fixInfo) {
onError, lineNumber, context, start, end, range, fixInfo) { // Normalize new line characters so Linux and Windows trim consistently
context = ellipsify(context, start, end); context = ellipsify(context.replace(newLineRe, "\n"), start, end);
addError(onError, lineNumber, undefined, context, range, fixInfo); addError(onError, lineNumber, undefined, context, range, fixInfo);
} }
module.exports.addErrorContext = addErrorContext; module.exports.addErrorContext = addErrorContext;