summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHasanAlrimawi <141642411+HasanAlrimawi@users.noreply.github.com>2024-07-24 00:17:17 +0300
committerGitHub <noreply@github.com>2024-07-23 21:17:17 +0000
commitf0df54fc70ec1781a3ffec232fefc38cabf39c37 (patch)
tree40cd7281c1f0a752e5f459daa148992517e614f2
parenta45a40533eb25c5a12df98189338320f8aa6dcc4 (diff)
fix: enable the reporting of parsing related problems when running deno lint (#24332)
-rw-r--r--.dprint.json1
-rw-r--r--cli/tools/lint/mod.rs7
-rw-r--r--tests/specs/lint/syntax_error_reporting/__test__.jsonc5
-rw-r--r--tests/specs/lint/syntax_error_reporting/lint.out16
-rw-r--r--tests/specs/lint/syntax_error_reporting/script.ts1
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