# prefer-string-raw

Prefer String.raw when backslashes are escaped only to preserve themselves

Repeatedly escaping literal backslashes obscures paths, regular-expression source, and similar text.
Instead, you SHOULD use a `String.raw` template when it preserves the same value without doubled backslashes.

Strings containing value-producing escapes remain unchanged.

- Category: style
- Level: warning
- Fix: automatic
- Scope: module

## Reported

```ds title="main.ds"
function path(): string {
    return "C:\\windows\\system32";
}
```

## Accepted

```ds title="main.ds"
function path(): string {
    return String.raw`C:\windows\system32`;
}
```

## Prior art

- [eslint-plugin-unicorn · prefer-string-raw](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-string-raw.md)

[language/linter/src/rules/style/prefer_string_raw.rs:8](https://github.com/destack-sh/destack/blob/main/language/linter/src/rules/style/prefer_string_raw.rs#L8)
