src/cli/expand-patterns.js/getSupportedFilesGlob
function* expandPatternsInternal(context) {
  // Ignores files in version control systems directories and `node_modules`
  const silentlyIgnoredDirs = {
    ".git": true,
    ".svn": true,
    ".hg": true,
    node_modules: context.argv["with-node-modules"] !== true,
  };

  const globOptions = {
    dot: true,
    ignore: Object.keys(silentlyIgnoredDirs)
      .filter((dir) => silentlyIgnoredDirs[dir])
      .map((dir) => "**/" + dir),
  };

  let supportedFilesGlob;
  const cwd = process.cwd();

  /** @type {Array<{ type: 'file' | 'dir' | 'glob'; glob: string; input: string; }>} */
  const entries = [];

  for (const pattern of context.filePatterns) {
    const absolutePath = path.resolve(cwd, pattern);

    if (containsIgnoredPathSegment(absolutePath, cwd, silentlyIgnoredDirs)) {
      continue;
    }

    const stat = statSafeSync(absolutePath);
    if (stat) {
      if (stat.isFile()) {
        entries.push({
          type: "file",
          glob: escapePathForGlob(fixWindowsSlashes(pattern)),
          input: pattern,
        });
      } else if (stat.isDirectory()) {
        entries.push({
          type: "dir",
          glob:
            escapePathForGlob(fixWindowsSlashes(pattern)) +
            "/" +
            getSupportedFilesGlob(),
          input: pattern,
        });
      }
    } else if (pattern[0] === "!") {
      // convert negative patterns to `ignore` entries
      globOptions.ignore.push(fixWindowsSlashes(pattern.slice(1)));
    } else {
      entries.push({
        type: "glob",
        glob: fixWindowsSlashes(pattern),
        input: pattern,
      });
    }
  }

  for (const { type, glob, input } of entries) {
    let result;

    try {
      result = fastGlob.sync(glob, globOptions);
    } catch ({ message }) {
      /* istanbul ignore next */
      yield { error: `${errorMessages.globError[type]}: ${input}\n${message}` };
      /* istanbul ignore next */
      continue;
    }

    if (result.length === 0) {
      yield { error: `${errorMessages.emptyResults[type]}: "${input}".` };
    } else {
      yield* sortPaths(result);
    }
  }

  function getSupportedFilesGlob() {
    if (!supportedFilesGlob) {
      const extensions = flat(
        context.languages.map((lang) => lang.extensions || [])
      );
      const filenames = flat(
        context.languages.map((lang) => lang.filenames || [])
      );
      supportedFilesGlob = `**/{${extensions
        .map((ext) => "*" + (ext[0] === "." ? ext : "." + ext))
        .concat(filenames)}}`;
    }
    return supportedFilesGlob;
  }
}