Registry / testing / prettier-stylelint

prettier-stylelint

JSON →
library0.4.2jsnpmunverified

prettier-stylelint (v0.4.2) is a tool that formats CSS/SCSS/Less files by first running Prettier and then stylelint --fix, using a generated Prettier config derived from your stylelint config. It aims to produce formatted code that also passes stylelint rules, eliminating the need for manual alignment. The package includes a stylelint config that disables conflicting rules. It should be considered experimental and unmaintained; the last release was in 2018. Key differentiators from alternatives like stylelint-prettier or Prettier's own stylelint plugin: it generates Prettier config from stylelint rules, whereas modern approaches typically use stylelint-config-prettier or run Prettier before stylelint. The project has not seen updates for 6+ years, and the API example shows a mistake (using prettier-eslint instead of prettier-stylelint). Not recommended for new projects.

npm install prettier-stylelint
INSTALL
IMPORT
SIG · PRETTIER-STYLELINT
P
prettier-stylelint
testingjavascriptv0.4.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

default
const format = require('prettier-stylelint')
import format from 'prettier-stylelint'
Package is CommonJS-only; no ESM exports. The default export is a function that takes an options object.
format
const format = require('prettier-stylelint')
const { format } = require('prettier-stylelint')
The default export is the format function; there is no named export 'format'.
config
require('prettier-stylelint/config')
import 'prettier-stylelint/config'
The config file is a CommonJS module that exports a stylelint config object. It must be required (or imported with a bundler that supports CJS).

Demonstrates usage with stylelint config extension and the JavaScript API.

// Install: npm install prettier-stylelint --save-dev // In your stylelint config (.stylelintrc or package.json) { "extends": [ "./node_modules/prettier-stylelint/config.js" ], "rules": { "indentation": 4, "string-quotes": "single" } } // Then run CLI: // npx prettier-stylelint --write "src/**/*.css" // Or use the API: const format = require('prettier-stylelint'); const sourceCode = 'a[id="foo"] { content: "x"; }'; const options = { text: sourceCode }; const formatted = format(options); console.log(formatted); // Output: // a[id='foo'] { // content: 'x'; // }
prettier-stylelint --version
Debug
Known issues
gotchaThe API example in the README imports 'prettier-eslint' instead of 'prettier-stylelint', which is incorrect and will cause a runtime error.
fix
Use require('prettier-stylelint') as shown in the quickstart.
affects: <=0.4.2
breakingPackage is EOL: no updates since 2018, repository archived, and the generating Prettier config from stylelint rules approach is superseded by modern solutions.
fix
Migrate to stylelint-prettier or stylelint-config-prettier combined with Prettier directly.
affects: all
deprecatedThe package relies on deprecated Prettier API v1.x; may not work with Prettier v2+ or stylelint v14+.
fix
Do not use; consider alternatives.
affects: all
gotchaCLI uses default glob `**/*.{css,scss,less,sss}` but may omit common files like .styl or .sass if not included.
fix
Explicitly specify file patterns if needed.
affects: all
Errors
Common errors & fixes
TypeError: format is not a function
Importing package incorrectly (e.g., using named import or non-CJS).
fix
Use `const format = require('prettier-stylelint');`
Cannot find module 'prettier-stylelint/config'
Relative path in stylelint extends is wrong or module not installed.
fix
Ensure package is installed and use `./node_modules/prettier-stylelint/config.js` or the correct path relative to your config.
prettier-stylelint: error: unknown option `--stdin'
Possibly using a very old version (pre-0.3) where --stdin was not supported.
fix
Update to 0.4.2 or use pipe: `echo 'css' | prettier-stylelint`
Upgrade
Version history
0.4.2latest on npm
Audit
Dependencies
prettierrequiredUsed for initial formatting
stylelintrequiredUsed for linting and fixing after Prettier
Agent activity
6 hits · last 30 days
node
6
Resources
prettier-stylelint — npm install prettier-stylelint · libregistry