Skip to content

linters/eslint

Linting utility for ESLint configuration with support for automatic fixing.

This module provides a function to lint files based on the ESLint configuration defined in eslint.config.ts. It can automatically fix linting issues if specified, and logs results to the console.

It also keeps a crashed linter apart from a red codebase. Handing ESLint’s exit code straight to execFromRoot and letting it throw reports every non-zero code the same way – Command failed with exit code N – which puts a rule that threw, a broken config and an OS-level death in the same bucket as real findings. The reader then goes hunting for a defect in source code that was never judged at all.

Interface Description
LintOptions Parameters for the lint function.
Function Description
classifyEslintExit Decides which of the three things an ESLint run established. A killed process is did-not-lint whatever its exit code says, because a signal means it was stopped rather than that it finished. An exit 1 carrying ESLint’s fatal-error banner is did-not-lint too: that is a crash npm relayed as a plain 1, not a finding.
describeFailureToLint Says which of the four failures to lint happened, and quotes back what ESLint said about it.
hasEslintConfig Says whether the project configures ESLint itself.
lint Lint the project with ESLint.
Type Description
EslintExitKind What an ESLint run actually established. - clean – it linted everything and found nothing, warnings included: see ESLINT_WARNINGS_AS_FINDINGS_ARGUMENTS for what makes the “included” half true. - lint-problems – it linted everything and the SOURCE is red. - did-not-lint – it never got through the lint, so the source has not been judged at all.
Variable Description
LINT_PROBLEMS_MESSAGE The message thrown for real findings, kept apart from describeFailureToLint’s.