message: Use `while` loops instead of `for` loops in pathUtils
diff: @@ -3,18 +3,16 @@ import type { RuleGroupTypeAny, RuleType } from '../types';
  type FindPathReturnType = RuleGroupTypeAny | RuleType | null;
  export const findPath = (path: number[], query: RuleGroupTypeAny): FindPathReturnType => {
  - if (path.length === 0) {
  - return query;
  - }
  -
  let target: FindPathReturnType = query;
  - for (let level = 0; level < path.length && target && 'rules' in target; level++) {
  + let level = 0;
  + while (level < path.length && target && 'rules' in target) {
  const t: RuleGroupTypeAny | RuleType | string = target.rules[path[level]];
  if (typeof t !== 'string') {
  target = t;
  } else {
  target = null;
  }
  + level++;
  }
  return target;
  @@ -32,28 +30,27 @@ export const getCommonAncestorPath = (path1: number[], path2: number[]) => {
  const commonAncestorPath: number[] = [];
  const parentPath1 = getParentPath(path1);
  const parentPath2 = getParentPath(path2);
  -
  - for (
  let i = 0;
  - i < parentPath1.length && i < parentPath2.length && parentPath1[i] === parentPath2[i];
  - i++
  - ) {
  +
  + while (i < parentPath1.length && i < parentPath2.length && parentPath1[i] === parentPath2[i]) {
  commonAncestorPath.push(parentPath2[i]);
  + i++;
  }
  return commonAncestorPath;
  };
  export const pathIsDisabled = (path: number[], query: RuleGroupTypeAny) => {
  - if (query.disabled) return true;
  - let disabled = false;
  + let disabled = !!query.disabled;
  let target: RuleType | RuleGroupTypeAny = query;
  - for (let level = 0; level < path.length && !disabled && 'rules' in target; level++) {
  + let level = 0;
  + while (level < path.length && !disabled && 'rules' in target) {
  const t: RuleGroupTypeAny | RuleType | string = target.rules[path[level]];
  if (typeof t === 'object' && ('rules' in t || 'field' in t)) {
  disabled = !!t.disabled;
  target = t;
  }
  + level++;
  }
  return disabled;
  };
  