Skip to content

Latest commit

 

History

History
961 lines (709 loc) · 22.1 KB

prefer-regexp-test.mjs.md

File metadata and controls

961 lines (709 loc) · 22.1 KB

Snapshot report for test/prefer-regexp-test.mjs

The actual snapshot is saved in prefer-regexp-test.mjs.snap.

Generated by AVA.

Invalid #1

  1 | const re = /a/; const bar = !foo.match(re)

Output

`␊
  1 | const re = /a/; const bar = !re.test(foo)␊
`

Error 1/1

`␊
> 1 | const re = /a/; const bar = !foo.match(re)␊
    |                              ^^^^^^^^^^^^^ Prefer \`RegExp#test(…)\` over \`String#match(…)\`.␊
`

Invalid #2

  1 | const re = /a/; const bar = Boolean(foo.match(re))

Output

`␊
  1 | const re = /a/; const bar = Boolean(re.test(foo))␊
`

Error 1/1

`␊
> 1 | const re = /a/; const bar = Boolean(foo.match(re))␊
    |                                     ^^^^^^^^^^^^^ Prefer \`RegExp#test(…)\` over \`String#match(…)\`.␊
`

Invalid #3

  1 | const re = /a/; if (foo.match(re)) {}

Output

`␊
  1 | const re = /a/; if (re.test(foo)) {}␊
`

Error 1/1

`␊
> 1 | const re = /a/; if (foo.match(re)) {}␊
    |                     ^^^^^^^^^^^^^ Prefer \`RegExp#test(…)\` over \`String#match(…)\`.␊
`

Invalid #4

  1 | const re = /a/; const bar = foo.match(re) ? 1 : 2

Output

`␊
  1 | const re = /a/; const bar = re.test(foo) ? 1 : 2␊
`

Error 1/1

`␊
> 1 | const re = /a/; const bar = foo.match(re) ? 1 : 2␊
    |                             ^^^^^^^^^^^^^ Prefer \`RegExp#test(…)\` over \`String#match(…)\`.␊
`

Invalid #5

  1 | const re = /a/; while (foo.match(re)) foo = foo.slice(1);

Output

`␊
  1 | const re = /a/; while (re.test(foo)) foo = foo.slice(1);␊
`

Error 1/1

`␊
> 1 | const re = /a/; while (foo.match(re)) foo = foo.slice(1);␊
    |                        ^^^^^^^^^^^^^ Prefer \`RegExp#test(…)\` over \`String#match(…)\`.␊
`

Invalid #6

  1 | const re = /a/; do {foo = foo.slice(1)} while (foo.match(re));

Output

`␊
  1 | const re = /a/; do {foo = foo.slice(1)} while (re.test(foo));␊
`

Error 1/1

`␊
> 1 | const re = /a/; do {foo = foo.slice(1)} while (foo.match(re));␊
    |                                                ^^^^^^^^^^^^^ Prefer \`RegExp#test(…)\` over \`String#match(…)\`.␊
`

Invalid #7

  1 | const re = /a/; for (; foo.match(re); ) foo = foo.slice(1);

Output

`␊
  1 | const re = /a/; for (; re.test(foo); ) foo = foo.slice(1);␊
`

Error 1/1

`␊
> 1 | const re = /a/; for (; foo.match(re); ) foo = foo.slice(1);␊
    |                        ^^^^^^^^^^^^^ Prefer \`RegExp#test(…)\` over \`String#match(…)\`.␊
`

Invalid #8

  1 | const re = /a/; const bar = !re.exec(foo)

Output

`␊
  1 | const re = /a/; const bar = !re.test(foo)␊
`

Error 1/1

`␊
> 1 | const re = /a/; const bar = !re.exec(foo)␊
    |                                 ^^^^ Prefer \`.test(…)\` over \`.exec(…)\`.␊
`

Invalid #9

  1 | const re = /a/; const bar = Boolean(re.exec(foo))

Output

`␊
  1 | const re = /a/; const bar = Boolean(re.test(foo))␊
`

Error 1/1

`␊
> 1 | const re = /a/; const bar = Boolean(re.exec(foo))␊
    |                                        ^^^^ Prefer \`.test(…)\` over \`.exec(…)\`.␊
`

Invalid #10

  1 | const re = /a/; if (re.exec(foo)) {}

Output

`␊
  1 | const re = /a/; if (re.test(foo)) {}␊
`

Error 1/1

