Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add raw codeFrame and fix JSONError type #37

Merged

Conversation

crondinini
Copy link
Contributor

@crondinini crondinini commented Aug 30, 2023

Description

Needed to get the code lines without the highlighting, so I have introduced a new property for it.

Also fixes JSONError to be a class so that the instanceof comparison can be used in a Typescript codebase.

test.js Outdated
parseJson('{\n\t"foo": true,\n}', 'foo.json');
} catch (error) {
t.assert(error.codeFrame);
t.true(error.rawCodeFrame === ' 1 | {\n 2 | \t"foo": true,\n> 3 | }\n | ^');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use t.is()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@sindresorhus
Copy link
Owner

You need to add it to the readme and index.d.ts

@sindresorhus sindresorhus merged commit 9f3bd0b into sindresorhus:main Sep 1, 2023
@sindresorhus
Copy link
Owner

This was already merged and released.

SmushyTaco pushed a commit to SmushyTaco/parse-json that referenced this pull request Jan 15, 2025
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants