configlet icon indicating copy to clipboard operation
configlet copied to clipboard

lint: should exit non-zero for a duplicate key name

Open ee7 opened this issue 3 years ago • 0 comments

A duplicate key is technically valid JSON [1], but recommended against (depending on the JSON spec) and is generally less portable.

But for our use case, any addition of a duplicate key is almost certainly unintended. So we should produce an error, rather than silently accepting it. I believe our Ruby JSON parser silently accepts it.

See also https://github.com/exercism/configlet/issues/312

[1] From section 6 of https://www.ecma-international.org/wp-content/uploads/ECMA-404_2nd_edition_december_2017.pdf:

6 Objects

An object structure is represented as a pair of curly bracket tokens surrounding zero or more name/value pairs. A name is a string. A single colon token follows each name, separating the name from the value. A single comma token separates a value from a following name. The JSON syntax does not impose any restrictions on the strings used as names, does not require that name strings be unique, and does not assign any significance to the ordering of name/value pairs. These are all semantic considerations that may be defined by JSON processors or in specifications defining specific uses of JSON for data interchange.

ee7 avatar Jun 02 '21 22:06 ee7