eslint-plugin-eslint-plugin
eslint-plugin-eslint-plugin copied to clipboard
New Rule: `no-incomplete-schema`
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 https://github.com/eslint/rfcs/pull/85#discussion_r775144472 such as:
{}{ type: "array" }- etc
And ensure:
- Objects have
additionalProperties: falseto ensure all properties are included - Does not allow empty strings
uniqueItems: truefor arraysminItems: 1for 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:
- https://github.com/ota-meshi/eslint-plugin-json-schema-validator