prefer-string-replace-all Prefer String.replaceAll when every occurrence is replaced A global replacement or split-and-join chain expresses replacement of every occurrence indirectly. Instead, you SHOULD use String.replaceAll to state that operation directly. Splitting on an empty string has different behavior and is left unchanged. - Category: style - Level: warning - Fix: automatic - Scope: module Reported function redact(text: string): string { return text.replace(/secret/g, "***"); } Accepted function redact(text: string): string { return text.replaceAll(/secret/g, "***"); } Prior art - eslint-plugin-unicorn ยท prefer-string-replace-all language/linter/src/rules/style/preferstringreplaceall.rs:8