Skip to content

Remove obsolete rule javascript.lang.correctness.no-replaceall#3998

Open
munzzyy wants to merge 1 commit into
semgrep:developfrom
munzzyy:remove-no-replaceall
Open

Remove obsolete rule javascript.lang.correctness.no-replaceall#3998
munzzyy wants to merge 1 commit into
semgrep:developfrom
munzzyy:remove-no-replaceall

Conversation

@munzzyy

@munzzyy munzzyy commented Jul 10, 2026

Copy link
Copy Markdown

Link to an issue, if relevant

Fixes #3984

Why remove this rule

javascript.lang.correctness.no-replaceall warns that String.prototype.replaceAll "is not supported in all versions of javascript" and suggests rewriting to replace() with a regex. That was fair when the rule landed in October 2020 (#887), but replaceAll is ES2021 and has been Baseline widely available since August 2020: Chrome 85, Firefox 77, Safari 13.1, Node 15 (MDN). The rule's only reference is a three.js forum thread from 2020. At this point every match is a false positive on valid code, filed under correctness.

The suggested rewrite is also a small footgun. The pattern only matches string-literal first arguments, and mechanically converting something like s.replaceAll(".", "-") to s.replace(/./g, "-") changes the meaning unless you remember to escape regex metacharacters. So the rule nudges people from the safer construct toward the riskier one.

If you'd rather keep coverage for legacy-browser targets, the alternative would be a rewritten message under a compat/portability category instead of correctness. Removal seemed to match precedent like #3496, so that's what this PR does. Happy to rework it the other way if you prefer.

What I checked

  • semgrep test javascript/lang/correctness/ passes before (5/5) and after (4/4) the removal, and javascript/lang/ passes 41/41 after, on semgrep 1.169.0.
  • Ran the rule against a plain ES2021 snippet (title.replaceAll(" ", "-")) and it fires as a blocking correctness finding.
  • Grepped the repo for no-replaceall: only the rule file and its test file reference it, so nothing else needed updating.

The new-rule checklist doesn't apply here since this removes a rule.

String.prototype.replaceAll is ES2021 and Baseline widely available
since August 2020 (Chrome 85, Firefox 77, Safari 13.1, Node 15). The
rule's warning that replaceAll 'is not supported in all versions of
javascript' is no longer true, so every match in the correctness
category is a false positive on valid modern code.

Fixes semgrep#3984
@CLAassistant

CLAassistant commented Jul 10, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

no-replaceall is outdated

2 participants