`␊
> 1 | const re = /a/; if (re.exec(foo)) {}␊
    |                        ^^^^ Prefer \`.test(…)\` over \`.exec(…)\`.␊
`

Invalid #11

  1 | const re = /a/; const bar = re.exec(foo) ? 1 : 2

Output

`␊
  1 | const re = /a/; const bar = re.test(foo) ? 1 : 2␊
`

Error 1/1

`␊
> 1 | const re = /a/; const bar = re.exec(foo) ? 1 : 2␊
    |                                ^^^^ Prefer \`.test(…)\` over \`.exec(…)\`.␊
`

Invalid #12

  1 | const re = /a/; while (re.exec(foo)) foo = foo.slice(1);

Output

`␊
  1 | const re = /a/; while (re.test(foo)) foo = foo.slice(1);␊
`

Error 1/1

`␊
> 1 | const re = /a/; while (re.exec(foo)) foo = foo.slice(1);␊
    |                           ^^^^ Prefer \`.test(…)\` over \`.exec(…)\`.␊
`

Invalid #13

  1 | const re = /a/; do {foo = foo.slice(1)} while (re.exec(foo));

Output

`␊
  1 | const re = /a/; do {foo = foo.slice(1)} while (re.test(foo));␊
`

Error 1/1

`␊
> 1 | const re = /a/; do {foo = foo.slice(1)} while (re.exec(foo));␊
    |                                                   ^^^^ Prefer \`.test(…)\` over \`.exec(…)\`.␊
`

Invalid #14

  1 | const re = /a/; for (; re.exec(foo); ) foo = foo.slice(1);

Output

`␊
  1 | const re = /a/; for (; re.test(foo); ) foo = foo.slice(1);␊
`

Error 1/1

`␊
> 1 | const re = /a/; for (; re.exec(foo); ) foo = foo.slice(1);␊
    |                           ^^^^ Prefer \`.test(…)\` over \`.exec(…)\`.␊
`

Invalid #15

  1 | const re = /a/; if ((0, foo).match(re)) {}

Output

`␊
  1 | const re = /a/; if ((re).test((0, foo))) {}␊
`

Error 1/1

`␊
> 1 | const re = /a/; if ((0, foo).match(re)) {}␊
    |                     ^^^^^^^^^^^^^^^^^^ Prefer \`RegExp#test(…)\` over \`String#match(…)\`.␊
`

Invalid #16

  1 | const re = /a/; if ((0, foo).match((re))) {}

Output

`␊
  1 | const re = /a/; if ((re).test((0, foo))) {}␊
`

Error 1/1

`␊
> 1 | const re = /a/; if ((0, foo).match((re))) {}␊
    |                     ^^^^^^^^^^^^^^^^^^^^ Prefer \`RegExp#test(…)\` over \`String#match(…)\`.␊
`

Invalid #17

  1 | const re = /a/; if ((foo).match(re)) {}

Output

`␊
  1 | const re = /a/; if ((re).test(foo)) {}␊
`

Error 1/1

`␊
> 1 | const re = /a/; if ((foo).match(re)) {}␊
    |                     ^^^^^^^^^^^^^^^ Prefer \`RegExp#test(…)\` over \`String#match(…)\`.␊
`

Invalid #18

  1 | const re = /a/; if ((foo).match((re))) {}

Output

`␊
  1 | const re = /a/; if ((re).test((foo))) {}␊
`

Error 1/1

`␊
> 1 | const re = /a/; if ((foo).match((re))) {}␊
    |                     ^^^^^^^^^^^^^^^^^ Prefer \`RegExp#test(…)\` over \`String#match(…)\`.␊
`

Invalid #19

  1 | if (foo.match(/re/)) {}

Output

`␊
  1 | if (/re/.test(foo)) {}␊
`

Error 1/1

`␊
> 1 | if (foo.match(/re/)) {}␊
    |     ^^^^^^^^^^^^^^^ Prefer \`RegExp#test(…)\` over \`String#match(…)\`.␊
`

Invalid #20

  1 | const re = /a/; if (foo.match(re)) {}

Output

`␊
  1 | const re = /a/; if (re.test(foo)) {}␊
`

Error 1/1

`␊
> 1 | const re = /a/; if (foo.match(re)) {}␊
    |                     ^^^^^^^^^^^^^ Prefer \`RegExp#test(…)\` over \`String#match(…)\`.␊
`

Invalid #21

  1 | const bar = {bar: /a/}; if (foo.match(bar.baz)) {}

Error 1/1

