@babel/code-frame
Advanced tools
+7
-6
@@ -93,3 +93,3 @@ 'use strict'; | ||
| const NEWLINE = /\r\n|[\n\r\u2028\u2029]/; | ||
| function getMarkerLines(loc, source, opts) { | ||
| function getMarkerLines(loc, source, opts, startLineBaseZero) { | ||
| const startLoc = Object.assign({ | ||
@@ -104,5 +104,5 @@ column: 0, | ||
| } = opts || {}; | ||
| const startLine = startLoc.line; | ||
| const startLine = startLoc.line - startLineBaseZero; | ||
| const startColumn = startLoc.column; | ||
| const endLine = endLoc.line; | ||
| const endLine = endLoc.line - startLineBaseZero; | ||
| const endColumn = endLoc.column; | ||
@@ -153,2 +153,3 @@ let start = Math.max(startLine - (linesAbove + 1), 0); | ||
| const shouldHighlight = opts.forceColor || isColorSupported() && opts.highlightCode; | ||
| const startLineBaseZero = (opts.startLine || 1) - 1; | ||
| const defs = getDefs(shouldHighlight); | ||
@@ -160,9 +161,9 @@ const lines = rawLines.split(NEWLINE); | ||
| markerLines | ||
| } = getMarkerLines(loc, lines, opts); | ||
| } = getMarkerLines(loc, lines, opts, startLineBaseZero); | ||
| const hasColumns = loc.start && typeof loc.start.column === "number"; | ||
| const numberMaxWidth = String(end).length; | ||
| const numberMaxWidth = String(end + startLineBaseZero).length; | ||
| const highlightedLines = shouldHighlight ? highlight(rawLines) : rawLines; | ||
| let frame = highlightedLines.split(NEWLINE, end).slice(start, end).map((line, index) => { | ||
| const number = start + 1 + index; | ||
| const paddedNumber = ` ${number}`.slice(-numberMaxWidth); | ||
| const paddedNumber = ` ${number + startLineBaseZero}`.slice(-numberMaxWidth); | ||
| const gutter = ` ${paddedNumber} |`; | ||
@@ -169,0 +170,0 @@ const hasMarker = markerLines[number]; |
+1
-1
| { | ||
| "name": "@babel/code-frame", | ||
| "version": "7.28.6", | ||
| "version": "7.29.0", | ||
| "description": "Generate errors that contain a code frame that point to source locations.", | ||
@@ -5,0 +5,0 @@ "author": "The Babel Team (https://babel.dev/team)", |
Sorry, the diff of this file is not supported yet
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
34632
2.02%211
0.48%