pre-commit / pre-commit-hooks

Some out-of-the-box hooks for pre-commit
MIT License
5.34k stars 708 forks source link

check-json fails with wrong message #1026

Closed bluppfisk closed 7 months ago

bluppfisk commented 7 months ago

given

test.json:

{
 "date": {
  "$ref": "#/components/schemas/Datetime",
}
}

and

pre-commit run --files test.json

I get error:

test.json: Failed to json decode (Expecting property name enclosed in double quotes: line 4 column 1 (char 56))

While the error is the trailing comma, not an improperly enclosed property name.

asottile commented 7 months ago

after a comma there should be a property name

the error message is correct

bluppfisk commented 7 months ago

Whether it's correct is debatable. It's misleading at least. I'd alter it to "Property name missing or not enclosed in double quotes"

asottile commented 7 months ago

feel free to send a pr to cpython lol