Registry / testing / stylelint-junit-formatter

stylelint-junit-formatter

JSON →
library0.2.2jsnpmunverified

A custom formatter for Stylelint that outputs JUnit XML reports, enabling integration with CI tools like CircleCI and Bamboo that natively parse JUnit XML. Current stable version is 0.2.2. The package converts Stylelint lint results into a JUnit XML structure with test suites per file and test cases per rule violation. It is a lightweight wrapper around Stylelint's formatter API, with no additional dependencies beyond Stylelint itself. It is a simple, focused utility with a single function.

npm install stylelint-junit-formatter
INSTALL
IMPORT
SIG · STYLELINT-JUNIT-FO
S
stylelint-junit-formatter
testingjavascriptv0.2.2
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 junitFormatter from 'stylelint-junit-formatter'
const { junitFormatter } = require('stylelint-junit-formatter')
The package exports a single function as default. CommonJS require works with default export; destructuring with named import fails.

Demonstrates using the stylelint-junit-formatter with Stylelint's Node API to lint CSS files and output JUnit XML.

const stylelint = require('stylelint'); const junitFormatter = require('stylelint-junit-formatter'); stylelint.lint({ files: 'src/**/*.css', formatter: junitFormatter }).then(result => { console.log(result.output); // prints JUnit XML string }).catch(err => { console.error(err); });
Debug
Known issues
gotchaThe formatter must be passed as 'formatter' option to stylelint.lint(), not as a string path. Using '--custom-formatter' in CLI works, but in Node API, provide the function directly.
fix
Use 'formatter: junitFormatter' (function) instead of 'formatter: 'stylelint-junit-formatter'' (string).
affects: >=0.0.0
gotchaThe package only outputs a single XML string; it does not write to a file. You must handle file writing yourself (e.g., fs.writeFileSync).
fix
Use 'fs.writeFileSync('report.xml', result.output)' after linting.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: junitFormatter is not a function
Incorrect import: destructuring a named export instead of using default import.
fix
Use 'const junitFormatter = require('stylelint-junit-formatter');' or 'import junitFormatter from 'stylelint-junit-formatter';'
Error: Cannot find module 'stylelint-junit-formatter'
Package not installed or not in node_modules.
fix
Run 'npm install stylelint-junit-formatter --save-dev'
Upgrade
Version history
0.2.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

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