Registry / testing / stylelint-codeframe-formatter

stylelint-codeframe-formatter

JSON →
library1.2.0jsnpmunverified

A custom formatter for Stylelint that displays lint results with a babel-code-frame, showing the exact source code where errors/warnings occur, along with filenames and line:column references for clickable navigation. Current stable version 1.2.0 (released 2023-06). Maintained as a minor/major update cycle; last release fixes CSS syntax error display. Key differentiator: provides inline code context unlike Stylelint's built-in formatters, helping developers quickly locate issues. Requires Stylelint as a peer dependency.

npm install stylelint-codeframe-formatter
INSTALL
IMPORT
SIG · STYLELINT-CODEFRAM
S
stylelint-codeframe-formatter
testingjavascriptv1.2.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

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

default
✓ import formatter from 'stylelint-codeframe-formatter'
✗ const { default: formatter } = require('stylelint-codeframe-formatter')
ESM default export; CommonJS users can use require('stylelint-codeframe-formatter') directly, but this is the ESM way.
formatter
✓ const formatter = require('stylelint-codeframe-formatter')
✗ const formatter = require('stylelint-codeframe-formatter').default
CommonJS require returns the default export directly; do not access .default in CJS.
formatter as default import in TypeScript
✓ import formatter from 'stylelint-codeframe-formatter'
✗ import * as formatter from 'stylelint-codeframe-formatter'
TypeScript uses default import; namespace import may cause runtime issues.

Demonstrates installing the formatter, using it via Stylelint CLI, and integrating programmatically with lint results.

// Install: npm install stylelint stylelint-codeframe-formatter --save-dev // Use with Stylelint CLI: // stylelint --custom-formatter node_modules/stylelint-codeframe-formatter/index.js "src/**/*.css" // Or programmatically (ESM): import formatter from 'stylelint-codeframe-formatter'; import stylelint from 'stylelint'; const result = await stylelint.lint({ files: 'src/**/*.css', formatter: formatter, }); console.log(result.output);
Debug
Known issues
gotchaThe formatter may show 'undefined' for rule name when the message duplicates the rule name (fixed in v1.2.0).
fix
Upgrade to >=1.2.0
affects: <1.2.0
breakingv1.0.6 fixed an issue with empty stylelint results; earlier versions could crash.
fix
Upgrade to >=1.0.6
affects: <1.0.6
deprecatedThe package uses babel-code-frame; babel-code-frame is deprecated in favor of @babel/code-frame (upgraded in v1.0.5).
fix
Upgrade to >=1.0.5
affects: <1.0.5
gotchaWhen using with stylelint-webpack-plugin, ensure the formatter is required correctly: formatter: require('stylelint-codeframe-formatter') (not the path).
fix
Use require('stylelint-codeframe-formatter') in the plugin options
affects: all
Errors
Common errors & fixes
Error: Cannot find module 'stylelint-codeframe-formatter'
Package not installed or not in node_modules.
fix
Run: npm install stylelint-codeframe-formatter --save-dev
The constructor must be a function that returns an object or the formatter expects to be a function
Using namespace import (import * as) instead of default import in ESM.
fix
Use: import formatter from 'stylelint-codeframe-formatter'
stylelint-codeframe-formatter: Failed to display codeframe: Cannot read property 'type' of null
Issue with empty result or malformed node (fixed in v1.0.6).
fix
Upgrade to >=1.0.6
Upgrade
Version history
1.2.0latest on npm
Audit
Dependencies
stylelintrequiredPeer dependency required to format lint results; the formatter receives data from Stylelint.
Agent activity
14 hits · last 30 days
node
10
Amazon
1
Resources
stylelint-codeframe-formatter — npm install stylelint-codeframe-formatter · libregistry