Skip to content

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

Description

@electrohyun

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
import json from "@eslint/json";

export default [
	{
		files: ["**/*.json"],
		plugins: { json },
		language: "json/json",
		rules: {
			"json/no-unnormalized-keys": ["error", { form: "NFKC" }],
		},
	},
];
{
	""": 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

  • I am willing to submit a pull request for this issue.

AI acknowledgment

  • 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.

I used AI to check the English grammar in the issue description I wrote myself. The technical decisions in those responses were my own.

For context, Microsoft Japanese IME supports full-width punctuation, so text such as "りんご" or "abc" can be entered. I had encountered this form while using Japanese input before, which prompted me to test the full-width quotation mark here.

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

acceptedbugSomething isn't workingrepro:yesIssues with a reproducible example

Type

No type

Projects

  • Status
    Complete

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions