Registry / testing / eslint-formatter-codeframe

eslint-formatter-codeframe

JSON →
library7.32.2jsnpmunverified

This package provides ESLint's official 'codeframe' formatter, extracted from ESLint 7 as a standalone module for continued use after its removal in ESLint 8. It displays linting results with a colorful, framed code snippet showing the exact location of each problem. The current stable version is 7.32.2, matching ESLint 7's release cadence, and it is maintained by the eslint-community. Key differentiators: it's the exact same formatter as in ESLint 7, offers a more visually structured output than the default 'stylish' formatter, and can be used as a drop-in replacement with the --format flag.

npm install eslint-formatter-codeframe
INSTALL
IMPORT
SIG · ESLINT-FORMATTER-C
E
eslint-formatter-codeframe
testingjavascriptv7.32.2
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 codeframe from 'eslint-formatter-codeframe'
const codeframe = require('eslint-formatter-codeframe')
The package exports a single function as default export. Use ESM import for consistency with modern ESLint configs.
codeframe
import codeframe from 'eslint-formatter-codeframe'
import { codeframe } from 'eslint-formatter-codeframe'
Named import is incorrect; the package only has a default export.
type FormatterFunction
import type { FormatterFunction } from 'eslint-formatter-codeframe'
TypeScript types are included; import the type if you need the function signature.

Demonstrates installing, running via CLI, and programmatic usage of the codeframe formatter.

// Install: npm install --save-dev eslint-formatter-codeframe // Run ESLint with the codeframe formatter: // eslint --format codeframe *.js // Alternatively, use programmatically: import codeframe from 'eslint-formatter-codeframe'; const results = [ { filePath: './example.js', messages: [ { ruleId: 'no-unused-vars', severity: 2, message: "'addOne' is defined but never used.", line: 1, column: 10, endLine: 1, endColumn: 16 } ], errorCount: 1, warningCount: 0, fixableErrorCount: 0, fixableWarningCount: 0, source: 'function addOne(i) {\n if (i != NaN) {\n return i ++\n } else {\n return\n }\n};\n' } ]; const output = codeframe(results, {}); console.log(output);
Debug
Known issues
breakingThis package is extracted from ESLint 7. ESLint 8+ does not include this formatter; you must install this package separately.
fix
Install eslint-formatter-codeframe and use --format codeframe (it will be found automatically if installed in node_modules).
affects: >=8.0.0
gotchaThe formatter output may contain trailing '.' if preceded by a space (fixed in v7.32.2).
fix
Update to v7.32.2 or later.
affects: <7.32.2
gotchaProgrammatic use: the formatter expects results array with 'source' property; without it, code snippets cannot be displayed.
fix
Ensure ESLint results include the 'source' field (e.g., by calling CLIEngine with .executeOnFiles(...).results).
affects: >=7.0.0
deprecatedThis package is tied to ESLint 7's rule format; may not work correctly with ESLint 9 flat config or newer rule metadata.
fix
Consider using ESLint's built-in formatters or alternative community formatters for ESLint 9+ compatibility.
affects: >=7.0.0
Errors
Common errors & fixes
Cannot find module 'eslint-formatter-codeframe'
Package not installed or not in node_modules.
fix
Run npm install --save-dev eslint-formatter-codeframe
Missing source property in result object
Programmatic usage without providing source code.
fix
Ensure you pass results that include the source file content (e.g., from .executeOnFiles().results).
TypeError: codeframe is not a function
Incorrect import pattern (e.g., named import { codeframe }).
fix
Use import codeframe from 'eslint-formatter-codeframe' or const codeframe = require('eslint-formatter-codeframe').default
Error: Invalid formatter 'codeframe'
ESLint cannot find the formatter; the package is not installed or ESLint is running from a different directory.
fix
Install eslint-formatter-codeframe globally or ensure it is in the local node_modules when running ESLint.
Upgrade
Version history
7.32.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
4
Resources
eslint-formatter-codeframe — npm install eslint-formatter-codeframe · libregistry