{"id":19643,"library":"eslint-formatter-json-relative","title":"ESLint JSON Relative Formatter","description":"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.","status":"maintenance","version":"0.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/philsch/eslint-formatter-json-relative","tags":["javascript","eslint","eslint-formatter","eslintformatter"],"install":[{"cmd":"npm install eslint-formatter-json-relative","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-formatter-json-relative","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-formatter-json-relative","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The package is ESM-only; require() may fail depending on Node.js version and project configuration.","wrong":"const formatter = require('eslint-formatter-json-relative')","symbol":"default","correct":"import formatter from 'eslint-formatter-json-relative'"},{"note":"While the package is ESM, it may still be required if the project uses CommonJS, but this is not officially supported.","wrong":"import formatter from 'eslint-formatter-json-relative'","symbol":"formatter (CommonJS)","correct":"const formatter = require('eslint-formatter-json-relative')"},{"note":"No types are shipped; you may need to cast or use the ESLint type definitions.","wrong":"import formatter from 'eslint-formatter-json-relative'; // missing type import for Linter.Formatter","symbol":"default (with type assertion)","correct":"import type { Linter } from 'eslint';\nimport formatter from 'eslint-formatter-json-relative';"}],"quickstart":{"code":"// Install: npm i eslint-formatter-json-relative --save-dev\n// Use via ESLint CLI:\neslint -f json-relative ./src\n// Or programmatically in an ESLint plugin or script:\nimport formatter from 'eslint-formatter-json-relative';\nimport { ESLint } from 'eslint';\n\nconst eslint = new ESLint();\nconst results = await eslint.lintFiles(['./src']);\nconst output = formatter(results);\nconsole.log(output);","lang":"typescript","description":"Shows installation, CLI usage, and programmatic usage of the formatter, including how to get relative-path JSON output."},"warnings":[{"fix":"No action needed; this is expected behavior.","message":"The formatter only replaces absolute paths with relative ones; all other JSON structure is identical to the built-in JSON formatter.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Use import instead of require, or ensure your project is set up for ESM.","message":"The package is ESM-only; using require() may fail in some Node.js versions or configurations.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Use --format json with a post-processing script to convert absolute paths to relative.","message":"No updates since initial release; consider using ESLint's built-in JSON formatter and processing paths yourself.","severity":"deprecated","affected_versions":">=0.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 eslint-formatter-json-relative --save-dev` in the project root.","cause":"The package is not installed or is not in the current working directory's node_modules.","error":"Cannot find module 'eslint-formatter-json-relative'"},{"fix":"Use `eslint -f json-relative` after installing the package correctly.","cause":"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'.","error":"Error: Formatter 'json-relative' not found"},{"fix":"Use `import formatter from 'eslint-formatter-json-relative'` (default import) and ensure the package is installed.","cause":"Attempting to import the default export incorrectly, e.g., using a named import or importing from the wrong path.","error":"TypeError: formatter is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}