Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prefer-string-replace-all: Ignore regex with pipe #1962

Merged
merged 3 commits into from Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion rules/prefer-string-replace-all.js
Expand Up @@ -19,7 +19,7 @@ const isRegexWithGlobalFlag = node =>

function isLiteralCharactersOnly(node) {
const searchPattern = node.regex.pattern;
return !/[$()*+.?[\\\]^{}]/.test(searchPattern.replace(/\\[$()*+.?[\\\]^{}]/g, ''));
return !/[$()*+.?[\\\]^{}|]/.test(searchPattern.replace(/\\[$()*+.?[\\\]^{}|]/g, ''));
}

function removeEscapeCharacters(regexString) {
Expand Down
1 change: 1 addition & 0 deletions test/prefer-string-replace-all.mjs
Expand Up @@ -14,6 +14,7 @@ test({
'foo.replace(/[a]/g, bar)',
'foo.replace(/a?/g, bar)',
'foo.replace(/.*/g, bar)',
'foo.replace(/a|b/g, bar)',
hampuskraft marked this conversation as resolved.
Show resolved Hide resolved
'foo.replace(/\\W/g, bar)',
'foo.replace(/\\u{61}/g, bar)',
'foo.replace(/\\u{61}/gu, bar)',
Expand Down