> ## Documentation Index
> Fetch the complete documentation index at: https://loadwise.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# escape-replace-incomplete

> A hand-written string escape replaces only the first match, or escapes a delimiter without escaping backslashes first.

## What it flags

A `replace` or `replaceAll` call on a string that escapes markup, quote or delimiter characters incompletely:

* `replace` with a one-character string pattern or a regex without the `g` flag, such as `html.replace('<', '&lt;')` or `name.replace('"', '\\"')`. Only the first match is escaped.
* A backslash escape of a delimiter, such as `cell.replaceAll('|', '\\|')` or `s.replace(/"/g, '\\"')`, where the receiver does not come from a chain or a local assignment that first escapes backslashes.

The rule resolves the receiver to the built-in string method. The missing-backslash diagnostic skips direct comparison operands and direct inputs to the built-in `JSON.stringify` when it takes only that input. It also skips return values from a local named replacer whose only uses pass it as the replacer to the built-in `JSON.stringify`.

The check carries earlier escape evidence through a built-in array `map` only when a direct callback returns its sole parameter unchanged.

## How to review or fix

Use `replaceAll` or a regex with the `g` flag. Escape backslashes before the delimiter, for example `text.replaceAll('\\', '\\\\').replaceAll('|', '\\|')`, or use the target format's own escaping function (`JSON.stringify`, an HTML escaper, a parameterized query).

## Configuration

Set the rule to `"off"` in `loadwise.config.json` to drop its findings:

```json theme={null}
{
  "rules": { "escape-replace-incomplete": "off" }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.