Registry / testing / checkstyle-formatter

checkstyle-formatter

JSON →
library1.1.0jsnpmunverified

checkstyle-formatter is a simple Node.js library for formatting lint results into Checkstyle XML (version 4.3). The current stable version is 1.1.0, with a low release cadence (minor updates as needed). It takes an array of file/message objects and outputs an XML string. Unlike full-featured reporters (e.g., eslint formatters), it leaves reporting details to the user and has zero dependencies. Supports optional 'source' information since v1.1.0. MIT licensed.

npm install checkstyle-formatter
INSTALL
IMPORT
SIG · CHECKSTYLE-FORMATT
C
checkstyle-formatter
testingjavascriptv1.1.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 checkstyleFormatter from 'checkstyle-formatter'
const checkstyleFormatter = require('checkstyle-formatter')
Package does not ship TypeScript types; uses CommonJS internally but ESM imports work in Node 14+ via package.json 'exports' field.
default
const checkstyleFormatter = require('checkstyle-formatter')
const { checkstyleFormatter } = require('checkstyle-formatter')
The module exports a single function as default, not a named export.
default
import checkstyleFormatter from 'checkstyle-formatter'
import { checkstyleFormatter } from 'checkstyle-formatter'
Named import will fail because there is no named export 'checkstyleFormatter'.

Formats two files with lint messages into Checkstyle XML output.

const checkstyleFormatter = require('checkstyle-formatter'); const results = [ { filename: 'foo.js', messages: [ { line: 1, column: 2, severity: 'warning', message: 'the quick' }, { line: 3, column: 4, severity: 'error', message: 'brown fox' } ] }, { filename: 'bar.js', messages: [ { line: 5, column: 6, severity: 'warning', message: 'jumped over' }, { line: 7, column: 8, severity: 'error', message: 'the lazy dog' } ] } ]; console.log(checkstyleFormatter(results));
Debug
Known issues
breakingv1.0.0 removed the old undocumented custom XML template feature.
fix
Migrate to using the standard results array format described in the README.
affects: <1.0.0
deprecatedThe optional 'source' property in v1.1.0 is undocumented in v1.0.0 and may change.
fix
Upgrade to v1.1.0 if you need 'source' support.
affects: 1.0.0
gotchaThe function always generates an XML version declaration with encoding="utf-8". This cannot be customized.
fix
If you need different XML declaration, post-process the output string.
affects: >=1.0.0
gotchaSeverity values must be lowercase ('warning' or 'error'); uppercase will not validate against checkstyle schema.
fix
Ensure severity is lowercase: 'warning' or 'error'.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: checkstyleFormatter is not a function
Importing named export instead of default.
fix
Use `const checkstyleFormatter = require('checkstyle-formatter');` or `import checkstyleFormatter from 'checkstyle-formatter';`
SyntaxError: Unexpected token 'export'
Using ESM imports in a CommonJS environment without enabling ESM.
fix
Add `"type": "module"` to package.json or use `.mjs` extension, or switch to `require`.
XML parsing error: Content is not allowed in prolog
The output includes a BOM or has extra whitespace before XML declaration.
fix
Ensure you are not prepending any characters to the returned string.
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
14 hits · last 30 days
node
12
OpenAI (training)
1
Resources
checkstyle-formatter — npm install checkstyle-formatter · libregistry