Rewrite `replaceAll` ⇒ `replace` when have regex pattern

JavaScript pattern

Replaces replaceAll with replace, when it uses a regex pattern.

The replaceAll string method may not be supported in all JavaScript versions and older browsers. It is advisable to use the replace() method with a regular expression as the first argument. For example, use mystring.replace(/bad/g, "good") instead of mystring.replaceAll("bad", "good")


Apply with the Grit CLI
grit apply replaceAll_to_replace

Transforms replaceAll to replace when have regex pattern

BEFORE
const str = 'Hello String';
// GOOD: replaceAll
const str1 = old_str1.replaceAll(str, '    ');
// GOOD: replaceAll
const str1 = old_str1.replaceAll(hello, '    ');
// BAD: replaceAll
const str2 = old_str2.replaceAll('\t', '    ');
// GOOD: replaceAll
const str3 = old_str3.replace('\t', '    ');
// BAD: replaceAll
const mystr = mystring.replaceAll('bad', 'good');
AFTER
const str = 'Hello String';
// GOOD: replaceAll
const str1 = old_str1.replaceAll(str, '    ');
// GOOD: replaceAll
const str1 = old_str1.replaceAll(hello, '    ');
// BAD: replaceAll
const str2 = old_str2.replace(/\t/g, '    ');
// GOOD: replaceAll
const str3 = old_str3.replace('\t', '    ');
// BAD: replaceAll
const mystr = mystring.replace(/bad/g, "good")