function listFilesUsingFileEnumerator(FileEnumerator, src, extensions) {
  // We need to know whether this is being run with flat config in order to
  // determine how to report errors if FileEnumerator throws due to a lack of eslintrc.

  const { ESLINT_USE_FLAT_CONFIG } = process.env;

  // This condition is sufficient to test in v8, since the environment variable is necessary to turn on flat config
  let isUsingFlatConfig = ESLINT_USE_FLAT_CONFIG && process.env.ESLINT_USE_FLAT_CONFIG !== 'false';

  // In the case of using v9, we can check the `shouldUseFlatConfig` function
  // If this function is present, then we assume it's v9
  try {
    const { shouldUseFlatConfig } = require('eslint/use-at-your-own-risk');
    isUsingFlatConfig = shouldUseFlatConfig && ESLINT_USE_FLAT_CONFIG !== 'false';
  } catch (_) {
    // We don't want to throw here, since we only want to update the
    // boolean if the function is available.
  }

  const enumerator = new FileEnumerator({
    extensions,
  });

  try {
    return Array.from(
      enumerator.iterateFiles(src),
      ({ filePath, ignored }) => ({ filename: filePath, ignored }),
    );
  } catch (e) {
    // If we're using flat config, and FileEnumerator throws due to a lack of eslintrc,
    // then we want to throw an error so that the user knows about this rule's reliance on
    // the legacy config.
    if (
      isUsingFlatConfig
      && e.message.includes('No ESLint configuration found')
    ) {
      throw new Error(`
Due to the exclusion of certain internal ESLint APIs when using flat config,
the import/no-unused-modules rule requires an .eslintrc file to know which
files to ignore (even when using flat config).
The .eslintrc file only needs to contain "ignorePatterns", or can be empty if
you do not want to ignore any files.

See https://github.com/import-js/eslint-plugin-import/issues/3079
for additional context.
`);
    }
    // If this isn't the case, then we'll just let the error bubble up
    throw e;
  }
}
Given a FileEnumerator class, instantiate and load the list of files.
@param FileEnumerator the `FileEnumerator` class from `eslint`'s internal api
@param {string} src path to the src root
@param {string[]} extensions list of supported extensions
@returns {{ filename: string, ignored: boolean }[]} list of files to operate on