Repository navigation
feat: zodResolver reads a schema declared inside the component - #19
Closed
mertcanaltin wants to merge 3 commits into
Closed
mertcanaltin wants to merge 3 commits into
mertcanaltin wants to merge 3 commits into
Conversation
…d by default, and how to turn it off
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #18; the diff here is the one commit on top of it.
A schema declared inside the component (
const formSchema = z.object({ ... })in the function body) was not read: only a constant at the top of the file was. In the corpus that was 12 of 156 calls. It is read now where the file declares that name once and the schema is made of zod and constants alone, the same rule as at the top of the file. The declaration is removed with the call replaced, as before.One built from a prop or a translation function (
z.string().min(2, t('short'))) is still not read, and the scan says which name stopped it.Reach on the corpus (each file alone in a directory): 57 before, 62 after. Of the 94 left: 64 import the schema from a module the one-file setup does not have, 8 have a function that is not carried (a message function,
superRefine, a transform), 5 useurl, 4 use a value from outside, and 13 others.Tests: a build with one schema of each kind inside two functions, the pure one replaced and held to
zodResolver, the one that callst()kept; the scan test's reason for a schema that uses a parameter.npm test: 267 tests, 265 pass, 2 skipped.Not covered:
letandvar, a destructured declaration, and a name the file declares twice are not read.