Prettier Plugin for Stylus
raw JSON → 0.1.0 verified Sat Apr 25 auth: no javascript
A Prettier plugin for formatting Stylus stylesheets. Current stable version is 0.1.0 with irregular release cadence. Provides Pythonic-style formatting and is compatible with Vue.js Single-File Components via Stylus parser inference. Alternative to stylefmt or manual formatting; leverages Prettier's ecosystem for consistent code style across languages.
Common errors
error Error: Cannot find module 'prettier-plugin-stylus' ↓
cause Plugin not installed in project's node_modules.
fix
Run 'npm install prettier-plugin-stylus' or 'yarn add prettier-plugin-stylus'.
error Unsupported language: stylus ↓
cause Plugin not loaded; Prettier doesn't recognize .styl files.
fix
Ensure plugin is listed in Prettier's 'plugins' config.
Warnings
gotcha Plugin must be listed in 'plugins' config; using --plugin for each file invocation can be tedious. ↓
fix Add 'plugins': ['prettier-plugin-stylus'] to .prettierrc file.
gotcha Stylus parser inference for Vue SFC requires Prettier v2.7+. Older versions won't detect Stylus inside <style lang="stylus">. ↓
fix Update Prettier to v2.7 or later.
Install
npm install prettier-plugin-stylus yarn add prettier-plugin-stylus pnpm add prettier-plugin-stylus Imports
- default wrong
Attempting to import or require the plugin directly in codecorrectAdd 'prettier-plugin-stylus' to .prettierrc under plugins, or use --plugin=prettier-plugin-stylus on CLI
Quickstart
{
"semi": false,
"singleQuote": true,
"plugins": ["prettier-plugin-stylus"]
}
# Then format a Stylus file:
npx prettier --write style.styl