Registry / devops / hardhat-prettier

hardhat-prettier

JSON →
library0.0.1jsnpmunverified

Hardhat plugin integrating Prettier Solidity for automatic code formatting and style checking. Current stable version 0.0.1 (pre-release) with no regular release cadence — it's experimental. Key differentiators: adds a format task and overrides the check task for Solidity files, leveraging prettier-plugin-solidity's Solidity-specific formatting rules. Minimal configuration via .prettierrc. Requires Hardhat ^2.0.0, Prettier ^2.1.0, and prettier-plugin-solidity 1.0.0-beta.1. Alternatives like solhint focus on linting; this plugin focuses solely on formatting. Active development on GitHub by a single maintainer.

npm install hardhat-prettier
INSTALL
IMPORT
SIG · HARDHAT-PRETTIER
H
hardhat-prettier
devopsjavascriptv0.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

hardhat-prettier (plugin)
import 'hardhat-prettier'
import { hardhatPrettier } from 'hardhat-prettier'
Plugin is imported for side effects — no named exports. Must be required/imported in hardhat.config
format task
npx hardhat format
npx hardhat prettier
The plugin adds a 'format' task, not a 'prettier' task. Run via Hardhat CLI
check task (overridden)
npx hardhat check
npx hardhat check:format
The plugin overrides the built-in 'check' task to include formatting verification

Shows how to install, configure, and use hardhat-prettier for formatting Solidity files in a Hardhat project.

// Install dependencies // npm install hardhat-prettier prettier prettier-plugin-solidity // hardhat.config.js require('hardhat-prettier'); // hardhat.config.ts (TypeScript) import 'hardhat-prettier'; // .prettierrc (optional, use default settings) { "plugins": ["prettier-plugin-solidity"], "singleQuote": true, "printWidth": 120 } // Format your Solidity files // npx hardhat format // Check formatting without overwriting (via check task) // npx hardhat check
hardhat --version
Debug
Known issues
deprecatedprettier-plugin-solidity version pinned to 1.0.0-beta.1 — not semver-stable and may have breaking changes
fix
Monitor the package for updates; consider using a more recent version of prettier-plugin-solidity if compatible
affects: >=0.0.1
gotchaPlugin overrides the 'check' task globally — affects all Hardhat check behavior
fix
Be aware that 'npx hardhat check' will now also check Solidity formatting; use 'npx hardhat format' to fix issues
affects: >=0.0.1
gotchaNo custom task configuration — uses .prettierrc defaults only
fix
Create a .prettierrc file for any customization; cannot pass options via hardhat.config
affects: >=0.0.1
breakingRequires Hardhat ^2.0.0 — incompatible with Hardhat v1
fix
Upgrade Hardhat to v2 or later
affects: >=0.0.1
Errors
Common errors & fixes
Error: Cannot find module 'hardhat-prettier'
Plugin not installed or missing from dependencies
fix
Run: npm install hardhat-prettier
Error HH12: Trying to use a non-existent hardhat task: format
Plugin not imported in hardhat config
fix
Add require('hardhat-prettier') or import 'hardhat-prettier' to your hardhat.config.js/ts
Cannot find module 'prettier-plugin-solidity'
Missing peer dependency
fix
Install peer: npm install prettier-plugin-solidity
Upgrade
Version history
0.0.1latest on npm
Audit
Dependencies
hardhatrequiredpeer dependency — Hardhat plugin architecture requires it
prettierrequiredpeer dependency — core formatting engine
prettier-plugin-solidityrequiredpeer dependency — Solidity language support for Prettier
Agent activity
11 hits · last 30 days
node
10
Resources
hardhat-prettier — npm install hardhat-prettier · libregistry