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:
parent
a45a40533e
commit
f0df54fc70
5 changed files with 29 additions and 1 deletions
|
@ -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",
|
||||||
|
|
|
@ -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,
|
||||||
|
|
5
tests/specs/lint/syntax_error_reporting/__test__.jsonc
Normal file
5
tests/specs/lint/syntax_error_reporting/__test__.jsonc
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"args": "lint script.ts",
|
||||||
|
"output": "lint.out",
|
||||||
|
"exitCode": 1
|
||||||
|
}
|
16
tests/specs/lint/syntax_error_reporting/lint.out
Normal file
16
tests/specs/lint/syntax_error_reporting/lint.out
Normal 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
|
1
tests/specs/lint/syntax_error_reporting/script.ts
Normal file
1
tests/specs/lint/syntax_error_reporting/script.ts
Normal file
|
@ -0,0 +1 @@
|
||||||
|
const foo = 'bar
|
Loading…
Reference in a new issue