Skip to content

Remove json-parse-even-better-errors #46

@fisker

Description

@fisker

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'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions