From f9331bbe9521bb7bc99e9f3177c2a751f30735f2 Mon Sep 17 00:00:00 2001 From: Tim Allen Date: Wed, 24 Jun 2020 12:30:19 +1000 Subject: [PATCH 1/3] Failing test to show issue with /A|B/. --- test/prefer-starts-ends-with.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/prefer-starts-ends-with.js b/test/prefer-starts-ends-with.js index 5b28a1c7c3..aa3984ca29 100644 --- a/test/prefer-starts-ends-with.js +++ b/test/prefer-starts-ends-with.js @@ -26,7 +26,8 @@ const validRegex = [ /\^foo/, /^foo/i, /^foo/m, - /^foo/im + /^foo/im, + /^A|B/ ]; const invalidRegex = [ From b7dbf4f4164dfafc5f4b86c7b5f7efdc98538279 Mon Sep 17 00:00:00 2001 From: Tim Allen Date: Wed, 24 Jun 2020 12:31:35 +1000 Subject: [PATCH 2/3] Include | in invalid regex chars. --- rules/prefer-starts-ends-with.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules/prefer-starts-ends-with.js b/rules/prefer-starts-ends-with.js index 209ba42a5e..4105c3e113 100644 --- a/rules/prefer-starts-ends-with.js +++ b/rules/prefer-starts-ends-with.js @@ -11,7 +11,7 @@ const doesNotContain = (string, characters) => characters.every(character => !st const isSimpleString = string => doesNotContain( string, - ['^', '$', '+', '[', '{', '(', '\\', '.', '?', '*'] + ['^', '$', '+', '[', '{', '(', '\\', '.', '?', '*', '|'] ); const regexTestSelector = [ From f3eafb79687314d4df3b5a24e5c56915b065fc40 Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Wed, 24 Jun 2020 10:47:49 +0800 Subject: [PATCH 3/3] Update test/prefer-starts-ends-with.js --- test/prefer-starts-ends-with.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/prefer-starts-ends-with.js b/test/prefer-starts-ends-with.js index aa3984ca29..2a00e4c00e 100644 --- a/test/prefer-starts-ends-with.js +++ b/test/prefer-starts-ends-with.js @@ -27,7 +27,8 @@ const validRegex = [ /^foo/i, /^foo/m, /^foo/im, - /^A|B/ + /^A|B/, + /A|B$/ ]; const invalidRegex = [