sindresorhus/parse-json

Remove `json-parse-even-better-errors`

fisker opened this issue · 1 comments

fisker commented

As I understand. It

  1. Add code point to unexpected token
parseJson('abcde')
Uncaught:
JSONError: Unexpected token 'a', "abcde" is not valid JSON while parsing 'abcde'
    at Module.parseJson (<CWD>/index.js:78:20)
    at REPL15:1:69 {
  fileName: undefined,
  codeFrame: undefined,
  rawCodeFrame: undefined
}

but it doesn't work anymore, since Node.js changed the error message.

Test case come from https://github.com/npm/json-parse-even-better-errors/blob/25d9898034a1641a5bd3aa34446838a7932ee954/test/index.js#L161

This is a good feature, but we can do it in this code base ourself.

  1. It add part of code to the message.
JSONError: Unterminated string in JSON at position 11 while parsing '{"foo: bar}'

> 1 | {"foo: bar}
    |            ^

We already have code frame in the message, it seems unnecessary. Even confusing some time.

"abcde" is not valid JSON while parsing 'abcde'

👍