Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
source-code-error
Advanced tools
Render Error for Source-Code
This is a small wrapper around the @babel/code-frame module for rendering a nice error message for source-code with a colorized code frame.
Installation:
$ npm install error-frame
Usage:
const sourceCodeError = require("source-code-error")
const code = `foo bar\n baz quux\nfoo bar`
let report = sourceCodeError({
message: "Unknown error",
origin: "somewhere",
filename: "foo.txt",
code: code,
line: 2,
column: 5,
colors: true,
newline: false
})
console.log(report)
Output:
ERROR: file "./foo.txt", line 2, column 5:
Unknown error [somewhere]
1 | foo bar
> 2 | baz quux
| ^
3 | foo bar
The following options in the API exist:
type: string = "ERROR"
: type of error: ERROR or WARNING [optional].message: string = ""
: error description message [optional].origin: string = ""
: error origin indicator [optional].filename: string = ""
: source code filename [optional].code: string
: source code text [required].line: number
: source code line of error [required].column: number
: source code column of error [required].above: number = 2
: source code lines to show above error [optional].below: number = 2
: source code lines to show below error [optional].newline: boolean = true
: whether to close with trailing newline [optional].colors: boolean = true
: whether to use colors [optional].Copyright (c) 2018-2019 Dr. Ralf S. Engelschall (http://engelschall.com/)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
Render Error of Source-Code
The npm package source-code-error receives a total of 4 weekly downloads. As such, source-code-error popularity was classified as not popular.
We found that source-code-error demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.