Registry / testing / stylelint-formatter-pretty

stylelint-formatter-pretty

JSON →
library4.0.1jsnpmunverified

A pretty formatter for Stylelint that provides a clean, colorized output with clickable file links and rule IDs. Version 4.0.1 requires Node >=18.12.0 and Stylelint >=16.0.0. It is a stable, actively maintained package with weekly-committed updates. Compared to the default Stylelint formatter, it offers a more readable output, hyperlink support, and is designed for modern terminals. It is the Stylelint counterpart to eslint-formatter-pretty.

npm install stylelint-formatter-pretty
INSTALL
IMPORT
SIG · STYLELINT-FORMATTE
S
stylelint-formatter-pretty
testingjavascriptv4.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

default
import stylelintFormatter from 'stylelint-formatter-pretty';
const stylelintFormatter = require('stylelint-formatter-pretty');
The package is ESM-only (type: module) and does not provide a CommonJS export. Use import syntax.
stylelintFormatter
import stylelintFormatter from 'stylelint-formatter-pretty';
import { stylelintFormatter } from 'stylelint-formatter-pretty';
The package exports a single default function. Named destructuring will fail.
StylelintFormatter
import stylelintFormatter from 'stylelint-formatter-pretty';
import { StylelintFormatter } from 'stylelint-formatter-pretty';
There is no named export 'StylelintFormatter'. Use default import.

Demonstrates command-line usage with --custom-formatter and programmatic usage with stylelint.lint() and the imported formatter.

// Install: npm install --save-dev stylelint stylelint-formatter-pretty // Then run: // npx stylelint '**/*.css' --custom-formatter stylelint-formatter-pretty // Or use programmatically with a bundler or task runner: import stylelint from 'stylelint'; import stylelintFormatter from 'stylelint-formatter-pretty'; async function lint() { const result = await stylelint.lint({ files: 'src/**/*.css', formatter: stylelintFormatter, }); console.log(result.output); // formatted output } lint().catch(console.error);
Debug
Known issues
breakingVersion 4.0.0 dropped support for Node.js versions <18.12.0 and Stylelint versions <16.0.0.
fix
Upgrade Node.js to >=18.12.0 and Stylelint to >=16.0.0.
affects: >=4.0.0
breakingVersion 4.0.0 migrated to ESM only. CommonJS require() no longer works.
fix
Use import syntax or dynamic import() instead of require().
affects: >=4.0.0
gotchaThe package does not provide TypeScript type definitions. Users must supply their own types or use a declaration file.
fix
Add a declaration file: declare module 'stylelint-formatter-pretty';
affects: >=4.0.0
deprecatedUsing this formatter with grunt-stylelint or gulp-stylelint v1 may require additional configuration; the package's README shows legacy examples.
fix
Check the documentation for the task runner's current API. For programmatic use, pass the formatter as a function.
affects: >=4.0.0
gotchaThe output relies on terminal hyperlinks; not all terminals support clickable filenames or rule IDs.
fix
Use a terminal that supports hyperlinks (e.g., iTerm2, Hyper, Windows Terminal).
affects: >=1.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/stylelint-formatter-pretty/index.js from /path/to/yourfile.js not supported. Instead change the require of index.js to a dynamic import() which is available in all CommonJS modules.
Using require() on an ESM-only package.
fix
Change to import stylelintFormatter from 'stylelint-formatter-pretty'; or use dynamic import().
SyntaxError: Unexpected token 'export'
Trying to require the package in a CommonJS file without proper transpilation.
fix
Use import syntax or set type: module in your package.json.
TypeError: stylelintFormatter is not a function
Named destructured import instead of default import.
fix
Use import stylelintFormatter from 'stylelint-formatter-pretty'; (without curly braces).
error: unknown option '--custom-formatter'
Older Stylelint versions <16.0.0 do not support --custom-formatter.
fix
Use --formatter instead for Stylelint <16, or upgrade to Stylelint >=16.
Upgrade
Version history
4.0.1latest on npm
Audit
Dependencies
stylelintrequiredPeer dependency; this package is a formatter for Stylelint >=16
Agent activity
5 hits · last 30 days
node
4
Resources
stylelint-formatter-pretty — npm install stylelint-formatter-pretty · libregistry