eslint / eslint/json

Bug: `no-unnormalized-keys` autofix normalizes key without escaping `"` or `\`

Open
#282 2 comments 0 reactions 1 assignee Claimed by @electrohyun View on GitHub
accepted bug repro:yes
Dominant language
JavaScript
Stars
121
Forks
30
Avg merge
2d 5h
Merged PRs (30d)
6

Description

### Environment

ESLint version: 10.10.0
@eslint/json version: 2.1.0
Node version: 22.16.0
npm version: 11.17.0
Operating System: darwin 25.5.0

### Which language are you using?

json

### What did you do?

Configuration

```js
import json from "@eslint/json";

export default [
{
files: ["**/*.json"],
plugins: { json },
language: "json/json",
rules: {
"json/no-unnormalized-keys": ["error", { form: "NFKC" }],
},
},
];
```

```json
{
""": 1,
"\": 2
}

```

### What did you expect to happen?

Image

(Before running `npx eslint test.json --fix`)

The autofix should produce valid JSON `{"\"": 1, "\\": 2}`.

### What actually happened?

Image

(After running `npx eslint test.json --fix`)

The autofix produces invalid JSON `{""": 1, "\": 2}`.

### Link to Minimal Reproducible Example

https://stackblitz.com/edit/stackblitz-starters-vvepisbw?file=test.json (You can reproduce by running `npx eslint test.json --fix`)

### Participation

- [x] I am willing to submit a pull request for this issue.

### AI acknowledgment

- [x] I did not use AI to generate this issue report.
- [ ] (If the above is not checked) I have reviewed the AI-generated content before submitting.

### Additional comments

From my reading of the rule’s implementation and documentation, `no-unnormalized-keys` rule is intended to catch cases where different Unicode representations could cause key lookup or comparison mismatches.

However, it now includes an autofix that normalizes object keys according to the `NFC`, `NFD`, `NFKC`, or `NFKD`, so I opened this issue because I understood converting `"` to `"` to be within the intended scope of that autofix.

These characters may occur in practice through full-width input modes and conversions in Japanese and Chinese IMEs, so I think the autofix should preserve valid JSON when normalizing them.


Disclosure: I'm a participant of [open source contribution program OSSCA](https://github.com/eslint-ossca)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.