Skip to content

Commit 73466fd

Browse files
committed
linter: add check ref-best-practice
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
1 parent 3bcc377 commit 73466fd

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

tools/src/main/js/linter/index.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -376,12 +376,24 @@ export class SchemaLinter {
376376
}
377377

378378
/**
379-
* Utility to traverse a JSON schema and call a visitor function
380-
* @param {object} schema - The schema to traverse
381-
* @param {function} visitor - Function called for each node: (node, path, key, parent)
382-
* @param {string} [path] - Current path (used internally)
383-
* @param {string} [key] - Current key (used internally)
384-
* @param {object} [parent] - Parent node (used internally)
379+
* Utility to traverse a JSON schema depth-first and call a visitor function for each node.
380+
*
381+
* The visitor is invoked before descending into a node's children.
382+
* If the visitor returns `false`, the node's children are not traversed
383+
* (the subtree is pruned); any other return value (including `undefined`)
384+
* continues the traversal.
385+
*
386+
* @param {*} schema - The schema (or sub-schema/value) to traverse
387+
* @param {function(*, string, (string|number|null), (object|null)): (boolean|void)} visitor -
388+
* Function called for each node with `(node, path, key, parent)`:
389+
* - `node`: the current value (object, array, or primitive)
390+
* - `path`: JSON-path-like location, e.g. `$.properties.foo[0]`
391+
* - `key`: the property name or array index of `node` in its parent, `null` at the root
392+
* - `parent`: the parent object/array, `null` at the root
393+
* Return `false` to skip traversal of this node's children.
394+
* @param {string} [path='$'] - Current path (used internally)
395+
* @param {string|number|null} [key=null] - Current key (used internally)
396+
* @param {object|null} [parent=null] - Parent node (used internally)
385397
*/
386398
export function traverseSchema(schema, visitor, path = '$', key = null, parent = null) {
387399
if (visitor(schema, path, key, parent) === false) {

0 commit comments

Comments
 (0)