loadConfig = async (configFile, cwd = process.cwd()) => {
  if (configFile != null) {
    if (path.isAbsolute(configFile)) {
      return importConfig(configFile);
    } else {
      return importConfig(path.join(cwd, configFile));
    }
  }
  let dir = cwd;

  while (true) {
    const js = path.join(dir, 'svgo.config.js');
    if (await isFile(js)) {
      return importConfig(js);
    }
    const mjs = path.join(dir, 'svgo.config.mjs');
    if (await isFile(mjs)) {
      return importConfig(mjs);
    }
    const cjs = path.join(dir, 'svgo.config.cjs');
    if (await isFile(cjs)) {
      return importConfig(cjs);
    }
    const parent = path.dirname(dir);
    if (dir === parent) {
      // @ts-expect-error https://github.com/microsoft/TypeScript/issues/33912
      return null;
    }
    dir = parent;
  }
}
If you write a tool on top of svgo you might need a way to load svgo config.
You can also specify relative or absolute path and customize current working
directory.

@type {<T extends string | null>(configFile?: T, cwd?: string) => Promise<T extends string ? import('./svgo.js').Config : import('./svgo.js').Config | null>}