Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

source-code-error

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

source-code-error - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

14

package.json
{
"name": "source-code-error",
"version": "1.0.2",
"version": "1.1.0",
"description": "Render Error of Source-Code",

@@ -20,4 +20,4 @@ "keywords": [ "error", "code", "frame" ],

"dependencies": {
"@babel/code-frame": "7.12.11",
"chalk": "4.1.0",
"@babel/code-frame": "7.14.5",
"chalk": "4.1.2",
"strip-ansi": "6.0.0"

@@ -27,6 +27,6 @@ },

"babel-eslint": "10.1.0",
"eslint": "7.17.0",
"eslint-config-standard": "16.0.2",
"eslint-plugin-promise": "4.2.1",
"eslint-plugin-import": "2.22.1",
"eslint": "7.32.0",
"eslint-config-standard": "16.0.3",
"eslint-plugin-promise": "5.1.0",
"eslint-plugin-import": "2.24.2",
"eslint-plugin-node": "11.1.0"

@@ -33,0 +33,0 @@ },

@@ -19,1 +19,15 @@

frame = errorFrame({
type: "WARNING",
message: "Unknown warning",
origin: "somewhere",
filename: "foo.txt",
code: code,
line: 2,
column: 5,
colors: true,
newline: false
})
console.log(frame)

@@ -56,2 +56,5 @@ /*

/* determine type related color */
const color = (options.type === "ERROR" ? "red" : "yellow")
/* render code frame */

@@ -71,5 +74,5 @@ let frame = codeFrame(options.code, { start: { line: options.line, column: options.column } }, {

.replace(/(\|\s*)(\^)/, (_, m1, m2) =>
chalk.grey(m1) + chalk.bold.red(m2))
chalk.grey(m1) + chalk[color].bold(m2))
.replace(/(\n)(>)(\s*\d+\s+\|)(.*)/, (_, m1, m2, m3, m4) =>
m1 + chalk.bold.red(m2) + chalk.grey(m3) + chalk.blue(m4))
m1 + chalk[color].bold(m2) + chalk.grey(m3) + chalk.blue(m4))
}

@@ -79,10 +82,10 @@

let header = ""
header += `${chalk.bold.red(options.type + ":")} `
header += `${chalk[color].bold(options.type + ":")} `
if (options.filename !== "") {
const dirname = path.dirname(options.filename) + path.sep
const basename = path.basename(options.filename)
header += `${chalk.red("file \"")}${chalk.red(dirname)}${chalk.red.bold(basename)}${chalk.red("\", ")}`
header += `${chalk[color]("file \"")}${chalk[color](dirname)}${chalk[color].bold(basename)}${chalk[color]("\", ")}`
}
header += `${chalk.red("line ")}${chalk.red.bold(options.line)}` +
`${chalk.red(", column ")}${chalk.red.bold(options.column)}:\n`
header += `${chalk[color]("line ")}${chalk[color].bold(options.line)}` +
`${chalk[color](", column ")}${chalk[color].bold(options.column)}:\n`
if (options.message !== "" || options.origin !== "") {

@@ -89,0 +92,0 @@ header += " ".repeat(options.type.length + 2)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc