diff options
-rw-r--r-- | .dprint.json | 1 | ||||
-rw-r--r-- | cli/tools/lint/mod.rs | 7 | ||||
-rw-r--r-- | tests/specs/lint/syntax_error_reporting/__test__.jsonc | 5 | ||||
-rw-r--r-- | tests/specs/lint/syntax_error_reporting/lint.out | 16 | ||||
-rw-r--r-- | tests/specs/lint/syntax_error_reporting/script.ts | 1 |
5 files changed, 29 insertions, 1 deletions
diff --git a/.dprint.json b/.dprint.json index 1ab5dfaae..beebc4d87 100644 --- a/.dprint.json +++ b/.dprint.json @@ -41,6 +41,7 @@ "tests/registry/", "tests/specs/fmt", "tests/specs/lint/bom", + "tests/specs/lint/syntax_error_reporting", "tests/specs/publish/no_check_surfaces_syntax_error", "tests/testdata/byte_order_mark.ts", "tests/testdata/encoding", diff --git a/cli/tools/lint/mod.rs b/cli/tools/lint/mod.rs index 05458a7b0..3b2af12fb 100644 --- a/cli/tools/lint/mod.rs +++ b/cli/tools/lint/mod.rs @@ -646,7 +646,12 @@ fn handle_lint_result( let mut reporter = reporter_lock.lock(); 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) { std::cmp::Ordering::Equal => a.range.start.cmp(&b.range.start), file_order => file_order, diff --git a/tests/specs/lint/syntax_error_reporting/__test__.jsonc b/tests/specs/lint/syntax_error_reporting/__test__.jsonc new file mode 100644 index 000000000..532caf320 --- /dev/null +++ b/tests/specs/lint/syntax_error_reporting/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "lint script.ts", + "output": "lint.out", + "exitCode": 1 +} diff --git a/tests/specs/lint/syntax_error_reporting/lint.out b/tests/specs/lint/syntax_error_reporting/lint.out new file mode 100644 index 000000000..31e4c576b --- /dev/null +++ b/tests/specs/lint/syntax_error_reporting/lint.out @@ -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 diff --git a/tests/specs/lint/syntax_error_reporting/script.ts b/tests/specs/lint/syntax_error_reporting/script.ts new file mode 100644 index 000000000..4458a11ae --- /dev/null +++ b/tests/specs/lint/syntax_error_reporting/script.ts @@ -0,0 +1 @@ +const foo = 'bar |