Registry / devops / eslint-formatter-json-with-metadata

eslint-formatter-json-with-metadata

JSON →
library9.0.1jsnpmunverified

Standalone package of ESLint's official `json-with-metadata` formatter. v9.0.1 is current stable. It outputs lint results as JSON including metadata (fix count). Released on the same cadence as ESLint. Useful for programmatic consumption or CI pipelines. No external dependencies. Ships TypeScript definitions. The only difference is it can be imported independently from the main `eslint` package.

npm install eslint-formatter-json-with-metadata
INSTALL
IMPORT
SIG · ESLINT-FORMATTER-J
E
eslint-formatter-json-with-metadata
devopsjavascriptv9.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

default
import formatter from 'eslint-formatter-json-with-metadata';
const formatter = require('eslint-formatter-json-with-metadata');
ESM-only since v9. Use dynamic import for CommonJS.
formatter
import formatter from 'eslint-formatter-json-with-metadata';
import { formatter } from 'eslint-formatter-json-with-metadata';
Default export, not named. Common mistake: attempting named import.
type
import type { Linter } from 'eslint';
TypeScript types are re-exported from ESLint; not directly provided.

Shows how to use the formatter programmatically with ESLint. The second argument is the data object with metadata.

import formatter from 'eslint-formatter-json-with-metadata'; import { ESLint } from 'eslint'; const eslint = new ESLint(); const results = await eslint.lintFiles(['*.js']); const resultText = formatter(results, results); console.log(resultText);
Debug
Known issues
breakingv9.0.0 changed to ESM-only. CommonJS require() will fail.
fix
Switch to ES modules (type: module in package.json) or use dynamic import: const formatter = await import('eslint-formatter-json-with-metadata');
affects: >=9.0.0
breakingv9.0.0 removed the deprecated metadata argument; now only accepts results object as single argument.
fix
Call formatter(results) instead of formatter(results, metadata). Use the same object for metadata if needed.
affects: >=9.0.0
gotchaThe formatter expects an array of results, not a single result object. Passing a single object will produce unexpected output (no messages shown).
fix
Always pass an array: formatter([result]) or formatter(results) where results is an array.
affects: >=9.0.0
Errors
Common errors & fixes
Cannot find module 'eslint-formatter-json-with-metadata'
Missing install or incorrect import path.
fix
Run 'npm install eslint-formatter-json-with-metadata' and ensure import path is correct.
formatter is not a function
Using named import instead of default import.
fix
Use default import: import formatter from 'eslint-formatter-json-with-metadata';
TypeError: Cannot read properties of undefined (reading 'messages')
Passing undefined or malformed results object.
fix
Ensure results is an array of ESLint result objects with 'messages' property.
Upgrade
Version history
9.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
eslint-formatter-json-with-metadata — npm install eslint-formatter-json-with-metadata · libregistry