From 1dca2f3d9a5b42976b6d1b2d5038f5a5b9e5467d Mon Sep 17 00:00:00 2001 From: Tim Allen Date: Wed, 24 Jun 2020 13:08:02 +1000 Subject: [PATCH] `prefer-starts-ends-with`: Fix pipe in regex (#783) Co-authored-by: fisker Cheung --- rules/prefer-starts-ends-with.js | 2 +- test/prefer-starts-ends-with.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) 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 = [ diff --git a/test/prefer-starts-ends-with.js b/test/prefer-starts-ends-with.js index 5b28a1c7c3..2a00e4c00e 100644 --- a/test/prefer-starts-ends-with.js +++ b/test/prefer-starts-ends-with.js @@ -26,7 +26,9 @@ const validRegex = [ /\^foo/, /^foo/i, /^foo/m, - /^foo/im + /^foo/im, + /^A|B/, + /A|B$/ ]; const invalidRegex = [