-
Notifications
You must be signed in to change notification settings - Fork 171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Make dlint report syntax/parsing errors #1285
Conversation
Hello @lucacasonato , |
@HasanAlrimawi Thanks for working on it! This looks very good, however this fix only applies to |
…urning them within Err. This change allows lint diagnostics errors to be shown in the same shot as the parse diagnostic errors.
@magurotuna Thank you for the informative feedback.
It would be great if you could review the changes |
Hello @magurotuna, |
@HasanAlrimawi Sorry for the delay. The approach looks great, but I think it would be even nicer if we could display syntax errors in the same way as lint errors. For instance, the target file's content is let's say: let a = 'fo and when we run dlint against this file, the result is displayed as follows: So as shown in this screenshot, syntax errors are displayed with no color while lint errors are colored. It'd be awesome to add color to syntax errors too. (I guess what you need to do to achieve it is using That said, given that the purpose of |
Hello @magurotuna , |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Supported dlint reporting of syntax/parsing errors.
The commit is made to address issue 23437 from deno repo
Code changes
Added check for
ParsedSource.diagnostics()
and when it's not empty, an object ofParseDiagnosticsError
holding the vector ofParseDiagnostic
objects is returned as anErr
object withinfn run_linter()
in deno_lint/examples/dlint/main.rs file.PS: The change within this function was preffered over the suggested one in the issue discussion to maintain the types of returned Err in order to keep the same successful flow, since the run_linter function returns AnyError not some specific one like parse_program function, and also it's much simpler (doesn't need to append the ParseDiagnostic single object that returned from
deno_ast::parse_program
into a vector before returning it as an error).@lucacasonato