feat(linter): Improve linting by validating examples in nested schemas (T424002)
We consider a schema to satisfy the requirement to have examples only when all recursively traversed nested schemas have examples.
- Refactor
findNestedExamplesto coordinate recursive traversal. - Extract nested example validation logic into dedicated
evaluateNestedExamplesfunction. - Introduce
Setthat helps prevent infinite recursion on self-referencing schemas. - Use
WeakMapvalidation cache to memoize example check outcomes on shared schema objects, to prevent redundant walks. - Align keyword lists with ruleset's existing traversed keywords checklist.
- Adjust linter warning messages.
- Add missing examples in
oad_example.yamlto comply with most up-to-date rules. - Add and modify tests. Verify that new and old tests pass.
Why?
Previously, the code returned true if any property had an example. Now we want to recursively enforce examples in all relevant nested schemas.
Closes T424002
Closes T426836