Show syntax errors on the playground (#12083)

## Summary

This PR updates the playground to show syntax errors.

(I forgot to update this and noticed it this morning.)

## Test Plan

Build the playground locally and preview it:

<img width="764" alt="Screenshot 2024-06-28 at 11 03 35"
src="1fd48d6c-ae41-4672-bf3c-32a61d9946ef">
This commit is contained in:
Dhruv Manilawala 2024-06-28 13:06:15 +05:30 committed by GitHub
parent 526efd398a
commit 9fec384d11
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 44 additions and 11 deletions

View file

@ -25,7 +25,7 @@ fn empty_config() {
"if (1, 2):\n pass",
r#"{}"#,
[ExpandedMessage {
code: Rule::IfTuple.noqa_code().to_string(),
code: Some(Rule::IfTuple.noqa_code().to_string()),
message: "If test is a tuple, which is always `True`".to_string(),
location: SourceLocation {
row: OneIndexed::from_zero_indexed(0),
@ -40,6 +40,27 @@ fn empty_config() {
);
}
#[wasm_bindgen_test]
fn syntax_error() {
check!(
"x =\ny = 1\n",
r#"{}"#,
[ExpandedMessage {
code: None,
message: "SyntaxError: Expected an expression".to_string(),
location: SourceLocation {
row: OneIndexed::from_zero_indexed(0),
column: OneIndexed::from_zero_indexed(3)
},
end_location: SourceLocation {
row: OneIndexed::from_zero_indexed(1),
column: OneIndexed::from_zero_indexed(0)
},
fix: None,
}]
);
}
#[wasm_bindgen_test]
fn partial_config() {
check!("if (1, 2):\n pass", r#"{"ignore": ["F"]}"#, []);