Registry / devops / eslint-clang-formatter

eslint-clang-formatter

JSON →
library1.3.0jsnpmunverified

A formatter for ESLint that provides output similar to clang's error format. Version 1.3.0 is the latest stable release. Includes colorized output, configurable colors via .clangformatterrc or programmatic config, and obeys ESLint's --no-color flag. It differentiates from default ESLint formatters by offering more informative file/location/error/message layout and customizable chalk-based colors. Suitable for developers who prefer clang-style error reporting.

npm install eslint-clang-formatter
INSTALL
IMPORT
SIG · ESLINT-CLANG-FORMA
E
eslint-clang-formatter
devopsjavascriptv1.3.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
const formatter = require('eslint-clang-formatter');
import formatter from 'eslint-clang-formatter'; // ESM not supported; package uses CommonJS
Package only provides CommonJS; CJS require is the only way. No named exports.
config
const formatter = require('eslint-clang-formatter'); formatter(results, { clangFormatter: { colors: { file: 'green' } } });
Config object must have a 'clangFormatter' property containing formatter config.

Demonstrates programmatic usage with custom colors and options.

const eslint = require('eslint'); const cli = new eslint.CLIEngine(); const formatter = cli.getFormatter('node_modules/eslint-clang-formatter'); const report = cli.executeOnFiles(['src/**/*.js']); const output = formatter(report.results, { clangFormatter: { colorize: true, colors: { file: 'cyan', error: 'red.bold', warning: 'yellow.bold' }, showRule: true } }); console.log(output);
Debug
Known issues
gotchaConfig object must be wrapped in a `clangFormatter` property when passed programmatically.
fix
Pass an object like { clangFormatter: { colors: {...} } } instead of just { colors: {...} }.
affects: >=1.0.0
breakingIn version 1.0.0, the `.clangformatterrc` file format changed from a flat config to having a `clangFormatter` key.
fix
Ensure your `.clangformatterrc` file has `clangFormatter` as top-level key, e.g., {"clangFormatter":{"colorize":true}}
affects: >=1.0.0 <2.0.0
gotchaThe formatter does not support ESM import; using import will fail.
fix
Use `require('eslint-clang-formatter')` instead.
affects: >=1.0.0
gotchaWhen using with gulp-eslint, the formatter path must include 'node_modules/' prefix.
fix
Pass 'node_modules/eslint-clang-formatter' as the formatter name.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'eslint-clang-formatter'
Formetter path not correctly specified or module not installed.
fix
Ensure the package is installed: `npm install eslint-clang-formatter` and specify path as `node_modules/eslint-clang-formatter` or use the module name directly when using CLIEngine.getFormatter.
Expected results object but got undefined
Calling formatter with no arguments or invalid results object.
fix
Formetter expects first argument to be an ESLint results array (e.g., from CLIEngine.executeOnFiles). Ensure you pass `report.results`.
Cannot read property 'clangFormatter' of undefined
Config object passed without the `clangFormatter` wrapper key.
fix
Wrap your config inside `{ clangFormatter: { ... } }`.
Upgrade
Version history
1.3.0latest on npm
Audit
Dependencies
chalkrequiredUsed for colorizing output
Agent activity
4 hits · last 30 days
node
4
Resources
eslint-clang-formatter — npm install eslint-clang-formatter · libregistry