in src/__Private/LintRunCLIEventHandler.hack [45:117]
private async function linterRaisedErrorsImplAsync(
Linter $linter,
LintRunConfig::TFileConfig $config,
Traversable<LintError> $errors,
): Awaitable<LintAutoFixResult> {
$class = \get_class($linter);
$to_fix = vec[];
$result = LintAutoFixResult::ALL_FIXED;
$colors = $this->terminal->supportsColors();
$fixing_linter = (
$linter is AutoFixingLinter<_> &&
!C\contains_key($config['autoFixBlacklist'], $class)
)
? $linter
: null;
foreach ($errors as $error) {
$position = $error->getRange()[0] ?? null;
/* HHAST_IGNORE_ERROR[DontAwaitInALoop] */
await $this->terminal
->getStdout()
->writeAllAsync(Str\format(
"%s%s%s\n"." %sLinter: %s%s\n"." Location: %s\n",
$colors ? "\e[1;31m" : '',
$error->getDescription(),
$colors ? "\e[0m" : '',
$colors ? "\e[90m" : '',
$error->getLintRule()->getName(),
$colors ? "\e[0m" : '',
$position === null
? $error->getFile()->getPath()
: Str\format(
'%s:%d:%d',
$error->getFile()->getPath(),
$position[0],
$position[1],
),
));
if ($fixing_linter) {
/* HHAST_IGNORE_ERROR[DontAwaitInALoop] */
$should_fix = await $this->shouldFixLintAsync(
$fixing_linter,
/* HH_FIXME[4110] TError is lost here*/
/* HH_FIXME[4323] TError is lost here*/
$error,
);
if ($should_fix) {
$to_fix[] = $error;
} else {
$result = LintAutoFixResult::SOME_UNFIXED;
}
continue;
}
/* HHAST_IGNORE_ERROR[DontAwaitInALoop] */
await $this->renderLintBlameAsync($error);
$result = LintAutoFixResult::SOME_UNFIXED;
}
if (!C\is_empty($to_fix)) {
invariant($fixing_linter, "Can't fix without a fixing linter");
self::fixErrors(
$fixing_linter,
/* HH_FIXME[4110] TError is lost here */
/* HH_FIXME[4323] TError is lost here */
$to_fix
);
}
return $result;
}