{"id":20463,"library":"prettier-stylelint-formatter","title":"prettier-stylelint-formatter","description":"A tool that formats CSS/SCSS/Less style files by running Prettier then stylelint --fix in sequence. It auto-generates a Prettier config from a stylelint config and disables conflicting rules. Stable version 0.5.1-beta.2 is a pre-release fork of prettier-stylelint by hugomrdias. It provides both a CLI and API, supports glob patterns, stdin, and respects .gitignore/.prettierignore. Compared to alternatives like prettier-eslint, this package focuses on style files (CSS, SCSS, Less, SSS) and integrates with stylelint.","status":"active","version":"0.5.1-beta.2","language":"javascript","source_language":"en","source_url":"https://github.com/ismail-syed/prettier-stylelint-formatter","tags":["javascript","stylelint","prettier","style","lint","linter","validate","code style","strict"],"install":[{"cmd":"npm install prettier-stylelint-formatter","lang":"bash","label":"npm"},{"cmd":"yarn add prettier-stylelint-formatter","lang":"bash","label":"yarn"},{"cmd":"pnpm add prettier-stylelint-formatter","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core formatting engine","package":"prettier","optional":false},{"reason":"Linting and fixing after Prettier","package":"stylelint","optional":false},{"reason":"Forked package providing mergeConfigs logic","package":"prettier-stylelint","optional":false}],"imports":[{"note":"The package is CommonJS-only; named export 'format' via module.exports.","wrong":"import format from 'prettier-stylelint-formatter'","symbol":"format","correct":"const format = require('prettier-stylelint-formatter')"},{"note":"TypeScript users: no @types package; default import is the format function.","wrong":"","symbol":"PrettierStylelintFormatter (default import type)","correct":"import prettierStylelint from 'prettier-stylelint-formatter'"},{"note":"There is no --fix flag; use --write to edit files in place.","wrong":"prettier-stylelint --fix","symbol":"CLI usage","correct":"npx prettier-stylelint --write \"**/*.css\""}],"quickstart":{"code":"// Install: npm install prettier-stylelint-formatter --save-dev\n\n// API example\nconst format = require('prettier-stylelint-formatter');\nconst sourceCode = 'a[id=\"foo\"] { content: \"x\"; }';\nconst options = {\n  text: sourceCode,\n  // Optional: specify a stylelint config file path\n  // config: '/path/to/.stylelintrc'\n};\nconst formatted = format(options);\nconsole.log(formatted);\n// Output: a[id='foo'] {\n//     content: 'x';\n// }\n\n// CLI: npx prettier-stylelint --write \"src/**/*.css\"","lang":"javascript","description":"Demonstrates basic usage of the format API to lint and fix a CSS string, and the CLI command to process files."},"warnings":[{"fix":"Pin to a specific version or wait for stable release.","message":"Version 0.5.1-beta.2 is a beta release; API and CLI may have breaking changes before stable release.","severity":"breaking","affected_versions":"0.5.1-beta.*"},{"fix":"Consider using stylelint-prettier or prettier-stylelint-recommended instead.","message":"The package is a fork of the deprecated prettier-stylelint; the original is no longer maintained.","severity":"deprecated","affected_versions":">=0.5.0"},{"fix":"Always run `git commit` before using --write, or use --stdin with output redirection.","message":"The CLI --write flag overwrites files in place; it is recommended to commit changes before running.","severity":"gotcha","affected_versions":">=0.5.0"},{"fix":"Manually validate the merged config by running stylelint separately.","message":"The config merge logic may not respect all stylelint config structures (e.g., plugins, processors).","severity":"gotcha","affected_versions":">=0.5.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run `npm install prettier-stylelint-formatter --save-dev` or `yarn add prettier-stylelint-formatter -D`.","cause":"Package is not installed or not in node_modules.","error":"Cannot find module 'prettier-stylelint-formatter'"},{"fix":"Use require: `const format = require('prettier-stylelint-formatter')`.","cause":"Using ES import syntax on a CommonJS module with a default export that is the function.","error":"TypeError: format is not a function"},{"fix":"Upgrade Node.js to >=14.0.0 or use a transpiler.","cause":"The package may use optional chaining not supported in older Node.js versions.","error":"SyntaxError: Unexpected token '?'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}