sindresorhus/eslint-plugin-unicorn
Enforce `.replaceAll()` over `.split().join()` in `prefer-string-replace-all` rule
Closed
#1,441 opened on Jul 23, 2021
enhancementhelp wanted
Repository metrics
- Stars
- (5,022 stars)
- PR merge metrics
- (Avg merge 1d 16h) (399 merged PRs in 30d)
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');