A Prettier plugin for automatically formatting your Solidity code.
Needed to put a specific experimentalTernaries
behaviour behind a feature flag. (thanks @pcaversaccio)
This version ships with 2 substantial changes.
externalTernaries
, so we invite people to start experimenting with it and give us some feedback. (#953)A few improvements on this release:
.cjs
extensionprettier-plugin-solidity/standalone
1000e-2
(solidity-parser/parser#95)A few tweaks in the code and refactor for simplicity and efficiency.
This version adds support for user-defined operators, a feature introduced in Solidity 0.8.19.
This version adds support for named parameters in mappings, introduced in Solidity 0.8.18. This means you can add names to your mappings parameters:
mapping(address account => uint balance) balanceOf;
and Prettier Solidity will format it correctly.
Thanks to @zemse for working on this!
With this version we started supporting prettier V3 which at the moment it's in their 3.0.0-alpha.4
version. (#757)
Some internal tweaks and removed some dependencies that were no longer used. (thanks to @frangio for noticing #780)
With this version, we are releasing a standalone build (#727). It follows the same patterns Prettier uses for their internal plugins such as UMD. Hopefully this will make integration for projects based on the browser easy and will be automatically shipped on each release to http://unpkg.com/prettier-plugin-solidity@latest.
We also took care of a small bug that would print an extra line when formatting solidity code within a markdown code block (#765).
We are happy to release the first stable version of Prettier Solidity! :tada: :tada:
What does this mean for you as a user? Semantic versioning doesn't make a lot of sense for a formatter, so it's hard to give hard rules about what will be the meaning of future versions. But we'll try to follow these guidelines:
What separates a "very minor formatting change" from a "bigger one" is hard to define precisely, of course, so some of these decisions will be very subjective, but we'll try to do our best.
Thanks for using our plugin and remember to star the repo! :star:
This is our first release candidate for a stable v1.0.0!
This version includes some significant changes:
explicitTypes
option, since we believe that this belongs to a linter. The behavior now is the same one that you would get if using explicitTypes: "preserve"
, meaning that we'll never convert an uint
to an uint256
or vice versa.line-width
. Plus, the way this works is that first the parameters are split, then the modifiers (if they also don't fit in a single line), and finally the return parameters (also only if they don't fit).**
) now has spaces around it. This is more consistent with other operators, and it looks better for long variable names (that is, base ** decimals
is better than base**decimals
). We do know that this is not as nice for some cases (2 ** 10
), but we are erring on the side of consistency and a better worst-case scenario.As an example, a function like this:
contract Foo {
function f(uint x, uint y, uint z) mod1 mod2 { x**y**z; }
}
would be formatted in the previous version like this:
contract Foo {
function f(
uint256 x,
uint256 y,
uint256 z
) mod1 mod2 {
x**y**z;
}
}
and now it will be formatted like this:
contract Foo {
function f(uint x, uint y, uint z) mod1 mod2 {
x ** y ** z;
}
}
Please upgrade to the latest version and let us if you find any issues!
This new release provides some bug fixes and new formatting added by solidity.
#643 #683 #685 #693 #694