Skip to content

New Rule: no-incomplete-schema #296

Open
@bmish

Description

@bmish

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:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions