sindresorhus/eslint-plugin-unicorn

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

Open

#1,441 opened on 2021年7月23日

GitHub で見る
 (4 comments) (3 reactions) (0 assignees)JavaScript (5,022 stars) (468 forks)user submission
enhancementhelp wanted

説明

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');

コントリビューターガイド