{"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,"search_vec":"'1.0.1':15 'across':53 'avoid':51 'comput':44 'depend':60 'differ':47 'differenti':37 'display':46 'duplic':52 'eslint':26 'eslint-plugin-pretti':25 'expos':8 'extract':23 'function':19 'generatediffer':22 'help':7 'helper':4,18 'instal':66 'integr':56 'javascript':68 'key':36 'lightweight':57 'lint':12 'linter':3,55 'multipl':54 'offer':38 'output':10,50 'plugin':27 'prettier':2,9,28,49,64 'prettier-linter-help':1 'provid':16 'rare':34 'reli':62 'separ':67 'share':40 'showinvis':20 'stabl':32 'test':41 'tool':13 'two':17 'typescript':69 'updat':35 'util':5 'v2.7.0':29 'version':14 'way':42","created_at":"2026-04-25T11:22:30.526303+00:00","updated_at":"2026-04-25T11:22:30.526303+00:00","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,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/prettier/prettier-linter-helpers","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/prettier-linter-helpers","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-24","install_tag":null}}