Solium: Write your Solidity code with style

Chih-Cheng Liang
Jul 27, 2017 · 3 min read
Solium linting in Visual Studio Code

Like most of the programming languages these days, the currently most widely used smart contract language, Solidity, has a linter that helps your team write high quality code with good coding style. Solium, maintained by duaraghav8 and other contributors, is the tool.

Getting started

Solium is a nodejs package, install with:

npm install -g git+https://github.com/duaraghav8/Solium.git

It’s highly configurable. You’ll need to initialize some configs in your project directory, we’ll explain these later.

solium --init

Let’s lint through the directory.

solium --dir .

That’s it! You should now see a bunch of coding style warnings and errors.

Customization

solium --init gives you two configs, .soliumrc.json and .soliumignore. Specify what rules you would (not) like to follow in former, what files you would not like to lint in later.

The package is well documented, reading more at it’s Github repository is highly recommended.

Integrate with Visual Studio Code

Visual Studio Code is by far the best editor I’ve been enjoying with, and is of course the default editor I use to develop Solidity code.

You can use Solium with Visual Studio in two ways.

Install Solidity Extended, a Visual Studio Code package maintained by beaugunderson, done.

The downside is, the Solium customization feature is currently not available.

Visual Studio Code allows you to customize build or test tasks specific to your project directory.

In Mac, enter Cmd+shift+b in the editor and see a popup message shows.

Click the “Configure Build Task” and paste the following to the tasks.json .

Enter Cmd+shift+b again, and you should see the linter run. Voila! warnings and errors will shown directly on your source code.

Recommend and subscribe to Taipei Ethereum Meetup Publication.

Ether address: 0x004864DeD3ca499D2f46BF74246E29b494610f5E

References

Taipei Ethereum Meetup

台北以太坊社群專欄

Chih-Cheng Liang

Written by

chihchengliang@gmail.com

Taipei Ethereum Meetup

台北以太坊社群專欄

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade