0.1.19 â€Ē Published 2 years ago

hardhat-output-validator v0.1.19

Weekly downloads
-
License
-
Repository
github
Last release
2 years ago

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
  • 🔧 (TODO) Extendable with custom checks

ðŸ“Ķ 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:

ParameterDescriptionDefault value
errorModeIf any checks don't pass it'll throw and error (on compilation).true
runOnCompileTrue if the plugin should make the checks on every compilationtrue
includeList of all the contract / interface / library names to include. An empty array will check for everything[]
excludeList of all the contract / interface / library names to exclude.[]
checksEnable/Disable certain checksdefaultValue = 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,}

comment: <> (| checks.devDoc | Enable/Disable certain checks for the dev docs | { events: false, variables: false, functions: true, constructor: true } |)

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 Best thing to do: Thorough Testing

0.1.19

2 years ago

0.1.18

2 years ago

0.1.17

2 years ago

0.1.16

2 years ago

0.1.15

2 years ago

0.1.14

2 years ago

0.1.12

2 years ago

0.1.11

2 years ago

0.1.10

2 years ago

0.1.9

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago