-
Notifications
You must be signed in to change notification settings - Fork 327
feat(linting): introduce jsonschema cli for linting and autofixing linting issues in schemas #625
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
base: master
Are you sure you want to change the base?
Conversation
…nting issues in schemas Signed-off-by: karan-palan <[email protected]>
Signed-off-by: karan-palan <[email protected]>
Signed-off-by: karan-palan <[email protected]>
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.
Thanks for the pull request. I'm inclined not to merge this as one can easily call your cli afterwards. I don't yet see the benefit of integrating linting into this tool. By separating the tools, people can lint with the version they prefer.
I do like the idea of lining all generates examples in the tests, though. Can you change the pull request to only do that?
}); | ||
|
||
describe("satisfies keyword - ignore from a \"satisfies\" and build by rally type", () => { | ||
describe('satisfies keyword - ignore from a "satisfies" and build by rally type', () => { |
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.
Please use consistent quotes
|
||
if (!options.fix && result) { | ||
console.log("JSON Schema lint results:"); | ||
console.log(result); |
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.
Can you also set the exit code?
} | ||
|
||
try { | ||
const result = execSync(cmd, { |
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'm not too happy about calling a tool like this. Don't you have a more direct/js way to call your library?
Fixes #623
Introduced linting schemas and auto-fixing linting issues in the schemas by integrating the @sourcemeta/jsonschema cli
Changes made:
Checklist
Note:
For context, I, along with Juan (JSON Schema TSC member) defined linting rules for JSON Schema as a Part of a GSoC (Google Summer of code) project here - https://github.com/Karan-Palan/JSON-Schema-Linting, and implementing their auto-fixes here - https://github.com/sourcemeta/jsonschema/blob/main/docs/lint.markdown. This is what we have accomplished so far - https://github.com/Karan-Palan/GSoC-2025/blob/main/Final-report.md. We have recently added many rules
prefixing unknown keywords with x-
which will be introduced in the newer JSON Schema drafts. We tested the linter on real world schemas and it was adopted by various projects like Vaccum, Manfred and many others. Many projects like ModelContextProtocol use this package for schema generation. One of their maintainers suggested to have the cli integrated in this package itself.Please:
Readme.md