Skip to content

Commit

Permalink
test(linter): add regression test for #5227
Browse files Browse the repository at this point in the history
  • Loading branch information
camchenry committed Sep 22, 2024
1 parent 9eb678f commit 5043e22
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions crates/oxc_linter/src/rules/eslint/no_useless_escape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@ fn test() {
r"/[\&&&\&]/v", // { "ecmaVersion": 2024 },
r"/[[\-]\-]/v", // { "ecmaVersion": 2024 },
r"/[\^]/v", // { "ecmaVersion": 2024 }
r"/[\s\-(]/", // https://github.com/oxc-project/oxc/issues/5227
];

let fail = vec![
Expand Down Expand Up @@ -692,6 +693,12 @@ fn test() {
("let foo = '\\ ';", "let foo = ' ';", None),
("let foo = /\\ /;", "let foo = / /;", None),
("var foo = `\\$\\{{${foo}`;", "var foo = `$\\{{${foo}`;", None),
(
// https://github.com/oxc-project/oxc/issues/5227
r"const regex = /(https?:\/\/github\.com\/(([^\s]+)\/([^\s]+))\/([^\s]+\/)?(issues|pull)\/([0-9]+))|(([^\s]+)\/([^\s]+))?#([1-9][0-9]*)($|[\s\:\;\-\(\=])/;",
r"const regex = /(https?:\/\/github\.com\/(([^\s]+)\/([^\s]+))\/([^\s]+\/)?(issues|pull)\/([0-9]+))|(([^\s]+)\/([^\s]+))?#([1-9][0-9]*)($|[\s:;\-(=])/;",
None,
),
];

Tester::new(NoUselessEscape::NAME, pass, fail).expect_fix(fix).test_and_snapshot();
Expand Down

0 comments on commit 5043e22

Please sign in to comment.