chore: add eslint rule to validate tool schema patterns#1191
Merged
OrKoN merged 4 commits intoChromeDevTools:mainfrom Apr 1, 2026
Merged
chore: add eslint rule to validate tool schema patterns#1191OrKoN merged 4 commits intoChromeDevTools:mainfrom
OrKoN merged 4 commits intoChromeDevTools:mainfrom
Conversation
Contributor
|
Thank you! The lint rule LGTM. I don't feel comfortable with the API change to How about not touching the |
Contributor
Author
|
Reverted fill_form changes and excluded |
Lightning00Blade
approved these changes
Mar 20, 2026
Collaborator
Lightning00Blade
left a comment
There was a problem hiding this comment.
LGTM, with 2 small nits.
wolfib
approved these changes
Mar 20, 2026
Collaborator
|
Thanks @mvanhorn ! |
Add `@local/no-zod-nullable-object` ESLint rule that disallows `.nullable()` and `.object()` in tool schemas (src/tools/**). Fix existing violation in fill_form by using "uid=value" string format instead of zod.object(). Remove the TODO from CONTRIBUTING.md. Closes ChromeDevTools#1076
- Revert fill_form API changes (src/tools/input.ts, tests/tools/input.test.ts) - Rename rule to enforce-zod-schema per reviewer suggestion - Fix copyright year to 2026 - Add comment explaining .nullable() catches all calls intentionally - Exclude src/tools/input.ts from the lint rule via ignores
Co-authored-by: Nikolay Vitkov <34244704+Lightning00Blade@users.noreply.github.com>
6e7851b to
c543391
Compare
Merged
via the queue into
ChromeDevTools:main
with commit Apr 1, 2026
2e1eaba
28 of 30 checks passed
Contributor
Author
|
Appreciate the review! |
Contributor
Author
|
Appreciate the fast turnaround on this one too! |
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.
Summary
@local/no-zod-nullable-objectESLint rule that disallows.nullable()and.object()usage in tool schema files (src/tools/**/*.ts)zod.object()violation infill_formby converting the elements array from objects to"uid=value"formatted stringsContext
Per the PR #1073 review and the CONTRIBUTING.md guidelines, tool schemas should not use
.nullable()or.object()types. Complex objects should be represented as short formatted strings instead.The rule catches:
zod.object({...})/z.object({...})- flags direct zod object schema usage.nullable()- flags nullable schema usage on any expressionCloses #1076
Test plan
npx eslint src/tools/passes with no violationszod.object()or.nullable()insrc/tools/triggers the rulenpx tsc --noEmit)fill_formtest updated to use new string format