Skip to content

Commit 7188b60

Browse files
authored
fix: error on merge conflict marker (#600)
1 parent 52d2c91 commit 7188b60

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

src/swc.rs

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ pub fn ensure_no_specific_syntax_errors(parsed_source: &ParsedSource) -> Result<
7575
SyntaxError::ExpectedSemiForExprStmt { .. } |
7676
SyntaxError::ExpectedUnicodeEscape |
7777
// unexpected token
78-
SyntaxError::Unexpected { .. }
78+
SyntaxError::Unexpected { .. } |
79+
// Merge conflict marker
80+
SyntaxError::TS1185
7981
)
8082
})
8183
.collect::<Vec<_>>();
@@ -225,6 +227,35 @@ mod tests {
225227
);
226228
}
227229

230+
#[test]
231+
fn it_should_error_for_merge_conflict_marker() {
232+
run_non_fatal_diagnostic_test(
233+
"./test.ts",
234+
r#"class Test {
235+
<<<<<<< HEAD
236+
v = 1;
237+
=======
238+
v = 2;
239+
>>>>>>> Branch-a
240+
}
241+
"#,
242+
r#"Merge conflict marker encountered. at ./test.ts:2:1
243+
244+
<<<<<<< HEAD
245+
~~~~~~~
246+
247+
Merge conflict marker encountered. at ./test.ts:4:1
248+
249+
=======
250+
~~~~~~~
251+
252+
Merge conflict marker encountered. at ./test.ts:6:1
253+
254+
>>>>>>> Branch-a
255+
~~~~~~~"#,
256+
);
257+
}
258+
228259
fn run_non_fatal_diagnostic_test(file_path: &str, text: &str, expected: &str) {
229260
let file_path = PathBuf::from(file_path);
230261
assert_eq!(format!("{}", parse_swc_ast(&file_path, text).err().unwrap()), expected);

0 commit comments

Comments
 (0)