`␊
> 1 | const bar = {bar: /a/}; if (foo.match(bar.baz)) {}␊
    |                             ^^^^^^^^^^^^^^^^^^ Prefer \`RegExp#test(…)\` over \`String#match(…)\`.␊

--------------------------------------------------------------------------------␊
Suggestion 1/1: Switch to \`RegExp#test(…)\`.␊
  1 | const bar = {bar: /a/}; if (bar.baz.test(foo)) {}␊
`

Invalid #22

  1 | if (foo.match(bar.baz())) {}

Error 1/1

`␊
> 1 | if (foo.match(bar.baz())) {}␊
    |     ^^^^^^^^^^^^^^^^^^^^ Prefer \`RegExp#test(…)\` over \`String#match(…)\`.␊

--------------------------------------------------------------------------------␊
Suggestion 1/1: Switch to \`RegExp#test(…)\`.␊
  1 | if (bar.baz().test(foo)) {}␊
`

Invalid #23

  1 | if (foo.match(new RegExp("re", "g"))) {}

Output

`␊
  1 | if (new RegExp("re", "g").test(foo)) {}␊
`

Error 1/1

`␊
> 1 | if (foo.match(new RegExp("re", "g"))) {}␊
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer \`RegExp#test(…)\` over \`String#match(…)\`.␊
`

Invalid #24

  1 | if (foo.match(new SomeRegExp())) {}

Error 1/1

`␊
> 1 | if (foo.match(new SomeRegExp())) {}␊
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer \`RegExp#test(…)\` over \`String#match(…)\`.␊

--------------------------------------------------------------------------------␊
Suggestion 1/1: Switch to \`RegExp#test(…)\`.␊
  1 | if (new SomeRegExp().test(foo)) {}␊
`

Invalid #25

  1 | if (foo.match(new SomeRegExp)) {}

Error 1/1

`␊
> 1 | if (foo.match(new SomeRegExp)) {}␊
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer \`RegExp#test(…)\` over \`String#match(…)\`.␊

--------------------------------------------------------------------------------␊
Suggestion 1/1: Switch to \`RegExp#test(…)\`.␊
  1 | if ((new SomeRegExp).test(foo)) {}␊
`

Invalid #26

  1 | if (foo.match(bar?.baz)) {}

Error 1/1

`␊
> 1 | if (foo.match(bar?.baz)) {}␊
    |     ^^^^^^^^^^^^^^^^^^^ Prefer \`RegExp#test(…)\` over \`String#match(…)\`.␊

--------------------------------------------------------------------------------␊
Suggestion 1/1: Switch to \`RegExp#test(…)\`.␊
  1 | if (bar?.baz.test(foo)) {}␊
`

Invalid #27

  1 | if (foo.match(bar?.baz())) {}

Error 1/1

`␊
> 1 | if (foo.match(bar?.baz())) {}␊
    |     ^^^^^^^^^^^^^^^^^^^^^ Prefer \`RegExp#test(…)\` over \`String#match(…)\`.␊

--------------------------------------------------------------------------------␊
Suggestion 1/1: Switch to \`RegExp#test(…)\`.␊
  1 | if (bar?.baz().test(foo)) {}␊
`

Invalid #28

  1 | if (foo.match(bar || baz)) {}

Error 1/1

`␊
> 1 | if (foo.match(bar || baz)) {}␊
    |     ^^^^^^^^^^^^^^^^^^^^^ Prefer \`RegExp#test(…)\` over \`String#match(…)\`.␊

--------------------------------------------------------------------------------␊
Suggestion 1/1: Switch to \`RegExp#test(…)\`.␊
  1 | if ((bar || baz).test(foo)) {}␊
`

Invalid #29

  1 | async function a() {
  2 | 	if (foo.match(await bar())) {}
  3 | }

Error 1/1

`␊
  1 | async function a() {␊
> 2 | 	if (foo.match(await bar())) {}␊
    | 	    ^^^^^^^^^^^^^^^^^^^^^^ Prefer \`RegExp#test(…)\` over \`String#match(…)\`.␊
  3 | }␊

--------------------------------------------------------------------------------␊
Suggestion 1/1: Switch to \`RegExp#test(…)\`.␊
  1 | async function a() {␊
  2 | 	if ((await bar()).test(foo)) {}␊
  3 | }␊
`

Invalid #30

  1 | if ((foo).match(/re/)) {}

Output

`␊
  1 | if ((/re/).test(foo)) {}␊
`

Error 1/1

