-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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: Replace JSON.parse with parseJsonWithSchema (@dev-mohit06) #6207
base: master
Are you sure you want to change the base?
refactor: Replace JSON.parse with parseJsonWithSchema (@dev-mohit06) #6207
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @dev-mohit06, nice work. I added some comments for you.
…WithSchema (@dev-mohit06) - Updated schema definitions for better clarity and reusability. - Replaced with where applicable. - Addressed all review comments for better code consistency.
Hey @fehmer, could you take a look at the changes? |
string | null | ||
]; | ||
const testSettingsSchema = z.tuple([ | ||
ModeSchema.nullable(), // Replaces z.union([ModeSchema, z.null()]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't think this comment adds any value.
Suggestion:
const TestSettingsSchema = z.tuple([
ModeSchema.nullable(),
Mode2Schema.nullable(),
CustomText.CustomTextDataSchema.nullable(),
z.boolean().nullable(), //punctuation
z.boolean().nullable(), //numbers
z.string().nullable(), //language
DifficultySchema.nullable(),
z.string().nullable(), //funbox
]);
Hey @fehmer, could you take a look at the changes? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @dev-mohit06 , changes look good. Please remove the code comment on the unresolved PR comment or replace with the suggested comments.
Thank you for your contribution. Do you want to take the backend part next?
Description
Replaces raw JSON parsing with schema-based validation across frontend TypeScript files to improve type safety and error handling.
Scope of Changes
Updated JSON parsing in:
account.ts
import-export-settings.ts
analytics-controller.ts
local-storage-with-schema.ts
url-handler.ts
commandline/lists.ts
test/wikipedia.ts
Added schema in
test/custom-text.ts
:Benefits
Checks