A Prettier plugin that adds formatting support for Motoko, the smart contract language of the Internet Computer (ICP). Current stable version is 0.13.0, released under the Apache 2.0 license. It integrates seamlessly into the Prettier ecosystem, allowing Motoko files to be formatted alongside other languages. Key differentiators include Motoko-specific options like motokoOrganizeImports (to group and sort imports by prefix) and motokoRemoveLinesAroundCodeBlocks (to strip extra blank lines), plus prettier-ignore comment support. It requires Prettier v2.7 or v3 as a peer dependency and ships with TypeScript type declarations.
npm install prettier-plugin-motokoNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates installation, configuration, and usage of the Motoko Prettier plugin via CLI.
Upgrade Prettier to ^2.7.0 || ^3.0.0
Add '"plugins": ["prettier-plugin-motoko"]' to your .prettierrc or use --plugin=prettier-plugin-motoko
Review your .mo files after enabling this option; consider disabling for projects with complex import comments.
Use 'prettier-plugin-motoko' with Prettier; for a standalone formatter, consider 'mo-fmt' package.
Run 'npm install --save-dev prettier-plugin-motoko' and check that node_modules contains it.
Ensure plugins array in .prettierrc includes 'prettier-plugin-motoko' or pass --plugin=prettier-plugin-motoko on CLI.
Install prettier with 'npm install --save-dev prettier'.