Registry / testing / stylelint-formatter-stats

stylelint-formatter-stats

JSON →
library0.4.0jsnpmunverified

A custom formatter for Stylelint that aggregates distribution of errors and warnings. Version 0.4.0 is the latest stable release. This tool is particularly useful when introducing Stylelint to legacy projects. It summarizes the number of occurrences per rule, helping prioritize fixes. The package has no notable dependencies aside from Stylelint itself.

npm install stylelint-formatter-stats
INSTALL
IMPORT
SIG · STYLELINT-FORMATTE
S
stylelint-formatter-stats
testingjavascriptv0.4.0
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 formatter from 'stylelint-formatter-stats'
There is no named export; the default export is a function that can be used as a custom formatter.
formatter
const formatter = require('stylelint-formatter-stats')
const { formatter } = require('stylelint-formatter-stats')
CommonJS require returns the formatter function directly, not as a named property.
formatter (via --custom-formatter)
stylelint "*.css" --custom-formatter=node_modules/stylelint-formatter-stats
stylelint "*.css" --custom-formatter=stylelint-formatter-stats
The path must point to the package entry file; relative paths like 'node_modules/...' work.

Shows both Node.js API usage and CLI invocation to output aggregated error statistics.

// 1. Install the package and stylelint if not already installed // npm install --save-dev stylelint stylelint-formatter-stats // 2. Run stylelint with the custom formatter // In a script: const stylelint = require('stylelint'); const formatter = require('stylelint-formatter-stats'); stylelint.lint({ files: '*.css', formatter: formatter }).then(result => { console.log(result.output); }).catch(err => { console.error(err); }); // Alternatively, via CLI: // stylelint "*.css" --custom-formatter=node_modules/stylelint-formatter-stats
Debug
Known issues
gotchaThe formatter must be used with Stylelint's --custom-formatter option, not the standard --formatter.
fix
Use --custom-formatter instead of --formatter in the CLI.
affects: >=0.1.0
gotchaThe path to the formatter may differ if installed globally or with npm workspaces.
fix
Ensure the path resolves to the package's main file, e.g., node_modules/stylelint-formatter-stats/index.js
affects: >=0.1.0
gotchaOutput is purely textual, no JSON or other machine-readable format.
fix
If you need JSON output, consider writing a custom formatter or piping the text output.
affects: >=0.1.0
Errors
Common errors & fixes
Error: Cannot find module 'stylelint-formatter-stats'
The package is not installed or the path is incorrect.
fix
Run 'npm install stylelint-formatter-stats' and ensure the path in --custom-formatter is correct.
TypeError: formatter is not a function
The imported value is not a function; may have mismatched import/require.
fix
Use const formatter = require('stylelint-formatter-stats'); do not destructure.
The --custom-formatter flag does not appear to be supported by this version of Stylelint.
The installed Stylelint version does not support --custom-formatter (introduced in Stylelint v9).
fix
Upgrade Stylelint to v9 or later, or use the Node API with formatter option.
Upgrade
Version history
0.4.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
Resources
stylelint-formatter-stats — npm install stylelint-formatter-stats · libregistry