From 2211d6f04fcbbec0b479f7866e89a7904d32970c Mon Sep 17 00:00:00 2001 From: Joe Hildebrand Date: Tue, 3 Dec 2024 23:59:53 -0700 Subject: [PATCH] test: Matching escaped and unescaped keys (#70) * test: Matching escaped and unescaped keys. Refs #68 * Update momoa, uncomment test and ensure it now passes. * fmt --- package.json | 2 +- tests/rules/no-duplicate-keys.test.js | 55 +++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 14fc0d0..fc3da65 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "license": "Apache-2.0", "dependencies": { "@eslint/plugin-kit": "^0.2.3", - "@humanwhocodes/momoa": "^3.3.3" + "@humanwhocodes/momoa": "^3.3.4" }, "devDependencies": { "@eslint/core": "^0.6.0", diff --git a/tests/rules/no-duplicate-keys.test.js b/tests/rules/no-duplicate-keys.test.js index 5cf4d21..e914a73 100644 --- a/tests/rules/no-duplicate-keys.test.js +++ b/tests/rules/no-duplicate-keys.test.js @@ -133,5 +133,60 @@ ruleTester.run("no-duplicate-keys", rule, { }, ], }, + { + code: '{"f\\u006fot": 1, "fo\\u006ft": 2}', + errors: [ + { + messageId: "duplicateKey", + data: { key: "foot" }, + line: 1, + column: 18, + endLine: 1, + endColumn: 29, + }, + ], + }, + { + code: '{"f\\u006fot": 1, "fo\\u006ft": 2}', + language: "json/jsonc", + errors: [ + { + messageId: "duplicateKey", + data: { key: "foot" }, + line: 1, + column: 18, + endLine: 1, + endColumn: 29, + }, + ], + }, + { + code: '{"f\\u006fot": 1, "fo\\u006ft": 2}', + language: "json/json5", + errors: [ + { + messageId: "duplicateKey", + data: { key: "foot" }, + line: 1, + column: 18, + endLine: 1, + endColumn: 29, + }, + ], + }, + { + code: "{f\\u006fot: 1, fo\\u006ft: 2}", + language: "json/json5", + errors: [ + { + messageId: "duplicateKey", + data: { key: "foot" }, + line: 1, + column: 16, + endLine: 1, + endColumn: 25, + }, + ], + }, ], });