How to do it...

  1. Solium is a popular linter used by many to validate their code against best practices. Solium is distributed through npm and you can install it using the following command:
npm install -g solium
  1. Run the following command to verify the installation. It will return the details of the currently installed version:
solium -V
  1. Use the init command to set up your project to support Solium linting:
solium --init
  1. This command will create two files (.soliumignore and .soliumrc.json) in the project directory. The soliumignore file contains the names of files and directories to ignore while linting and the soliumrc file contains configuration that includes rules, plugins, and shareable configs.

  2. Once solium is set up, you can start linting your project by specifying a single file or a directory that contains multiple solidity contract files:
// Lint a specific file
solium -f fileName.sol

// Lint files present in the folder
solium -d contracts/
  1. Solium also fixes recommendations automatically. To do this, add a --fix flag while linting:
solium -d contracts/ --fix
  1. You can also run Solium in the background in watch mode. It will watch the directory for any changes and will print the results immediately:
solium --watch --dir contracts/
  1. While linting, you can specify rules for each line through comments. For example, you can instruct Solium to ignore a line/file or to ignore a specific recommendation:
// Avoid linting for the next line
/* solium-disable-next-line */

// Avoid the whole file
/* solium-disable */
  1. For more information about Solium, refer to its official documentation at http://solium.readthedocs.io/.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.58.120.57