`␊
> 1 | if ((foo).match(/re/)) {}␊
    |     ^^^^^^^^^^^^^^^^^ Prefer \`RegExp#test(…)\` over \`String#match(…)\`.␊
`

Invalid #31

  1 | if ((foo).match(new SomeRegExp)) {}

Error 1/1

`␊
> 1 | if ((foo).match(new SomeRegExp)) {}␊
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer \`RegExp#test(…)\` over \`String#match(…)\`.␊

--------------------------------------------------------------------------------␊
Suggestion 1/1: Switch to \`RegExp#test(…)\`.␊
  1 | if ((new SomeRegExp).test(foo)) {}␊
`

Invalid #32

  1 | if ((foo).match(bar?.baz)) {}

Error 1/1

`␊
> 1 | if ((foo).match(bar?.baz)) {}␊
    |     ^^^^^^^^^^^^^^^^^^^^^ Prefer \`RegExp#test(…)\` over \`String#match(…)\`.␊

--------------------------------------------------------------------------------␊
Suggestion 1/1: Switch to \`RegExp#test(…)\`.␊
  1 | if ((bar?.baz).test(foo)) {}␊
`

Invalid #33

  1 | if ((foo).match(bar?.baz())) {}

Error 1/1

`␊
> 1 | if ((foo).match(bar?.baz())) {}␊
    |     ^^^^^^^^^^^^^^^^^^^^^^^ Prefer \`RegExp#test(…)\` over \`String#match(…)\`.␊

--------------------------------------------------------------------------------␊
Suggestion 1/1: Switch to \`RegExp#test(…)\`.␊
  1 | if ((bar?.baz()).test(foo)) {}␊
`

Invalid #34

  1 | const bar = false; const baz = /a/; if ((foo).match(bar || baz)) {}

Output

`␊
  1 | const bar = false; const baz = /a/; if ((bar || baz).test(foo)) {}␊
`

Error 1/1

`␊
> 1 | const bar = false; const baz = /a/; if ((foo).match(bar || baz)) {}␊
    |                                         ^^^^^^^^^^^^^^^^^^^^^^^ Prefer \`RegExp#test(…)\` over \`String#match(…)\`.␊
`

Invalid #35

  1 | async function a() {
  2 | 	if ((foo).match(await bar())) {}
  3 | }

Error 1/1

`␊
  1 | async function a() {␊
> 2 | 	if ((foo).match(await bar())) {}␊
    | 	    ^^^^^^^^^^^^^^^^^^^^^^^^ Prefer \`RegExp#test(…)\` over \`String#match(…)\`.␊
  3 | }␊

--------------------------------------------------------------------------------␊
Suggestion 1/1: Switch to \`RegExp#test(…)\`.␊
  1 | async function a() {␊
  2 | 	if ((await bar()).test(foo)) {}␊
  3 | }␊
`

Invalid #36

  1 | const re = [/a/]; if (foo.match([re][0])) {}

Error 1/1

`␊
> 1 | const re = [/a/]; if (foo.match([re][0])) {}␊
    |                       ^^^^^^^^^^^^^^^^^^ Prefer \`RegExp#test(…)\` over \`String#match(…)\`.␊

--------------------------------------------------------------------------------␊
Suggestion 1/1: Switch to \`RegExp#test(…)\`.␊
  1 | const re = [/a/]; if ([re][0].test(foo)) {}␊
`

Invalid #37

   1 | async function a() {
   2 | 	if (
   3 | 		/* 1 */ foo() /* 2 */
   4 | 			./* 3 */ match /* 4 */ (
   5 | 				/* 5 */ await /* 6 */ bar() /* 7 */
   6 | 				,
   7 | 				/* 8 */
   8 | 			)
   9 | 	) {}
  10 | }

Error 1/1

`␊
   1 | async function a() {␊
   2 | 	if (␊
>  3 | 		/* 1 */ foo() /* 2 */␊
     | 		        ^^^^^^^^^^^^^␊
>  4 | 			./* 3 */ match /* 4 */ (␊
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^␊
>  5 | 				/* 5 */ await /* 6 */ bar() /* 7 */␊
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^␊
>  6 | 				,␊
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^␊
>  7 | 				/* 8 */␊
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^␊
>  8 | 			)␊
     | ^^^^^ Prefer \`RegExp#test(…)\` over \`String#match(…)\`.␊
   9 | 	) {}␊
  10 | }␊

--------------------------------------------------------------------------------␊
Suggestion 1/1: Switch to \`RegExp#test(…)\`.␊
   1 | async function a() {␊
   2 | 	if (␊
   3 | 		/* 1 */ (await /* 6 */ bar()) /* 2 */␊
   4 | 			./* 3 */ test /* 4 */ (␊
   5 | 				/* 5 */ foo() /* 7 */␊
   6 | 				,␊
   7 | 				/* 8 */␊
   8 | 			)␊
   9 | 	) {}␊
  10 | }␊
`

