From 5640ea65730abab5c9c97d77b5708f3499ec62f3 Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Fri, 1 Nov 2019 11:05:17 +0800 Subject: [PATCH] Fix: Apply base indent to multiple line breaks (fixes #127) (#128) --- lib/processor.js | 4 ++-- tests/lib/plugin.js | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/processor.js b/lib/processor.js index 8efcc55b..594efc80 100644 --- a/lib/processor.js +++ b/lib/processor.js @@ -273,7 +273,7 @@ function adjustBlock(block) { /** * Adjusts ESLint messages to point to the correct location in the Markdown. * @param {Message} message A message from ESLint. - * @returns {Message} The same message, but adjusted ot the correct location. + * @returns {Message} The same message, but adjusted to the correct location. */ return function adjustMessage(message) { @@ -308,7 +308,7 @@ function adjustBlock(block) { // Apply the mapping delta for this range. return range + block.rangeMap[i - 1].md; }), - text: message.fix.text.replace("\n", `\n${block.baseIndentText}`) + text: message.fix.text.replace(/\n/g, `\n${block.baseIndentText}`) }; } diff --git a/tests/lib/plugin.js b/tests/lib/plugin.js index a0a50255..6fb03b94 100644 --- a/tests/lib/plugin.js +++ b/tests/lib/plugin.js @@ -665,6 +665,7 @@ describe("plugin", () => { ">", "> > ```js", "> > console.log('Hello, \\", + "> > new\\", "> > world!')", "> > console.log('Hello, \\", "> > world!')", @@ -682,6 +683,7 @@ describe("plugin", () => { ">", "> > ```js", "> > console.log(\"Hello, \\", + "> > new\\", "> > world!\")", "> > console.log(\"Hello, \\", "> > world!\")",