Registry / testing / stylelint-sarif-formatter

stylelint-sarif-formatter

JSON →
library1.0.7jsnpmunverified

A custom formatter for stylelint that outputs lint results in SARIF (Static Analysis Results Interchange Format). Current version 1.0.7. This package has no release cadence as it is a small utility. Key differentiator: enables integration with SARIF-compatible tools like GitHub Advanced Security and Microsoft SARIF viewers, unlike built-in stylelint formatters which output JSON or verbose text.

npm install stylelint-sarif-formatter
INSTALL
IMPORT
SIG · STYLELINT-SARIF-FO
S
stylelint-sarif-formatter
testingjavascriptv1.0.7
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-sarif-formatter'
const formatter = require('stylelint-sarif-formatter')
Package exports a single function; require() works in CommonJS, but named import preferred for ESM.
formatter
import formatter from 'stylelint-sarif-formatter'
import { formatter } from 'stylelint-sarif-formatter'
Default export only; named import will fail.
stylelint
stylelint --custom-formatter=node_modules/stylelint-sarif-formatter
stylelint --formatter=stylelint-sarif-formatter
Must use --custom-formatter and specify path to the module. Built-in formatters use --formatter with a name.

Shows how to run stylelint with the SARIF formatter via command line or programmatically using child_process.

// Install // yarn add stylelint-sarif-formatter // Run stylelint with custom formatter // Output to console or file const stylelint = require('stylelint'); const { execSync } = require('child_process'); const result = execSync('stylelint "**/*.css" --custom-formatter=node_modules/stylelint-sarif-formatter', { encoding: 'utf8' }); console.log(result); // To save to file: // stylelint "**/*.css" --custom-formatter=node_modules/stylelint-sarif-formatter -o output.sarif
Debug
Known issues
gotchaMust use absolute or relative path to the formatter module; stylelint resolves --custom-formatter relative to current working directory.
fix
Use --custom-formatter=./node_modules/stylelint-sarif-formatter or full path.
affects: >=1.0.0
gotchaOutput file via -o flag does not work with --custom-formatter; use shell redirection instead.
fix
Use stylelint ... --custom-formatter=... > output.sarif
affects: >=1.0.0
gotchaStylelint version compatibility: Ensure stylelint >=14.0.0; older versions may not support custom formatters correctly.
fix
Upgrade stylelint to at least 14.0.0.
affects: >=1.0.0
gotchaThe SARIF output filename must end with .sarif; some tools require the file extension.
fix
Name the output file with .sarif extension.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'stylelint-sarif-formatter'
The module is not installed or the path in --custom-formatter is incorrect.
fix
Run `yarn add stylelint-sarif-formatter` or `npm install stylelint-sarif-formatter` and use correct path: `--custom-formatter=./node_modules/stylelint-sarif-formatter`.
TypeError: formatter is not a function
Trying to import a named export instead of default export.
fix
Use default import: `import formatter from 'stylelint-sarif-formatter'` or `const formatter = require('stylelint-sarif-formatter')`.
Warning: The --custom-formatter option is not supported by this version of stylelint
Stylelint version is too old (<14.0.0).
fix
Upgrade stylelint to version 14 or later.
Upgrade
Version history
1.0.7latest on npm
Audit
Dependencies
stylelintrequiredPeer dependency; the formatter is invoked by stylelint's --custom-formatter option
Agent activity
5 hits · last 30 days
node
4
Resources
stylelint-sarif-formatter — npm install stylelint-sarif-formatter · libregistry