Releases: prettier-solidity/prettier-plugin-solidity
v2.0.0-beta.8
What's Changed
- Adding support for Slang
1.0.0
by @Janther in #1106 - Reintroducing tests for
antlr
by @Janther in #1107
Full Changelog: v2.0.0-beta.7...v2.0.0-beta.8
v2.0.0-beta.7
What's Changed
Full Changelog: 2.0.0-beta.6...v2.0.0-beta.7
2.0.0-beta.6
New features
Format changes
// Original
import * as SomeSymbol from "AnotherFile.sol";
// [email protected]
// { parser: 'solidity-parse' }
import "AnotherFile.sol" as SomeSymbol;
// [email protected]
// { parser: 'solidity-parse' }
import * as SomeSymbol from "AnotherFile.sol";
Breaking changes
Full Changelog: v1.4.1...v1.4.2
v1.4.2
New features
Format changes
// Original
import * as SomeSymbol from "AnotherFile.sol";
// [email protected]
import "AnotherFile.sol" as SomeSymbol;
// [email protected]
import * as SomeSymbol from "AnotherFile.sol";
Breaking changes
Full Changelog: v1.4.1...v1.4.2
v2.0.0-beta.5
Smaller bundled file size and performance improvements.
v2.0.0-beta.4
Fix a bug in the previous release with the unpkg
endpoint.
v2.0.0-beta.3
Features
- Support for Slang 18
- Support for the browser was added back
Breaking changes
- Slang provides a wasm endpoint that relies on ESM features. Therefore we had to drop UMD and CommonJS support in order to bundle a package for the browser.
v2.0.0-beta.2
Moving closer to a release candidate, this pre-release adds the following features:
- Support for
@nomicfoundation/[email protected]
#1043 - Infer solidity version from source code #1047
2.0.0-beta.1
This year we have been working hard on adopting Nomic Foundation's Slang as our new parser.
This allowed us to update our architecture, address issues that the ANTLR parser was blocking, have more control in the rendering of comments, and officially move our codebase to typescript.
While in beta, we will still serve the solidity-parse
parser, but the plugin will now log a deprecation warning recommending using the slang-solidity
parser.
To start using the new parser just replace solidity-parse
with slang-solidity
in the .prettierrc
file.
{
"plugins": ["prettier-plugin-solidity"],
"overrides": [
{
"files": "*.sol",
"options": {
"parser": "slang-solidity",
"printWidth": 80,
"tabWidth": 4,
"useTabs": false,
"singleQuote": false,
"bracketSpacing": false,
"compiler": "0.8.26",
}
}
]
}
If a compiler
version is specified, this will be used to parse all the contracts in your project. By default the compiler version will be the latest Solidity version supported by @nomicfoundation/slang
. The final 2.0.0 release will infer the Solidity version from the pragma statements in each contract.
A wasm build of the @nomicfoundation/slang
package is not included in this beta release. This means the beta release can currently be used in node projects and build pipelines where Rust is supported.
We are working with Nomic Foundation to include a wasm build in the final 2.0.0 release to support browser based IDEs like Remix.
import prettier from 'prettier';
import solidityPlugin from 'prettier-plugin-solidity';
async function format(code) {
return await prettier.format(code, {
parser: 'slang-solidity',
compiler: '0.8.26',
plugins: [solidityPlugin],
});
}
const originalCode = 'contract Foo {}';
const formattedCode = format(originalCode);
We invite everyone to try this new version out and welcome reports of new issues.
v1.4.1
@pcaversaccio let us know that one of our formatting decisions was formatting an expected result so this was quickly reverted to the previous standard.
// Input
contract Comments {
function ifElse() public {
if (condition) {
// ...
} // Reason for else case
else {
// ...
}
}
}
// v1.4.0
contract Comments {
function ifElse() public {
if (condition) {
// ...
} else {
// Reason for else case
// ...
}
}
}
// v1.4.1
contract Comments {
function ifElse() public {
if (condition) {
// ...
} // Reason for else case
else {
// ...
}
}
}