fix: remove escapes in prefer regexp test test cases (#1645)

This commit is contained in:
Cameron 2023-12-10 09:37:41 +00:00 committed by GitHub
parent 9bea2780d9
commit a09060be33
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 88 deletions

View file

@ -202,7 +202,7 @@ fn test() {
r"const re = /a/; if (foo.match(re)) {}",
r"const bar = {bar: /a/}; if (foo.match(bar.baz)) {}",
r"if (foo.match(bar.baz())) {}",
r#"if (foo.match(new RegExp(\"re\", \"g\"))) {}"#,
r#"if (foo.match(new RegExp("re", "g"))) {}"#,
r"if (foo.match(new SomeRegExp())) {}",
r"if (foo.match(new SomeRegExp)) {}",
r"if (foo.match(bar?.baz)) {}",
@ -219,13 +219,13 @@ fn test() {
r"if (foo.match(/a/y));",
r"if (foo.match(/a/gy));",
r"if (foo.match(/a/ig));",
r#"if (foo.match(new RegExp(\"a\", \"g\")));"#,
r#"if (foo.match(new RegExp("a", "g")));"#,
r"if (/a/g.exec(foo));",
r"if (/a/y.exec(foo));",
r"if (/a/gy.exec(foo));",
r"if (/a/yi.exec(foo));",
r#"if (new RegExp(\"a\", \"g\").exec(foo));"#,
r#"if (new RegExp(\"a\", \"y\").exec(foo));"#,
r#"if (new RegExp("a", "g").exec(foo));"#,
r#"if (new RegExp("a", "y").exec(foo));"#,
r"!/a/u.exec(foo)",
r"!/a/v.exec(foo)",
];

View file

@ -156,29 +156,12 @@ expression: prefer_regexp_test
╰────
help: RegExp#test() exclusively returns a boolean and therefore is more efficient
× Invalid Unicode escape sequence
⚠ eslint-plugin-unicorn(prefer-regexp-test): Prefer RegExp#test() over String#match() and RegExp#exec()
╭─[prefer_regexp_test.tsx:1:1]
1 │ if (foo.match(new RegExp(\"re\", \"g\"))) {}
· ─
╰────
× Invalid Unicode escape sequence
╭─[prefer_regexp_test.tsx:1:1]
1 │ if (foo.match(new RegExp(\"re\", \"g\"))) {}
· ─
╰────
× Invalid Unicode escape sequence
╭─[prefer_regexp_test.tsx:1:1]
1 │ if (foo.match(new RegExp(\"re\", \"g\"))) {}
· ─
╰────
× Invalid Unicode escape sequence
╭─[prefer_regexp_test.tsx:1:1]
1 │ if (foo.match(new RegExp(\"re\", \"g\"))) {}
· ─
1 │ if (foo.match(new RegExp("re", "g"))) {}
· ─────
╰────
help: RegExp#test() exclusively returns a boolean and therefore is more efficient
⚠ eslint-plugin-unicorn(prefer-regexp-test): Prefer RegExp#test() over String#match() and RegExp#exec()
╭─[prefer_regexp_test.tsx:1:1]
@ -292,29 +275,12 @@ expression: prefer_regexp_test
╰────
help: RegExp#test() exclusively returns a boolean and therefore is more efficient
× Invalid Unicode escape sequence
⚠ eslint-plugin-unicorn(prefer-regexp-test): Prefer RegExp#test() over String#match() and RegExp#exec()
╭─[prefer_regexp_test.tsx:1:1]
1 │ if (foo.match(new RegExp(\"a\", \"g\")));
· ─
╰────
× Invalid Unicode escape sequence
╭─[prefer_regexp_test.tsx:1:1]
1 │ if (foo.match(new RegExp(\"a\", \"g\")));
· ─
╰────
× Invalid Unicode escape sequence
╭─[prefer_regexp_test.tsx:1:1]
1 │ if (foo.match(new RegExp(\"a\", \"g\")));
· ─
╰────
× Invalid Unicode escape sequence
╭─[prefer_regexp_test.tsx:1:1]
1 │ if (foo.match(new RegExp(\"a\", \"g\")));
· ─
1 │ if (foo.match(new RegExp("a", "g")));
· ─────
╰────
help: RegExp#test() exclusively returns a boolean and therefore is more efficient
⚠ eslint-plugin-unicorn(prefer-regexp-test): Prefer RegExp#test() over String#match() and RegExp#exec()
╭─[prefer_regexp_test.tsx:1:1]
@ -344,53 +310,19 @@ expression: prefer_regexp_test
╰────
help: RegExp#test() exclusively returns a boolean and therefore is more efficient
× Invalid Unicode escape sequence
⚠ eslint-plugin-unicorn(prefer-regexp-test): Prefer RegExp#test() over String#match() and RegExp#exec()
╭─[prefer_regexp_test.tsx:1:1]
1 │ if (new RegExp(\"a\", \"g\").exec(foo));
· ─
1 │ if (new RegExp("a", "g").exec(foo));
· ───
╰────
help: RegExp#test() exclusively returns a boolean and therefore is more efficient
× Invalid Unicode escape sequence
⚠ eslint-plugin-unicorn(prefer-regexp-test): Prefer RegExp#test() over String#match() and RegExp#exec()
╭─[prefer_regexp_test.tsx:1:1]
1 │ if (new RegExp(\"a\", \"g\").exec(foo));
· ─
╰────
× Invalid Unicode escape sequence
╭─[prefer_regexp_test.tsx:1:1]
1 │ if (new RegExp(\"a\", \"g\").exec(foo));
· ─
╰────
× Invalid Unicode escape sequence
╭─[prefer_regexp_test.tsx:1:1]
1 │ if (new RegExp(\"a\", \"g\").exec(foo));
· ─
╰────
× Invalid Unicode escape sequence
╭─[prefer_regexp_test.tsx:1:1]
1 │ if (new RegExp(\"a\", \"y\").exec(foo));
· ─
╰────
× Invalid Unicode escape sequence
╭─[prefer_regexp_test.tsx:1:1]
1 │ if (new RegExp(\"a\", \"y\").exec(foo));
· ─
╰────
× Invalid Unicode escape sequence
╭─[prefer_regexp_test.tsx:1:1]
1 │ if (new RegExp(\"a\", \"y\").exec(foo));
· ─
╰────
× Invalid Unicode escape sequence
╭─[prefer_regexp_test.tsx:1:1]
1 │ if (new RegExp(\"a\", \"y\").exec(foo));
· ─
1 │ if (new RegExp("a", "y").exec(foo));
· ────
╰────
help: RegExp#test() exclusively returns a boolean and therefore is more efficient
⚠ eslint-plugin-unicorn(prefer-regexp-test): Prefer RegExp#test() over String#match() and RegExp#exec()
╭─[prefer_regexp_test.tsx:1:1]