{"id":20324,"library":"prettier-linter-helpers","title":"prettier-linter-helpers","description":"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.","status":"maintenance","version":"1.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/prettier/prettier-linter-helpers","tags":["javascript","typescript"],"install":[{"cmd":"npm install prettier-linter-helpers","lang":"bash","label":"npm"},{"cmd":"yarn add prettier-linter-helpers","lang":"bash","label":"yarn"},{"cmd":"pnpm add prettier-linter-helpers","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM import works in Node >=12; CommonJS require also works as package supports both.","wrong":"const showInvisibles = require('prettier-linter-helpers').showInvisibles","symbol":"showInvisibles","correct":"import { showInvisibles } from 'prettier-linter-helpers'"},{"note":"This is a named export, not default. CommonJS: const { generateDifferences } = require('prettier-linter-helpers').","wrong":"import generateDifferences from 'prettier-linter-helpers'","symbol":"generateDifferences","correct":"import { generateDifferences } from 'prettier-linter-helpers'"},{"note":"There is no default export; use namespace import if you want both.","wrong":"const helpers = require('prettier-linter-helpers'); helpers.default.showInvisibles","symbol":"package","correct":"import * as helpers from 'prettier-linter-helpers'"},{"note":"TypeScript types are included; 'Difference' is the type of items in the array returned by generateDifferences.","wrong":"","symbol":"types","correct":"import type { Difference } from 'prettier-linter-helpers'"}],"quickstart":{"code":"import { showInvisibles, generateDifferences } from 'prettier-linter-helpers';\n\nconst source = 'const x = 1;\\n';\nconst prettierSource = 'const x = 1;\\n';\n\n// Show invisible characters (tab, space, newline)\nconst visible = showInvisibles(source);\nconsole.log(visible);\n// 'const x = 1;·\\n'\n\n// Generate differences between source and prettierSource\nconst diffs = generateDifferences(source, prettierSource);\nconsole.log(diffs);\n// []\n\n// Example with a difference\nconst source2 = 'const x = 1';\nconst prettierSource2 = 'const x = 1;\\n';\nconst diffs2 = generateDifferences(source2, prettierSource2);\nconsole.log(diffs2);\n// [ { offset: 11, operation: 'insert', insertText: ';\\n' } ]\n","lang":"typescript","description":"Imports the two helper functions, shows use of showInvisibles to make whitespace visible, and generateDifferences to compare two strings."},"warnings":[{"fix":"Treat the returned differences as read-only; copy if modification needed.","message":"generateDifferences returns an array of difference objects that are not deeply immutable; do not mutate them.","severity":"gotcha","affected_versions":"<=1.0.1"},{"fix":"Consider directly using prettier's own diffing utilities if more advanced features are needed.","message":"Package is in maintenance mode; no new features are planned.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Use the original string for any logic; showInvisibles changes characters (e.g., space to ·).","message":"showInvisibles is intended for display purposes only; do not use it for programmatic string manipulation.","severity":"gotcha","affected_versions":"<=1.0.1"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Change to: import { showInvisibles } from 'prettier-linter-helpers'","cause":"Using CommonJS require incorrectly with ES module bundlers like Webpack.","error":"TypeError: (0 , prettier_linter_helpers.showInvisibles) is not a function"},{"fix":"Run: npm install prettier-linter-helpers","cause":"Package not installed or not in node_modules.","error":"Module not found: Can't resolve 'prettier-linter-helpers'"},{"fix":"Use named import: import { showInvisibles } from 'prettier-linter-helpers'","cause":"Attempting to access a named export as a property of the default export.","error":"Cannot read property 'showInvisibles' of undefined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}