Prettier CoffeeScript Plugin
raw JSON → 0.1.5 verified Sat Apr 25 auth: no javascript maintenance
A Prettier plugin that adds support for formatting CoffeeScript (v2.5.0+) files. Current version 0.1.5, last updated in 2020. Requires a forked version of Prettier (prettier-v2.1.0-dev.100-gitpkg) which may not be stable. Release cadence is sporadic. Unlike other CoffeeScript formatters, this integrates directly with Prettier's ecosystem, enabling consistent formatting across languages. However, due to the forked Prettier dependency and lack of recent maintenance, it may not work with current Prettier releases.
Common errors
error Error: Cannot find module 'prettier' ↓
cause The plugin expects the forked Prettier to be installed, but standard Prettier is not sufficient.
fix
npm install --save-dev github:helixbass/prettier#prettier-v2.1.0-dev.100-gitpkg
error SyntaxError: Unexpected token ↓
cause CoffeeScript file uses syntax not supported by the plugin's parser (e.g., v2.5.0+ features).
fix
Ensure coffeescript@^2.5.0 is installed and the plugin recognizes the correct parser.
error Error: No parser could be inferred for file ↓
cause File extension is not .coffee or the plugin is not properly loaded.
fix
Ensure the file has .coffee extension and the plugin is listed in .prettierrc's plugins array.
Warnings
breaking Requires a forked version of Prettier (prettier-v2.1.0-dev.100-gitpkg) which is not the official release. May not work with standard Prettier. ↓
fix Install the forked Prettier from GitHub as described in the README.
deprecated The plugin has not been updated since 2020 and may be incompatible with newer versions of CoffeeScript or Prettier. ↓
fix Consider using an alternative CoffeeScript formatter or contributing to the project.
gotcha The plugin expects CoffeeScript v2.5.0 or higher. Older versions will cause parsing errors. ↓
fix Upgrade CoffeeScript to ^2.5.0.
gotcha When installing via npm, the forked Prettier dependency may not be resolved correctly without a lockfile. ↓
fix Use yarn or manually verify the installed version in node_modules.
Install
npm install prettier-plugin-coffeescript yarn add prettier-plugin-coffeescript pnpm add prettier-plugin-coffeescript Imports
- default wrong
const plugin = require('prettier-plugin-coffeescript');correct// No import needed; plugin auto-loads when installed - plugin wrong
{ "plugins": ["./node_modules/prettier-plugin-coffeescript"] }correct// Plugins field in .prettierrc: { "plugins": ["prettier-plugin-coffeescript"] } - options wrong
prettier --plugin=prettier-plugin-coffeescript --parser=coffeescript file.coffeecorrect// CLI: prettier --plugin=prettier-plugin-coffeescript file.coffee
Quickstart
// Install dependencies:
// yarn add --dev coffeescript@^2.5.0 github:helixbass/prettier#prettier-v2.1.0-dev.100-gitpkg prettier-plugin-coffeescript
// or
// npm install --save-dev coffeescript@^2.5.0 github:helixbass/prettier#prettier-v2.1.0-dev.100-gitpkg prettier-plugin-coffeescript
// Then create .prettierrc (JSON):
{
"plugins": ["prettier-plugin-coffeescript"],
"printWidth": 80,
"tabWidth": 2
}
// Format a CoffeeScript file:
// npx prettier --write path/to/file.coffee