1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

fix: enable the reporting of parsing related problems when running deno lint (#24332)

This commit is contained in:
HasanAlrimawi 2024-07-24 00:17:17 +03:00 committed by GitHub
parent a45a40533e
commit f0df54fc70
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 29 additions and 1 deletions

View file

@ -41,6 +41,7 @@
"tests/registry/", "tests/registry/",
"tests/specs/fmt", "tests/specs/fmt",
"tests/specs/lint/bom", "tests/specs/lint/bom",
"tests/specs/lint/syntax_error_reporting",
"tests/specs/publish/no_check_surfaces_syntax_error", "tests/specs/publish/no_check_surfaces_syntax_error",
"tests/testdata/byte_order_mark.ts", "tests/testdata/byte_order_mark.ts",
"tests/testdata/encoding", "tests/testdata/encoding",

View file

@ -646,7 +646,12 @@ fn handle_lint_result(
let mut reporter = reporter_lock.lock(); let mut reporter = reporter_lock.lock();
match result { match result {
Ok((_source, mut file_diagnostics)) => { Ok((source, mut file_diagnostics)) => {
if !source.diagnostics().is_empty() {
for parse_diagnostic in source.diagnostics() {
log::warn!("{}: {}", colors::yellow("warn"), parse_diagnostic);
}
}
file_diagnostics.sort_by(|a, b| match a.specifier.cmp(&b.specifier) { file_diagnostics.sort_by(|a, b| match a.specifier.cmp(&b.specifier) {
std::cmp::Ordering::Equal => a.range.start.cmp(&b.range.start), std::cmp::Ordering::Equal => a.range.start.cmp(&b.range.start),
file_order => file_order, file_order => file_order,

View file

@ -0,0 +1,5 @@
{
"args": "lint script.ts",
"output": "lint.out",
"exitCode": 1
}

View file

@ -0,0 +1,16 @@
warn: Unterminated string constant at [WILDCARD]script.ts:1:13
const foo = 'bar
~~~~
error[no-unused-vars]: `foo` is never used
--> [WILDCARD]script.ts:1:7
|
1 | const foo = 'bar
| ^^^
= hint: If this is intentional, prefix it with an underscore like `_foo`
docs: https://lint.deno.land/rules/no-unused-vars
Found 1 problem
Checked 1 file

View file

@ -0,0 +1 @@
const foo = 'bar