sindresorhus/eslint-plugin-unicorn

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

Open

#1,441 建立於 2021年7月23日

在 GitHub 查看
 (4 留言) (3 反應) (0 負責人)JavaScript (5,022 star) (468 fork)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');

貢獻者指南