Registry / testing / eslint-formatter-json-relative

eslint-formatter-json-relative

JSON →
library0.1.0jsnpmunverified

A formatter for ESLint that outputs linting results in JSON format, but replaces all absolute file paths with paths relative to the current working directory. Version 0.1.0 is the latest stable release. This package is a thin wrapper around ESLint's built-in JSON formatter, with no active development or updates expected. It is designed to produce portable output that can be consumed by tools in CI or other environments where absolute paths may differ. Alternatives include using the native JSON formatter with a post-processing step.

npm install eslint-formatter-json-relative
INSTALL
IMPORT
SIG · ESLINT-FORMATTER-J
E
eslint-formatter-json-relative
testingjavascriptv0.1.0
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 formatter from 'eslint-formatter-json-relative'
const formatter = require('eslint-formatter-json-relative')
The package is ESM-only; require() may fail depending on Node.js version and project configuration.
formatter (CommonJS)
const formatter = require('eslint-formatter-json-relative')
import formatter from 'eslint-formatter-json-relative'
While the package is ESM, it may still be required if the project uses CommonJS, but this is not officially supported.
default (with type assertion)
import type { Linter } from 'eslint'; import formatter from 'eslint-formatter-json-relative';
import formatter from 'eslint-formatter-json-relative'; // missing type import for Linter.Formatter
No types are shipped; you may need to cast or use the ESLint type definitions.

Shows installation, CLI usage, and programmatic usage of the formatter, including how to get relative-path JSON output.

// Install: npm i eslint-formatter-json-relative --save-dev // Use via ESLint CLI: eslint -f json-relative ./src // Or programmatically in an ESLint plugin or script: import formatter from 'eslint-formatter-json-relative'; import { ESLint } from 'eslint'; const eslint = new ESLint(); const results = await eslint.lintFiles(['./src']); const output = formatter(results); console.log(output);
Debug
Known issues
gotchaThe formatter only replaces absolute paths with relative ones; all other JSON structure is identical to the built-in JSON formatter.
fix
No action needed; this is expected behavior.
affects: >=0.1.0
gotchaThe package is ESM-only; using require() may fail in some Node.js versions or configurations.
fix
Use import instead of require, or ensure your project is set up for ESM.
affects: >=0.1.0
deprecatedNo updates since initial release; consider using ESLint's built-in JSON formatter and processing paths yourself.
fix
Use --format json with a post-processing script to convert absolute paths to relative.
affects: >=0.1.0
Errors
Common errors & fixes
Cannot find module 'eslint-formatter-json-relative'
The package is not installed or is not in the current working directory's node_modules.
fix
Run `npm install eslint-formatter-json-relative --save-dev` in the project root.
Error: Formatter 'json-relative' not found
ESLint cannot resolve the formatter name. The package name must be 'eslint-formatter-json-relative' when installed from npm, but the -f argument uses the short name 'json-relative'.
fix
Use `eslint -f json-relative` after installing the package correctly.
TypeError: formatter is not a function
Attempting to import the default export incorrectly, e.g., using a named import or importing from the wrong path.
fix
Use `import formatter from 'eslint-formatter-json-relative'` (default import) and ensure the package is installed.
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

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