Invalid #38

  1 | const string = '[.!?]\s*$';
  2 | if (foo.match(string)) {
  3 | }

Error 1/1

`␊
  1 | const string = '[.!?]\\s*$';␊
> 2 | if (foo.match(string)) {␊
    |     ^^^^^^^^^^^^^^^^^ Prefer \`RegExp#test(…)\` over \`String#match(…)\`.␊
  3 | }␊

--------------------------------------------------------------------------------␊
Suggestion 1/1: Switch to \`RegExp#test(…)\`.␊
  1 | const string = '[.!?]\\s*$';␊
  2 | if (string.test(foo)) {␊
  3 | }␊
`

Invalid #39

  1 | const regex = new RegExp('[.!?]\s*$');
  2 | if (foo.match(regex)) {}

Output

`␊
  1 | const regex = new RegExp('[.!?]\\s*$');␊
  2 | if (regex.test(foo)) {}␊
`

Error 1/1

`␊
  1 | const regex = new RegExp('[.!?]\\s*$');␊
> 2 | if (foo.match(regex)) {}␊
    |     ^^^^^^^^^^^^^^^^ Prefer \`RegExp#test(…)\` over \`String#match(…)\`.␊
`

Invalid #40

  1 | if (foo.match(unknown)) {}

Error 1/1

`␊
> 1 | if (foo.match(unknown)) {}␊
    |     ^^^^^^^^^^^^^^^^^^ Prefer \`RegExp#test(…)\` over \`String#match(…)\`.␊

--------------------------------------------------------------------------------␊
Suggestion 1/1: Switch to \`RegExp#test(…)\`.␊
  1 | if (unknown.test(foo)) {}␊
`

Invalid #41

  1 | if (foo.match(/a/g));

Output

`␊
  1 | if (/a/g.test(foo));␊
`

Error 1/1

`␊
> 1 | if (foo.match(/a/g));␊
    |     ^^^^^^^^^^^^^^^ Prefer \`RegExp#test(…)\` over \`String#match(…)\`.␊
`

Invalid #42

  1 | if (foo.match(/a/y));

Output

`␊
  1 | if (/a/y.test(foo));␊
`

Error 1/1

`␊
> 1 | if (foo.match(/a/y));␊
    |     ^^^^^^^^^^^^^^^ Prefer \`RegExp#test(…)\` over \`String#match(…)\`.␊
`

Invalid #43

  1 | if (foo.match(/a/gy));

Output

`␊
  1 | if (/a/gy.test(foo));␊
`

Error 1/1

`␊
> 1 | if (foo.match(/a/gy));␊
    |     ^^^^^^^^^^^^^^^^ Prefer \`RegExp#test(…)\` over \`String#match(…)\`.␊
`

Invalid #44

  1 | if (foo.match(/a/ig));

Output

`␊
  1 | if (/a/ig.test(foo));␊
`

Error 1/1

`␊
> 1 | if (foo.match(/a/ig));␊
    |     ^^^^^^^^^^^^^^^^ Prefer \`RegExp#test(…)\` over \`String#match(…)\`.␊
`

Invalid #45

  1 | if (foo.match(new RegExp("a", "g")));

Output

`␊
  1 | if (new RegExp("a", "g").test(foo));␊
`

Error 1/1

`␊
> 1 | if (foo.match(new RegExp("a", "g")));␊
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer \`RegExp#test(…)\` over \`String#match(…)\`.␊
`

Invalid #46

  1 | if (/a/g.exec(foo));

Output

`␊
  1 | if (/a/g.test(foo));␊
`

Error 1/1

`␊
> 1 | if (/a/g.exec(foo));␊
    |          ^^^^ Prefer \`.test(…)\` over \`.exec(…)\`.␊
`

Invalid #47

  1 | if (/a/y.exec(foo));

Output

`␊
  1 | if (/a/y.test(foo));␊
`

Error 1/1

`␊
> 1 | if (/a/y.exec(foo));␊
    |          ^^^^ Prefer \`.test(…)\` over \`.exec(…)\`.␊
`

Invalid #48

  1 | if (/a/gy.exec(foo));

Output

