summaryrefslogtreecommitdiff
path: root/tools/node_modules/eslint/node_modules/@babel/code-frame/lib/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'tools/node_modules/eslint/node_modules/@babel/code-frame/lib/index.js')
-rw-r--r--tools/node_modules/eslint/node_modules/@babel/code-frame/lib/index.js6
1 files changed, 3 insertions, 3 deletions
diff --git a/tools/node_modules/eslint/node_modules/@babel/code-frame/lib/index.js b/tools/node_modules/eslint/node_modules/@babel/code-frame/lib/index.js
index 1f64c6ce7b..35176fbc06 100644
--- a/tools/node_modules/eslint/node_modules/@babel/code-frame/lib/index.js
+++ b/tools/node_modules/eslint/node_modules/@babel/code-frame/lib/index.js
@@ -66,7 +66,7 @@ function getMarkerLines(loc, source, opts) {
markerLines[lineNumber] = true;
} else if (i === 0) {
const sourceLength = source[lineNumber - 1].length;
- markerLines[lineNumber] = [startColumn, sourceLength - startColumn];
+ markerLines[lineNumber] = [startColumn, sourceLength - startColumn + 1];
} else if (i === lineDiff) {
markerLines[lineNumber] = [0, endColumn];
} else {
@@ -102,7 +102,6 @@ function codeFrameColumns(rawLines, loc, opts = {}) {
return highlighted ? chalkFn(string) : string;
};
- if (highlighted) rawLines = (0, _highlight().default)(rawLines, opts);
const lines = rawLines.split(NEWLINE);
const {
start,
@@ -111,7 +110,8 @@ function codeFrameColumns(rawLines, loc, opts = {}) {
} = getMarkerLines(loc, lines, opts);
const hasColumns = loc.start && typeof loc.start.column === "number";
const numberMaxWidth = String(end).length;
- let frame = lines.slice(start, end).map((line, index) => {
+ const highlightedLines = highlighted ? (0, _highlight().default)(rawLines, opts) : rawLines;
+ let frame = highlightedLines.split(NEWLINE).slice(start, end).map((line, index) => {
const number = start + 1 + index;
const paddedNumber = ` ${number}`.slice(-numberMaxWidth);
const gutter = ` ${paddedNumber} | `;