mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 02:39:12 +00:00
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:
parent
526efd398a
commit
9fec384d11
3 changed files with 44 additions and 11 deletions
|
@ -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"]}"#, []);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue