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

Quick changes to support array item validation #142

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

tbrockman
Copy link

@tbrockman tbrockman commented Sep 24, 2024

Not sure whether this contribution will be appreciated (and I totally won't be offended if it isn't), but I wanted syntax highlighting on individual (non-object) array items to work (plus to change some linting behavior to mirror VSCode a bit more closer, for ex. missing required properties highlighting the key) and I'd already done a bit of poking around the code to patch away the use of shikijs (my specific use-case makes it a bit less straight-forward to use things which require WASM), and had plans to make changes to autocomplete... so I just figured what the heck, may as well make a fork.

Rather than hoard my changes I thought I'd share them in case they're at all useful to the project. Admittedly, I haven't thoroughly tested them (beyond passing tests), so I'm open to making some edits if it turns out to have been an incorrect approach, but so far it seems to work for my needs.

This PR extends the existing getJsonPointers() code to add support for registering pointers to non-object array items, returning most specific error paths (when possible), and updates existing tests to reflect the changes. It also updates keyFrom and keyTo to be optional, to allow root objects and array elements to not have a key range (which makes sense to me), only a value range.

…keyTo and keyFrom (arrays items), updates tests to reflect the changes, and modifies some error path code to better match VSCode JSON schema linting behavior.
Copy link

changeset-bot bot commented Sep 24, 2024

🦋 Changeset detected

Latest commit: 69e36c6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
codemirror-json-schema Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

netlify bot commented Sep 24, 2024

Deploy Preview for codemirror-json-schema ready!

Name Link
🔨 Latest commit 69e36c6
🔍 Latest deploy log https://app.netlify.com/sites/codemirror-json-schema/deploys/673b7c715d1c8b0008fbe332
😎 Deploy Preview https://deploy-preview-142--codemirror-json-schema.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@acao
Copy link
Collaborator

acao commented Nov 18, 2024

awesome work, @tbrockman !
I plan to look at this more closely soon, I'm interested in seeing if we need to add any more test cases
if you add a changeset, we can add this to the next release!

@tbrockman
Copy link
Author

@acao sounds great, will do when I find some time!

@tbrockman tbrockman marked this pull request as ready for review November 18, 2024 17:42
@acao
Copy link
Collaborator

acao commented Jan 6, 2025

sorry @tbrockman just getting to this now! I will have to be careful about reconciling the changes to pointers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants