{"id":19640,"library":"eslint-formatter-gha","title":"ESLint GitHub Actions Formatter","description":"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).","status":"active","version":"2.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/sjinks/eslint-gha-formatter","tags":["javascript","eslint","formatter","eslint formatter","eslint-formatter","eslintformatter","matcher","GitHub Actions","actions","typescript"],"install":[{"cmd":"npm install eslint-formatter-gha","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-formatter-gha","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-formatter-gha","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM default export. The package provides a single function used as an ESLint formatter.","wrong":"const ghaFormatter = require('eslint-formatter-gha')","symbol":"default","correct":"import ghaFormatter from 'eslint-formatter-gha'"},{"note":"Use the short formatter name 'gha', not the package name.","wrong":"eslint . -f eslint-formatter-gha","symbol":"eslint formatter usage via CLI","correct":"eslint . -f gha"},{"note":"CommonJS require returns the default export, not a named export.","wrong":"const { ghaFormatter } = require('eslint-formatter-gha')","symbol":"module.exports (CJS fallback)","correct":"const ghaFormatter = require('eslint-formatter-gha')"}],"quickstart":{"code":"// Run ESLint with GitHub Actions formatter:\n// eslint . -f gha\n\n// Programmatic usage (ESM):\nimport ghaFormatter from 'eslint-formatter-gha';\nimport { ESLint } from 'eslint';\n\nconst eslint = new ESLint();\nconst results = await eslint.lintFiles(['./src']);\nconst formatter = await ghaFormatter(results);\nconsole.log(formatter);","lang":"typescript","description":"Shows CLI usage and programmatic usage with ESM import, linting a directory and formatting results."},"warnings":[{"fix":"Use `-f gha` in CLI or set formatter to 'eslint-formatter-gha' in config.","message":"Formatter name must be 'gha', not the full package name.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure GITHUB_ACTIONS=true is set in your GitHub Actions workflow; for other CI, consider a different formatter.","message":"The 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Set SONARSCANNER only when intended; handle file writes carefully.","message":"When SONARSCANNER=true, output is JSON written to GITHUB_WORKSPACE/eslint-report.json. This may overwrite existing files.","severity":"gotcha","affected_versions":">=1.1.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run `npm install --save-dev eslint-formatter-gha`.","cause":"Package not installed or not in node_modules.","error":"Error: Cannot find module 'eslint-formatter-gha'"},{"fix":"Use `-f gha` instead of `-f eslint-formatter-gha`.","cause":"Using full package name instead of 'gha' in CLI.","error":"Error: Invalid formatter 'eslint-formatter-gha'"},{"fix":"Use dynamic import: `const ghaFormatter = await import('eslint-formatter-gha')` or switch to ESM imports.","cause":"Using require() in an ESM-only context (Node.js 12+).","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module not supported"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}