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

refactor(parsing): Replace JSON.parse with parseJsonWithSchema (@dev-… #6203

Closed

Conversation

dev-mohit06
Copy link

refactor(parsing): Replace JSON.parse with parseJsonWithSchema (@dev-mohit06)

Description

Replaces JSON.parse calls with parseJsonWithSchema to improve type safety and error handling across multiple frontend TypeScript files. This change enhances JSON parsing by adding schema validation and consistent error handling.

Checks

  • Adding quotes? (N/A)
  • Adding a language or a theme? (N/A)
  • Check if any open issues are related to this PR
  • PR title follows Conventional Commits standard
  • Included GitHub username in PR title

Changes

  • Updated JSON parsing in files:

    • frontend/src/ts/event-handlers/account.ts
    • frontend/src/ts/modals/import-export-settings.ts
    • frontend/src/ts/controllers/analytics-controller.ts
    • frontend/src/ts/utils/local-storage-with-schema.ts
    • frontend/src/ts/utils/url-handler.ts
    • frontend/src/ts/commandline/lists.ts
    • frontend/src/ts/test/wikipedia.ts
  • Added new schema in frontend/src/ts/test/custom-text.ts:

export const customTextDataSchema = z.object({
  text: z.array(z.string()),
  mode: CustomTextModeSchema,
  limit: z.object({ value: z.number(), mode: CustomTextLimitModeSchema }),
  pipeDelimiter: z.boolean(),
});

Motivation

  • Improve runtime type safety
  • Provide more robust error handling
  • Create consistent JSON parsing approach across application

@monkeytypegeorge monkeytypegeorge added the frontend User interface or web stuff label Jan 23, 2025
Copy link
Contributor

github-actions bot commented Jan 23, 2025

Hey there and thank you for opening this pull request! 👋🏼

We require pull request titles to follow the Conventional Commits specification and also include the author name at the end inside parenthesis. It looks like your proposed title needs to be adjusted.

Details:

Title "refactor(parsing): Replace JSON.parse with parseJsonWithSchema (@dev-…"
didn't match the configured pattern. Please ensure that the title
contains your name so that you can be credited in our changelog.
A correct version would look something like: 

feat: add new feature (@github-username)
impr(quotes): add english quotes (@github-username)
fix: resolve bug (@github-username)

A correct version would look something like:

feat: add new feature (@github-username)
impr(quotes): add english quotes (@github-username)
fix: resolve bug (@github-username)

Copy link
Contributor

Continuous integration check(s) failed. Please review the failing check's logs and make the necessary changes.

@dev-mohit06 dev-mohit06 deleted the fix/json-parse-schema branch January 23, 2025 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend User interface or web stuff
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants