@logium/hardhat-output-validator
TypeScript icon, indicating that this package has built-in type declarations

0.1.0-logium • Public • Published

Validator

Output Validator

version npm

Zero-config Hardhat plugin to check the output of the compiler for any problems.

  • ツ Zero-configuration required
  • 🔍 Checks for : NatSpec comments & Compilation warnings.
  • 🔧 Extendable with custom checks. (TODO)

📦 Installation

First thing to do is to install the plugin in your Hardhat project:

# Using yarn
yarn add hardhat-output-validator

# Or using npm
npm i hardhat-output-validator

Next step is simply to include the plugin into your hardhat.config.js or hardhat.config.ts file:

// Using JavaScript
require('hardhat-output-validator');

// Using ES6 or TypeScript
import 'hardhat-output-validator';

And you're done! Documentation will be automatically checked on the next compilation and you'll see the result in your console. :)

📝 Usage

The Output Validator loops through all your Solidity contracts and checks for missing NatSpec . For example, given the following function:

/// @notice Does another thing when the function is called.
/// @dev More info about doing another thing when the function is called.
/// @param num A random number
/// @return A random variable
function anotherThing(uint256 num) external pure returns (uint256);

It will generate the following output:

Comments Error: Function: (anotherThing) is missing @notice
@ IExampleContract
--> contracts/IExampleContract.sol

The plugin is compatible with all the NatSpec tags (except custom ones), and checks all events and external / public functions and state variables.

🔧 Config

You can change the default settings in your Hardhat config file:

import { HardhatUserConfig } from 'hardhat/config';
import '@nomiclabs/hardhat-waffle';
import '@nomiclabs/hardhat-ethers';
import 'hardhat-output-validator';

const config: HardhatUserConfig = {
  // ... Your Hardhat config
  outputValidator: {
      runOnCompile: true,
      errorMode: true,
      checks: {
          title: "error",
          details: "error",
          params: "error",
          returns: "error",
          compilationWarnings: "warning",
          variables: false,
          events: false
      },
      exclude: ['contracts/test-helpers', "IExampleContract"],
  },
};

export default config;

Here are all the configuration parameters that are currently available, but as said above, all of them are entirely optional:

Parameter Description Default value
errorMode If any checks don't pass it'll throw and error (on compilation). true
runOnCompile True if the plugin should make the checks on every compilation true
include List of all the contract / interface / library names to include. An empty array will check for everything []
exclude List of all the contract / interface / library names to exclude. []
checks Enable/Disable certain checks defaultValue = errorMode ? 'error' : 'warning'

{ title: default,
details: default,
compilationWarnings: default,
missingUserDoc: default,
missingDevDoc: default,
events: false,
variables: false,
functions: default,
ctor: false,
params: default,
returnParams: default,
}

Features

  • Dev & User Documentation
  • @param & @return checks
  • Function Overloads
  • Checks in Base Contracts
  • Compilation Warnings
  • Events
  • Config-level ignore
  • Strict mode

Contribute

All feedback and contributions are welcome. Feel free to open an issue !

Next thing on the list: Unit tests.

Package Sidebar

Install

npm i @logium/hardhat-output-validator

Weekly Downloads

0

Version

0.1.0-logium

License

none

Unpacked Size

77.7 kB

Total Files

43

Last publish

Collaborators

  • logiumadm