---
url: /docs/guide/usage/linter/rules/oxc/bad-replace-all-arg.md
---

### What it does

This rule warns when the `replaceAll` method is called with a regular expression that does not have the global flag (g).

### Why is this bad?

When called with a regular expression, the `replaceAll` method requires the global flag (g).
Otherwise, it throws a `TypeError` at runtime instead of performing a replacement.

### Examples

Examples of **incorrect** code for this rule:

```javascript
withSpaces.replaceAll(/\s+/, ",");
```

Examples of **correct** code for this rule:

```javascript
withSpaces.replaceAll(/\s+/g, ",");
```

## How to use

## Version

This rule was added in v0.0.22.

## References
