Registry / testing / eslint-formatting-reporter

eslint-formatting-reporter

JSON →
library0.0.0jsnpmunverified

A utility library for ESLint plugins that report formatting differences between original and formatted code. Version 0.0.0, actively maintained by Anthony Fu. Extracted from eslint-plugin-prettier, it provides `reportDifferences` function and `messages` object to simplify creating custom formatting rules. Ships TypeScript types, peer dependency on ESLint >=8.40.0. Lightweight alternative to directly using prettier-linter-helpers.

npm install eslint-formatting-reporter
INSTALL
IMPORT
SIG · ESLINT-FORMATTING-
E
eslint-formatting-reporter
testingjavascriptv0.0.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.

reportDifferences
import { reportDifferences } from 'eslint-formatting-reporter'
const { reportDifferences } = require('eslint-formatting-reporter')
ESM-only; CommonJS require will not work this package is ESM.
messages
import { messages } from 'eslint-formatting-reporter'
Used for ESLint rule meta.messages.
Rule
import type { Rule } from 'eslint'
import { Rule } from 'eslint-formatting-reporter'
Rule type is from eslint, not this package.

Creates a custom ESLint rule that reports formatting differences using reportDifferences.

import { messages, reportDifferences } from 'eslint-formatting-reporter'; import type { Rule } from 'eslint'; export default <Rule.RuleModule>{ meta: { type: 'layout', fixable: 'whitespace', messages }, create(context) { return { Program() { const source = context.source.text; const formatted = source.replace(/\s+$/, ''); // example formatter reportDifferences(context, source, formatted); } }; } };
Debug
Known issues
gotchareportDifferences requires context.source.text. In older ESLint versions, use context.getSourceCode().getText().
fix
Use context.source.text for ESLint 8.40+; for older versions, upgrade or pass source code manually.
affects: >=0.0.0
gotchaPackage is ESM-only. Using require() will fail with ERR_REQUIRE_ESM.
fix
Use import syntax or dynamic import().
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module 'eslint-formatting-reporter'
Package not installed or incorrect import path.
fix
npm install eslint-formatting-reporter
ERR_REQUIRE_ESM
Using require() for an ESM-only package.
fix
Change to import { reportDifferences } from 'eslint-formatting-reporter'
Upgrade
Version history
0.0.0latest on npm
Audit
Dependencies
eslintrequiredpeer dependency required for ESLint rule context
Agent activity
2 hits · last 30 days
node
2
Resources
eslint-formatting-reporter — npm install eslint-formatting-reporter · libregistry