ecma-webpack-plugin
Advanced tools
Comparing version
@@ -22,4 +22,30 @@ const { parse } = require('acorn'); | ||
parse(content, parser); | ||
} catch ({ message }) { | ||
accumulator.push({ name, message }); | ||
} catch (error) { | ||
const { message, loc: { line, column } = {}, raisedAt } = error; | ||
const issue = { name, message }; | ||
if (line && column) { | ||
const lineOfCode = (content || '').split('\n')[line - 1]; | ||
const [ prefix, startFrom, indentation ] = column > 20 | ||
? [ '...', column - 17, 20 ] | ||
: [ '', 0, raisedAt ] | ||
; | ||
const [ suffix, endAt ] = lineOfCode.length - column > 30 | ||
? [ '...', column + 27 ] | ||
: [ '', lineOfCode.length ] | ||
; | ||
const snippet = lineOfCode.substring(startFrom, endAt); | ||
const pointer = [ | ||
' '.repeat(indentation), | ||
'^', | ||
].join(''); | ||
issue.content = [ | ||
prefix, | ||
snippet, | ||
suffix, | ||
'\n', | ||
pointer, | ||
].join(''); | ||
} | ||
accumulator.push(issue); | ||
} | ||
@@ -26,0 +52,0 @@ |
@@ -8,5 +8,5 @@ const { red, yellow } = require('chalk'); | ||
*/ | ||
module.exports = errors => errors | ||
module.exports = (errors) => errors | ||
.map( | ||
({ name, message }) => [ | ||
({ name, message, content }) => [ | ||
red('Found parsing errors in '), | ||
@@ -16,3 +16,6 @@ yellow(name), | ||
message, | ||
].join(''), | ||
content && '\n', | ||
content, | ||
].filter(Boolean).join(''), | ||
).join('\n'); | ||
{ | ||
"name": "ecma-webpack-plugin", | ||
"version": "1.1.0", | ||
"version": "1.2.0-rc.067c8e1", | ||
"description": "🧳 Verify your output code is compliant to the version you're targeting", | ||
@@ -26,4 +26,4 @@ "keywords": [ | ||
"dependencies": { | ||
"acorn": "^8.0.4", | ||
"chalk": "^4.1.0" | ||
"acorn": "^8.1.0", | ||
"chalk": "^4.1.2" | ||
}, | ||
@@ -33,8 +33,8 @@ "devDependencies": { | ||
"abuser": "^2.0.3", | ||
"chai": "^4.2.0", | ||
"eslint": "^7.11.0", | ||
"mocha": "^8.2.0", | ||
"sinon": "^9.2.0", | ||
"sinon-chai": "^3.5.0" | ||
"chai": "^4.3.4", | ||
"eslint": "^8.8.0", | ||
"mocha": "^9.2.0", | ||
"sinon": "^13.0.0", | ||
"sinon-chai": "^3.6.0" | ||
} | ||
} |
Unpublished package
Supply chain riskPackage version was not found on the registry. It may exist on a different registry and need to be configured to pull from that registry.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
4677
19.8%109
32.93%2
100%1
Infinity%Updated
Updated