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

Update JSON Schema on schemastore.org #632

Closed
reitzig opened this issue Feb 15, 2024 · 10 comments · Fixed by #914 or #928
Closed

Update JSON Schema on schemastore.org #632

reitzig opened this issue Feb 15, 2024 · 10 comments · Fixed by #914 or #928
Labels
bug Something isn't working

Comments

@reitzig
Copy link

reitzig commented Feb 15, 2024

🔧 Summary

The JSON Schema published on schemastore.org is out of date.

(re #288, cc @hyperupcall )

Lefthook version

1.6.1

Steps to reproduce

Create a config like this:

pre-commit:
  piped: true
  commands:
    formatter:
      priority: 1
      glob: "*.go"
      run: go fmt ./...
      stage_fixed: true
    vet:
      priority: 1
      glob: "*.go"
      run: for f in {staged_files}; do go vet "${f}"; done

Expected results

No schema violations

Actual results

*.commands.*.priority not supported:

image

There may be more mismatches for any features added and changes made since SchemaStore/schemastore@c4b2db5d; this is just the one I ran into.

Possible Solution

  • Update the schema to the current state.
  • Source the schema in this repository and include tests against it in the build; re-submit to schemastore on releases.
    • Would the schema need versioning?
@reitzig reitzig added the bug Something isn't working label Feb 15, 2024
@hyperupcall
Copy link
Contributor

hyperupcall commented Feb 16, 2024

In SchemaStore/schemastore#3591, I updated the schema to include the latest additions to the config file. Since schemas in schemastore aren't (usually) maintained by project maintainers but rather schemastore people involved with schemastore, it is probably better to open an issue there.

@reitzig
Copy link
Author

reitzig commented Feb 16, 2024

Thank you!

Since schemas in schemastore aren't maintained by project maintainers but rather schemastore

How curious! Is there no way for a project to maintain their own schemas? Where can I read up on that?

@hyperupcall
Copy link
Contributor

hyperupcall commented Feb 16, 2024

How curious! Is there no way for a project to maintain their own schemas? Where can I read up on that?

@reitzig I appear to have mispoken. What I meant, simply, is that when a schema is located in the schemastore repository, it is better to file an issue in the schemastore repository. I said what I said because typically, for the project maintainers that do add schemas or make fixes to schemas that are hosted in schemastore, it's usually not something that happens every release or update - other contributors fill in the gaps. I personally don't expect project maintainers to do this updating, that is why the schemas are in SchemaStore. And the other reason, for some schemas, the contributions are made from only non-project maintainers, which is why raising the issue in schemastore would be more relevant. But this isn't always the case and there many examples where this isn't the case.

To answer your question: there are two places where projects can maintain their schema: either in schemastore, or in the project repository itself.

If the schemas are located in schemastore, the testing infrastructure is already setup, merging fixes is typically faster (me and the primary owner typically merge within a few hours to a few days, depending on PR complexity and schedule), and we also use a GitHub action to allow maintainers to merge fixes themselves, reading from CODEOWNERS file (so yes, a project can maintain their own schemas within SchemaStore).

If the schemas are located in the project repository itself, then naturally the project has more control over the schema. The pattern I've observed is that people sometimes people choose this if the schema is automatically generated by a command or, usually if the schema is used by a proprietary tool. There are plenty of exceptions, of course.

There is a tradeoff, and we give the ability for project maintainers to choose what they'd like. For more information, we have a CONTRIBUTING.md and if you have questions that aren't answered by that I'd be happy to answer them

@montchr
Copy link

montchr commented Jun 24, 2024

Since SchemaStore/schemastore#3591 has been merged, is this issue fixed?

@dAnjou
Copy link

dAnjou commented Jan 8, 2025

Got out of date again with #861. I've created an issue over there: SchemaStore/schemastore#4311. Maybe someone can help out there.

@ianzone
Copy link

ianzone commented Jan 13, 2025

I prefer the schema.json to be shipped with the npm package so I can reference it from node_modules, and then it can match the installed version of lefthook.

@mrexox
Copy link
Member

mrexox commented Jan 14, 2025

@ianzone Could you share an example npm package, please?

@dAnjou
Copy link

dAnjou commented Jan 14, 2025

@ianzone Could you share an example npm package, please?

I guess they mean this one: https://www.npmjs.com/package/lefthook

@ianzone
Copy link

ianzone commented Jan 14, 2025

@ianzone Could you share an example npm package, please?

I guess they mean this one: https://www.npmjs.com/package/lefthook

Yes, that one, just includes the schema file into that package.

@mrexox
Copy link
Member

mrexox commented Jan 15, 2025

Oh, no problem, will add it with the next release 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
6 participants