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

Replace json-parse-helpfulerror with jsonc-parser #1493

Merged
merged 7 commits into from
Jan 26, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: lint
  • Loading branch information
Torathion committed Jan 26, 2025
commit 96a3217a1d0343a643662834f3181b1d89ebef93
8 changes: 4 additions & 4 deletions src/lib/utils/parseJson.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { ParseError, ParseErrorCode, parse } from 'jsonc-parser'

/**
* Parses a json string, while also handling errors and comments.
* Parses a json string, while also handling errors and comments.
*
* @param jsonString - target json string.
* @returns the parsed json object.
* @param jsonString - target json string.
* @returns the parsed json object.
*/
export default function parseJson(jsonString: string) {
const errors: ParseError[] = []
Expand All @@ -27,7 +27,7 @@ export default function parseJson(jsonString: string) {
currentOffset += line.length + 1 // +1 for the newline character
lineNumber++
}
// @ts-expect-error
// @ts-expect-error due to --isolatedModules forbidding to implement ambient constant enums.
errorString += `Error at line ${lineNumber}, column ${columnNumber}: ${ParseErrorCode[error.error]}\n${lines[lineNumber - 1]}\n${' '.repeat(columnNumber - 1)}^\n\n`
}

Expand Down
Loading