Add json parse linter to json-lang package #316
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "json-parse-linter"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This seems to assume V8's error message format (for example, Firefox emits something like "SyntaxError: JSON.parse: expected double-quoted property name at line 1 column 12 of the JSON data"). It'd be good to at least cover all major browsers.
Also, can't you just use
state.doc.toString()instead of theArray.frominvocation that you have there?state.docis never null, so the??is superfluous too.Tested in Chrome, Firefox, Opera and Edge with the latest versions. I am not able to test on Safari or IE.
Safari 13 macOS:
Thanks!
It should work as well, but the error is shown on position 0 all the time.
Edit: Not sure if this linter makes sense, since the behavior is not consistent on all browsers. It probably makes more sense to base the linting on the lezer syntax or a third party lib. What do you think about that @marijnh ?
Thanks. Two more nitpicks: this project uses semicolon-less style, and we target IE11, which doesn't have
Number.isNaN. But since\d+will only ever match integers, the check seems unnecessary in general.