Skip to content

Commit

Permalink
test: Matching escaped and unescaped keys.
Browse files Browse the repository at this point in the history
Note that this is affected by
humanwhocodes/momoa#164
in the sense that in JSON5 mode, unquoted escaped
keys are not yet unescaped in the same was as
all other keys, and will not trigger this lint
yet.  When the momoa issue is fixed, released, and
we have updated to that version, uncomment the
last test in no-duplicate-keys.test.js.

Suggest that we create a separate issue in this
repo to track that change.

Refs eslint#68
  • Loading branch information
hildjj committed Dec 3, 2024
1 parent a0374aa commit 0f471a9
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions tests/rules/no-duplicate-keys.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,61 @@ 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,
},
],
},
// See: https://github.com/humanwhocodes/momoa/issues/164
// {
// code: '{f\\u006fot: 1, fo\\u006ft: 2}',
// language: "json/json5",
// errors: [
// {
// messageId: "duplicateKey",
// data: { key: "foot" },
// line: 1,
// column: 18,
// endLine: 1,
// endColumn: 29,
// },
// ],
// },
],
});

0 comments on commit 0f471a9

Please sign in to comment.