sindresorhus/eslint-plugin-unicorn

Enforce `.replaceAll()` over `.split().join()` in `prefer-string-replace-all` rule

Open

#1,441 opened on Jul 23, 2021

View on GitHub
聽(4 comments)聽(3 reactions)聽(0 assignees)JavaScript聽(5,022 stars)聽(468 forks)user submission
enhancementhelp wanted

Description

Fail

foo.split('a').join('b');

Pass

foo.replaceAll('a', 'b');
// Not sure about this, maybe add `g` flag, result the same?
foo.split(/a+/).join('b');
// Different with foo.replaceAll('', 'b');
foo.split('').join('b');

Contributor guide

Enforce `.replaceAll()` over `.split().join()` in `prefer-string-replace-all` rule 路 sindresorhus/eslint-plugin-unicorn#1441 | Good First Issue