ESLint formatter for Code Climate
raw JSON → 2.0.1 verified Sat Apr 25 auth: no javascript
An ESLint formatter that outputs lint results in the Code Climate report format, suitable for integration with Code Climate's platform. Version 2.0.1 supports ESLint >=9 and requires Node.js 20+. The v2.0.0 release switched fingerprint hashing from SHA1 to SHA256, a breaking change. It offers both a CLI formatter (--format codeclimate) and a programmatic API (toCodeClimate). Unlike generic JSON formatters, this produces a Code Climate-specific JSON structure with categories, fingerprints, and relative paths.
Common errors
error Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/node_modules/eslint-formatter-codeclimate/index.js from /path/to/script.js not supported. ↓
cause Using CommonJS require() on an ESM-only package.
fix
Use import syntax or dynamic import(), or set package type to module.
error Error: Cannot find module 'eslint-formatter-codeclimate' ↓
cause Package not installed or not in node_modules.
fix
Run 'npm install eslint-formatter-codeclimate'.
error TypeError: toCodeClimate is not a function ↓
cause Incorrect import of default export instead of named export.
fix
Use import { toCodeClimate } from 'eslint-formatter-codeclimate'.
error Error: ESLint configuration error: The formatter 'codeclimate' is not found. ↓
cause ESLint cannot find the formatter when used via CLI.
fix
Ensure the package is installed in the project and the formatter name matches the package name (--format codeclimate).
Warnings
breaking Fingerprint hash algorithm changed from SHA1 to SHA256 in v2.0.0, altering issue fingerprints. ↓
fix Update any systems that rely on fingerprint consistency (e.g., deduplication) to use the new hash.
breaking Peer dependency requirement changed to eslint >=9 in v2.0.0. ↓
fix Ensure eslint version is 9 or above.
gotcha Package is ESM-only. Using require() throws ERR_REQUIRE_ESM. ↓
fix Use import syntax or dynamic import().
gotcha Node.js version must be 20 or greater. ↓
fix Upgrade Node.js to 20+.
Install
npm install eslint-formatter-codeclimate yarn add eslint-formatter-codeclimate pnpm add eslint-formatter-codeclimate Imports
- formatter wrong
const formatter = require('eslint-formatter-codeclimate')correctimport formatter from 'eslint-formatter-codeclimate' - toCodeClimate wrong
const { toCodeClimate } = require('eslint-formatter-codeclimate')correctimport { toCodeClimate } from 'eslint-formatter-codeclimate'
Quickstart
import { ESLint } from 'eslint';
import { toCodeClimate } from 'eslint-formatter-codeclimate';
const cwd = process.cwd();
const eslint = new ESLint({ cwd });
const results = await eslint.lintFiles([]);
const rulesMeta = eslint.getRulesMetaForResults(results);
const issues = toCodeClimate(results, rulesMeta, cwd);
console.log(JSON.stringify(issues, null, 2));