milkee-plugin-prettier
v1.0.0
Published
A Milkee plugin for working with Prettier for CoffeeScript without version conflicts.
Maintainers
Readme
milkee-plugin-prettier
A Milkee plugin for working with Prettier for CoffeeScript without version conflicts.
[!TIP] Uses Optimized-Prettier (by helixbass) and prettier-plugin-coffeescript (by helixbass) to format CoffeeScript files.
Features
- Recursively finds
.coffeefiles in the build entry directory and formats them with Prettier. - Supports a
prettierrc(object or a path to a config file) and.prettierignoreto exclude files. - Automatically resolves config via
prettier.resolveConfig()orpackage.json#prettierwhenprettierrcis not provided.
Usage
As a Milkee Plugin (coffee.config.cjs)
const prettierPlugin = require('milkee-plugin-prettier');
module.exports = {
entry: 'src',
output: 'dist',
milkee: {
plugins: [
// Pass options (optional)
prettierPlugin({
prettierrc: { tabWidth: 2 }, // or a path to a config file
prettierignore: '.prettierignore' // optional, resolved from cwd
})
]
}
};As a CLI Tool
You can also use this package as a standalone CLI tool to format CoffeeScript files:
# Format files in the current directory
npx cprettier
# Format files in a specific directory
npx cprettier srcThe CLI will:
- Recursively find all
.coffeefiles in the target directory - Respect
.prettierignoreand prettier config files (.prettierrc,prettier.config.js, orpackage.json#prettier) - Format files in place
Notes
.prettierignoreis resolved relative toprocess.cwd()by default. You can pass an absolute or relative path via theprettierignoreoption.- When
config.options.joinis used and a single entry file is emitted, the plugin will use the directory of the entry file as the search root for.coffeefiles.
