Registry / testing / prettier-linter-helpers

prettier-linter-helpers

JSON →
library1.0.1jsnpmunverified

Utilities to help expose prettier output in linting tools. Version 1.0.1 provides two helper functions: showInvisibles and generateDifferences. Extracted from eslint-plugin-prettier v2.7.0, it is stable but rarely updated. Key differentiator: offers a shared, tested way to compute and display differences from prettier output, avoiding duplication across multiple linter integrations. Lightweight with no dependencies, but relies on prettier being installed separately.

npm install prettier-linter-helpers
INSTALL
IMPORT
SIG · PRETTIER-LINTER-HE
P
prettier-linter-helpers
testingjavascriptv1.0.1
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
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 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

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

showInvisibles
✓ import { showInvisibles } from 'prettier-linter-helpers'
✗ const showInvisibles = require('prettier-linter-helpers').showInvisibles
ESM import works in Node >=12; CommonJS require also works as package supports both.
generateDifferences
✓ import { generateDifferences } from 'prettier-linter-helpers'
✗ import generateDifferences from 'prettier-linter-helpers'
This is a named export, not default. CommonJS: const { generateDifferences } = require('prettier-linter-helpers').
package
✓ import * as helpers from 'prettier-linter-helpers'
✗ const helpers = require('prettier-linter-helpers'); helpers.default.showInvisibles
There is no default export; use namespace import if you want both.
types
✓ import type { Difference } from 'prettier-linter-helpers'
TypeScript types are included; 'Difference' is the type of items in the array returned by generateDifferences.

Imports the two helper functions, shows use of showInvisibles to make whitespace visible, and generateDifferences to compare two strings.

import { showInvisibles, generateDifferences } from 'prettier-linter-helpers'; const source = 'const x = 1;\n'; const prettierSource = 'const x = 1;\n'; // Show invisible characters (tab, space, newline) const visible = showInvisibles(source); console.log(visible); // 'const x = 1;·\n' // Generate differences between source and prettierSource const diffs = generateDifferences(source, prettierSource); console.log(diffs); // [] // Example with a difference const source2 = 'const x = 1'; const prettierSource2 = 'const x = 1;\n'; const diffs2 = generateDifferences(source2, prettierSource2); console.log(diffs2); // [ { offset: 11, operation: 'insert', insertText: ';\n' } ]
Debug
Known issues
gotchagenerateDifferences returns an array of difference objects that are not deeply immutable; do not mutate them.
fix
Treat the returned differences as read-only; copy if modification needed.
affects: <=1.0.1
deprecatedPackage is in maintenance mode; no new features are planned.
fix
Consider directly using prettier's own diffing utilities if more advanced features are needed.
affects: >=1.0.0
gotchashowInvisibles is intended for display purposes only; do not use it for programmatic string manipulation.
fix
Use the original string for any logic; showInvisibles changes characters (e.g., space to ·).
affects: <=1.0.1
Errors
Common errors & fixes
TypeError: (0 , prettier_linter_helpers.showInvisibles) is not a function
Using CommonJS require incorrectly with ES module bundlers like Webpack.
fix
Change to: import { showInvisibles } from 'prettier-linter-helpers'
Module not found: Can't resolve 'prettier-linter-helpers'
Package not installed or not in node_modules.
fix
Run: npm install prettier-linter-helpers
Cannot read property 'showInvisibles' of undefined
Attempting to access a named export as a property of the default export.
fix
Use named import: import { showInvisibles } from 'prettier-linter-helpers'
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
prettier-linter-helpers — npm install prettier-linter-helpers · libregistry