Registry / devops / eslint-formatter-gha

eslint-formatter-gha

JSON →
library2.0.1jsnpmunverified

ESLint formatter (v2.0.1) that generates GitHub Actions annotations for linting errors and warnings, enabling inline code annotations in pull request diffs and checks. When run outside a GitHub Actions environment, it falls back to ESLint's built-in stylish formatter. Optionally outputs JSON for SonarCloud integration. Includes TypeScript type definitions. Compatible with ESLint 8 and 9 (flat config).

npm install eslint-formatter-gha
INSTALL
IMPORT
SIG · ESLINT-FORMATTER-G
E
eslint-formatter-gha
devopsjavascriptv2.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import ghaFormatter from 'eslint-formatter-gha'
const ghaFormatter = require('eslint-formatter-gha')
ESM default export. The package provides a single function used as an ESLint formatter.
eslint formatter usage via CLI
eslint . -f gha
eslint . -f eslint-formatter-gha
Use the short formatter name 'gha', not the package name.
module.exports (CJS fallback)
const ghaFormatter = require('eslint-formatter-gha')
const { ghaFormatter } = require('eslint-formatter-gha')
CommonJS require returns the default export, not a named export.

Shows CLI usage and programmatic usage with ESM import, linting a directory and formatting results.

// Run ESLint with GitHub Actions formatter: // eslint . -f gha // Programmatic usage (ESM): import ghaFormatter from 'eslint-formatter-gha'; import { ESLint } from 'eslint'; const eslint = new ESLint(); const results = await eslint.lintFiles(['./src']); const formatter = await ghaFormatter(results); console.log(formatter);
Debug
Known issues
gotchaFormatter name must be 'gha', not the full package name.
fix
Use `-f gha` in CLI or set formatter to 'eslint-formatter-gha' in config.
affects: >=1.0.0
gotchaThe formatter relies on the GITHUB_ACTIONS environment variable. If not set, it silently falls back to stylish formatter, which may cause unexpected output in CI.
fix
Ensure GITHUB_ACTIONS=true is set in your GitHub Actions workflow; for other CI, consider a different formatter.
affects: >=1.0.0
gotchaWhen SONARSCANNER=true, output is JSON written to GITHUB_WORKSPACE/eslint-report.json. This may overwrite existing files.
fix
Set SONARSCANNER only when intended; handle file writes carefully.
affects: >=1.1.0
Errors
Common errors & fixes
Error: Cannot find module 'eslint-formatter-gha'
Package not installed or not in node_modules.
fix
Run `npm install --save-dev eslint-formatter-gha`.
Error: Invalid formatter 'eslint-formatter-gha'
Using full package name instead of 'gha' in CLI.
fix
Use `-f gha` instead of `-f eslint-formatter-gha`.
Error [ERR_REQUIRE_ESM]: require() of ES Module not supported
Using require() in an ESM-only context (Node.js 12+).
fix
Use dynamic import: `const ghaFormatter = await import('eslint-formatter-gha')` or switch to ESM imports.
Upgrade
Version history
2.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
eslint-formatter-gha — npm install eslint-formatter-gha · libregistry