sindresorhus/eslint-plugin-unicorn

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

已关闭

#1,441 创建于 2021年7月23日

 (4 条评论) (3 个反应) (0 位负责人)JavaScript (468 个派生)user submission
enhancementhelp wanted

仓库指标

星标
 (5,022 个星标)
PR 合并指标
 (平均合并 1天 16小时) (30 天内合并 399 个 PR)

描述

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

贡献者指南