{"id":20462,"library":"prettier-stylelint","title":"prettier-stylelint","description":"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.","status":"abandoned","version":"0.4.2","language":"javascript","source_language":"en","source_url":"https://github.com/hugomrdias/prettier-stylelint","tags":["javascript","stylelint","prettier","style","lint","linter","validate","code style","strict"],"install":[{"cmd":"npm install prettier-stylelint","lang":"bash","label":"npm"},{"cmd":"yarn add prettier-stylelint","lang":"bash","label":"yarn"},{"cmd":"pnpm add prettier-stylelint","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used for initial formatting","package":"prettier","optional":false},{"reason":"Used for linting and fixing after Prettier","package":"stylelint","optional":false}],"imports":[{"note":"Package is CommonJS-only; no ESM exports. The default export is a function that takes an options object.","wrong":"import format from 'prettier-stylelint'","symbol":"default","correct":"const format = require('prettier-stylelint')"},{"note":"The default export is the format function; there is no named export 'format'.","wrong":"const { format } = require('prettier-stylelint')","symbol":"format","correct":"const format = require('prettier-stylelint')"},{"note":"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).","wrong":"import 'prettier-stylelint/config'","symbol":"config","correct":"require('prettier-stylelint/config')"}],"quickstart":{"code":"// Install: npm install prettier-stylelint --save-dev\n\n// In your stylelint config (.stylelintrc or package.json)\n{\n  \"extends\": [\n    \"./node_modules/prettier-stylelint/config.js\"\n  ],\n  \"rules\": {\n    \"indentation\": 4,\n    \"string-quotes\": \"single\"\n  }\n}\n\n// Then run CLI:\n// npx prettier-stylelint --write \"src/**/*.css\"\n\n// Or use the API:\nconst format = require('prettier-stylelint');\nconst sourceCode = 'a[id=\"foo\"] { content: \"x\"; }';\nconst options = {\n  text: sourceCode\n};\nconst formatted = format(options);\nconsole.log(formatted);\n// Output:\n// a[id='foo'] {\n//     content: 'x';\n// }","lang":"javascript","description":"Demonstrates usage with stylelint config extension and the JavaScript API."},"warnings":[{"fix":"Use require('prettier-stylelint') as shown in the quickstart.","message":"The API example in the README imports 'prettier-eslint' instead of 'prettier-stylelint', which is incorrect and will cause a runtime error.","severity":"gotcha","affected_versions":"<=0.4.2"},{"fix":"Migrate to stylelint-prettier or stylelint-config-prettier combined with Prettier directly.","message":"Package is EOL: no updates since 2018, repository archived, and the generating Prettier config from stylelint rules approach is superseded by modern solutions.","severity":"breaking","affected_versions":"all"},{"fix":"Do not use; consider alternatives.","message":"The package relies on deprecated Prettier API v1.x; may not work with Prettier v2+ or stylelint v14+.","severity":"deprecated","affected_versions":"all"},{"fix":"Explicitly specify file patterns if needed.","message":"CLI uses default glob `**/*.{css,scss,less,sss}` but may omit common files like .styl or .sass if not included.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use `const format = require('prettier-stylelint');`","cause":"Importing package incorrectly (e.g., using named import or non-CJS).","error":"TypeError: format is not a function"},{"fix":"Ensure package is installed and use `./node_modules/prettier-stylelint/config.js` or the correct path relative to your config.","cause":"Relative path in stylelint extends is wrong or module not installed.","error":"Cannot find module 'prettier-stylelint/config'"},{"fix":"Update to 0.4.2 or use pipe: `echo 'css' | prettier-stylelint`","cause":"Possibly using a very old version (pre-0.3) where --stdin was not supported.","error":"prettier-stylelint: error: unknown option `--stdin'","affected_versions":"<0.3.0"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}