`␊
  1 | if (/a/gy.test(foo));␊
`

Error 1/1

`␊
> 1 | if (/a/gy.exec(foo));␊
    |           ^^^^ Prefer \`.test(…)\` over \`.exec(…)\`.␊
`

Invalid #49

  1 | if (/a/yi.exec(foo));

Output

`␊
  1 | if (/a/yi.test(foo));␊
`

Error 1/1

`␊
> 1 | if (/a/yi.exec(foo));␊
    |           ^^^^ Prefer \`.test(…)\` over \`.exec(…)\`.␊
`

Invalid #50

  1 | if (new RegExp("a", "g").exec(foo));

Output

`␊
  1 | if (new RegExp("a", "g").test(foo));␊
`

Error 1/1

`␊
> 1 | if (new RegExp("a", "g").exec(foo));␊
    |                          ^^^^ Prefer \`.test(…)\` over \`.exec(…)\`.␊
`

Invalid #51

  1 | if (new RegExp("a", "y").exec(foo));

Output

`␊
  1 | if (new RegExp("a", "y").test(foo));␊
`

Error 1/1

`␊
> 1 | if (new RegExp("a", "y").exec(foo));␊
    |                          ^^^^ Prefer \`.test(…)\` over \`.exec(…)\`.␊
`

Invalid #52

  1 | const regex = /weird/g;
  2 | if (foo.match(regex));

Error 1/1

`␊
  1 | const regex = /weird/g;␊
> 2 | if (foo.match(regex));␊
    |     ^^^^^^^^^^^^^^^^ Prefer \`RegExp#test(…)\` over \`String#match(…)\`.␊

--------------------------------------------------------------------------------␊
Suggestion 1/1: Switch to \`RegExp#test(…)\`.␊
  1 | const regex = /weird/g;␊
  2 | if (regex.test(foo));␊
`

Invalid #53

  1 | const regex = /weird/g;
  2 | if (regex.exec(foo));

Error 1/1

`␊
  1 | const regex = /weird/g;␊
> 2 | if (regex.exec(foo));␊
    |           ^^^^ Prefer \`.test(…)\` over \`.exec(…)\`.␊

--------------------------------------------------------------------------------␊
Suggestion 1/1: Switch to \`RegExp#test(…)\`.␊
  1 | const regex = /weird/g;␊
  2 | if (regex.test(foo));␊
`

Invalid #54

  1 | const regex = /weird/y;
  2 | if (regex.exec(foo));

Output

`␊
  1 | const regex = /weird/y;␊
  2 | if (regex.test(foo));␊
`

Error 1/1

`␊
  1 | const regex = /weird/y;␊
> 2 | if (regex.exec(foo));␊
    |           ^^^^ Prefer \`.test(…)\` over \`.exec(…)\`.␊
`

Invalid #55

  1 | const regex = /weird/gyi;
  2 | if (regex.exec(foo));

Error 1/1

`␊
  1 | const regex = /weird/gyi;␊
> 2 | if (regex.exec(foo));␊
    |           ^^^^ Prefer \`.test(…)\` over \`.exec(…)\`.␊

--------------------------------------------------------------------------------␊
Suggestion 1/1: Switch to \`RegExp#test(…)\`.␊
  1 | const regex = /weird/gyi;␊
  2 | if (regex.test(foo));␊
`

Invalid #56

  1 | let re = new RegExp('foo', 'g');
  2 | if(str.match(re));

Error 1/1

`␊
  1 | let re = new RegExp('foo', 'g');␊
> 2 | if(str.match(re));␊
    |    ^^^^^^^^^^^^^ Prefer \`RegExp#test(…)\` over \`String#match(…)\`.␊

--------------------------------------------------------------------------------␊
Suggestion 1/1: Switch to \`RegExp#test(…)\`.␊
  1 | let re = new RegExp('foo', 'g');␊
  2 | if(re.test(str));␊
`

Invalid #57

  1 | !/a/u.exec(foo)

Output

`␊
  1 | !/a/u.test(foo)␊
`

Error 1/1

`␊
> 1 | !/a/u.exec(foo)␊
    |       ^^^^ Prefer \`.test(…)\` over \`.exec(…)\`.␊
`

Invalid #58

  1 | !/a/v.exec(foo)

Output

`␊
  1 | !/a/v.test(foo)␊
`

Error 1/1

`␊
> 1 | !/a/v.exec(foo)␊
    |       ^^^^ Prefer \`.test(…)\` over \`.exec(…)\`.␊
`