TransWikia.com

Source code formatter for Solidity?

Ethereum Asked by Pi Delport on November 24, 2021

Most programming languages have tools to format source code according to convention: for example, Python has autopep8 and yapf, and Go has gofmt.

Does a similar tool exist for Solidity source code, ideally according to the Solidity Style Guide?

7 Answers

There's a work in progress towards a plugin for prettier that formats solidity code: https://github.com/prettier-solidity/prettier-plugin-solidity As with prettier, the goal is to have an opinionated tool that takes your code, builds its AST and prints it again.

(Disclaimer: I'm one of the contributors)

Answered by Franco Victorio on November 24, 2021

You can use YAKINDU Soliditiy Tools, its open source and it has some other interesting features even if it is currently in beta phase.

https://medium.com/solidity-ide/yakindu-solidity-tools-beta-released-dbcc76307bc0

Answered by Johannes Dicks on November 24, 2021

This is a linter that provides security, style and best practice validations.

You may install it with

npm install -g solhint

For validation you need put in arguments glob expression of path to your code

solhint *.sol

I believe this tool with be useful for your project!

Answered by ilya_d on November 24, 2021

This is available now for IntelliJ (and related IDEs):

https://plugins.jetbrains.com/plugin/9475-intellij-solidity

Answered by Symmetric on November 24, 2021

https://github.com/alexstep/SublimeLinter-contrib-solium

Solium linter plugin for sublime text

Answered by Alex Step on November 24, 2021

I've recently published a Linter for Solidity which aims to comply the the official Style Guide.

Here's the repo

The architecture is pretty similar to that of ESLint so I'm trying to make it as easy-to-use and customizable (including plugging in of custom rules) as ESLint is.

Its under active development right now.

To get started, you could install it via npm:

npm install -g solium

Browse to the root directory of your project and run

solium --init

This creates .soliumrc.json (determines which rules to enable and handles plugging in of custom rules) & .soliumignore (specifies which files and folders to ignore)

To run the linter on a single file, simply use: solium --file path/to/myfile.sol

To lint over your entire project (all .sol files), use:

solium

OR

solium --hot to enable hot reloading.

Hopefully, this improves workflow & developer productivity, since I've been facing a lot of trouble developing for Ethereum platform, because of the lack of dev tools. Hope you find it useful!

Answered by Raghav Dua on November 24, 2021

If you use atom.io there is a linter: https://atom.io/packages/linter-solidity

And for syntax highlighting goodies: https://atom.io/packages/language-ethereum

Answered by firescar96 on November 24, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP