# eslint no-regex-spaces: fix changes program behavior

Internal evidence sheet generated by fixhunt. Not an issue text. A human re-verifies, checks the duplicates
below, and writes the upstream report in their own words following the project's AI policy.

- Tool: eslint 9.39.5
- Rule: no-regex-spaces (tool labels the fix: safe, this fix reported as safe)
- Oracle: fix-changes-behavior
- Judge (Nemotron 3 Ultra, advisory): program-bug, severity low. The program attempts to call a regular expression literal as a function, which throws a TypeError both before and after the fix. The behavioral difference is caused by a pre-existing bug in the program unrelated to the rewrite, not by the rule's transformation of the regex pattern.
- Program: minimized from 3 to 2 lines

## Reproducer

```js
let x = /'hello   world'/
(['a','b']).forEach(c => { if (/^h/.test(c)) x = null })
```

## Commands

```sh
node prog.js
npx eslint --no-config-lookup --rule 'no-regex-spaces: error' --fix prog.js
node prog.js
```

## Observed

```
stderr before: TypeError: /'hello   world'/ is not a function
stderr after: TypeError: /'hello {3}world'/ is not a function
```

## Diff applied by the fix

```diff
--- orig.js	2026-10-22 14:19:26.953231274 -0400
+++ fixed.js	2026-10-22 14:19:29.560332775 -0400
@@ -1,2 +1,2 @@
-let x = /'hello   world'/
+let x = /'hello {3}world'/
 (['a','b']).forEach(c => { if (/^h/.test(c)) x = null })
```

## Why the rewrite is not equivalent (model draft, verify before use)

The original regex literal `/'hello   world'/` matches the exact string `'hello   world'` with three spaces; it does not call any function, so invoking `x()` would throw because a RegExp object is not callable. The transformed regex `/'hello {3}world'/` uses a quantifier `{3}` to mean exactly three of the preceding token—a space—so it still matches the same literal string. However, the error persists because the code attempts to call `x` as a function in both versions; the change did not alter the fact that `x` remains a RegExp, not a function, so the behavior is unchanged, not different—the premise of altered behavior is incorrect. Both versions throw identically.

## Upstream search

Queries: "no-regex-spaces fix", "no-regex-spaces regex literal spaces", "eslint no-regex-spaces quantifier replacement", "regex literal to curly braces transformation"

- related: https://github.com/eslint/eslint/issues/17054
  same rule no-regex-spaces autofix breaking code, but different construct (arrow function vs regex literal in expression)

<details><summary>All hits</summary>

- [github, closed] Bug: npm audit fix managed to break eslint and I'm not quite sure what is wrong. — https://github.com/eslint/eslint/issues/20560
- [github, closed] Bug: `no-undef` `no-unused-vars` — https://github.com/eslint/eslint/issues/19982
- [github, closed] Change Request: autoformat docs — https://github.com/eslint/eslint/issues/17504
- [github, closed] Change Request: (Add new config eslint/fixable containing all fixable rules) — https://github.com/eslint/eslint/issues/18027
- [github, closed] Change Request: track dependencies of eslint.config.js to invalidate cache & typescript support — https://github.com/eslint/eslint/issues/18337
- [github, closed] ESlint error "Switch cases without blocks are disallowed. eslint (no-restricted-syntax)" — https://github.com/eslint/eslint/issues/18200
- [github, closed] ESLint hangs indefinitely, no errors — https://github.com/eslint/eslint/issues/18449
- [github, closed] Support RegExp `v` flag — https://github.com/eslint/eslint/issues/17223
- [github, closed] Bug: --fix is breaking valid code inside a simple arrow function — https://github.com/eslint/eslint/issues/17054
- [github, closed] Bug: `.eslintrc.js` is ignored again — https://github.com/eslint/eslint/issues/17090
- [github, closed] Bug: no-useless-assignment rule fails — https://github.com/eslint/eslint/issues/20513
- [github, closed] Docs: rewrite examples with `var` using `const` and `let` — https://github.com/eslint/eslint/issues/19240
- [github, closed] Docs: Clearly mark rules that are frozen — https://github.com/eslint/eslint/issues/18694

</details>
