You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 27, 2021. It is now read-only.
After looking into @babel/code-frame to improve the code-frame of eslint errors, i saw that someone already done that (maybe without @babel/code-frame).
my initial poc for showing any (not just eslint) error code frame using @babel/code-frame is: (very bad implementation but it's working)
functiondisplayError(severity,error){constlocationInfo=error.message.split('[24m')[1].split('m')[1].split('[')[0]const[line,column]=locationInfo.split(':')constfilePath=error.webpackError.module.resourceconstrawFileAsString=fs.readFileSync(filePath,'utf8')constlocation={start: {line: Number(line),column: Number(column.slice(0,column.length-1))}}constresult=codeFrameColumns(rawFileAsString,location,{highlightCode:true// show colors in the code that we print in the terminal})console.log(result)returnresult}
the core problem is finding the line and column numbers. we just don't have them.
we need to to give to babel and to create a link so the user can go to the error location.
when writing a eslint-formatter, you have direct access to them.
in the furure, if we can find a way to get the column and line number nicely, we can build a single solution for any kind of errors. for now, i'm not sure how so i have a solution to the eslint errors.
npm install eslint-formatter-friendly --save-dev
This is a different (non-default) eslint-loader formatter to show warnings and errors: