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

New Rule: no-incomplete-schema #296

Open
bmish opened this issue Sep 6, 2022 · 0 comments
Open

New Rule: no-incomplete-schema #296

bmish opened this issue Sep 6, 2022 · 0 comments

Comments

@bmish
Copy link
Member

bmish commented Sep 6, 2022

or named require-meta-schema-completeness.

This could also potentially be part of eslint-plugin/require-meta-schema but that's probably too much in one rule.

This rule would check for common useless / no-op schemas as discussed in eslint/rfcs#85 (comment) such as:

  • {}
  • { type: "array" }
  • etc

And ensure:

  • Objects have additionalProperties: false to ensure all properties are included
  • Does not allow empty strings
  • uniqueItems: true for arrays
  • minItems: 1 for arrays
  • Array item types are specified
  • It looks like z-schema has some related checks

But the challenge is encouraging completeness while still allowing rules to have any valid schema / options format.

There's also strict mode in ajv that is related and that we could take ideas from to enforce. If ESLint ever upgraded ajv, like in the declined ajv v8 upgrade PR, it's worth considering enabling strict mode.

There are also a few other linters targeting JSON Schema:

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

No branches or pull requests

1 participant