Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

hardhat-prettier

fvictorio3.6kMIT0.0.1TypeScript support: included

Hardhat plugin to format your code using Prettier Solidity

ethereum, smart-contracts, hardhat, hardhat-plugin

readme

hardhat-prettier

Use Prettier Solidity to format your code.

What

This plugin lets you automatically format your code using Prettier Solidity and check that it's correctly formatted.

Installation

<A step-by-step guide on how to install the plugin>

npm install hardhat-prettier prettier prettier-plugin-solidity

Import the plugin in your hardhat.config.js:

require("hardhat-prettier");

Or if you are using TypeScript, in your hardhat.config.ts:

import "hardhat-prettier";

Tasks

This plugin adds the format task, that will format and overwrite your Solidity code.

It also overrides the check task, to add checking your code's format as part of the check pipeline.

Configuration

This plugin will use prettier's defaults, but you can configure it by creating a .prettierrc file:

{
  "plugins": ["prettier-plugin-solidity"],
  "singleQuote": true
}