Skip to content
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(fmt): should fail --check on parse error #14907

Merged
merged 2 commits into from
Jun 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions cli/tests/integration/fmt_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ itest!(fmt_check_ignore {
exit_code: 0,
});

itest!(fmt_check_parse_error {
args: "fmt --check fmt/parse_error/parse_error.ts",
output: "fmt/fmt_check_parse_error.out",
exit_code: 1,
});

itest!(fmt_stdin {
args: "fmt -",
input: Some("const a = 1\n"),
Expand Down
6 changes: 6 additions & 0 deletions cli/tests/testdata/fmt/fmt_check_parse_error.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Error checking: [WILDCARD]
Line 2, column 7: Expected '{', got '<eof>'

class Test
~~~~
error: Found 1 not formatted file in 1 file
2 changes: 2 additions & 0 deletions cli/tests/testdata/fmt/parse_error/parse_error.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// a file that purposefully will cause an error
class Test
1 change: 1 addition & 0 deletions cli/tools/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ async fn check_source_files(
incremental_cache.update_file(&file_path, &file_text);
}
Err(e) => {
not_formatted_files_count.fetch_add(1, Ordering::Relaxed);
let _g = output_lock.lock();
eprintln!("Error checking: {}", file_path.to_string_lossy());
eprintln!(" {}", e);
Expand Down
1 change: 1 addition & 0 deletions tools/lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ async function dlint() {
":!:cli/dts/**",
":!:cli/tests/testdata/encoding/**",
":!:cli/tests/testdata/error_syntax.js",
":!:cli/tests/testdata/fmt/**",
":!:cli/tests/testdata/lint/**",
":!:cli/tests/testdata/tsc/**",
":!:cli/tsc/*typescript.js",
Expand Down