npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@logium/hardhat-output-validator

v0.1.0-logium

Published

Zero-config Hardhat plugin to check the build output of Solidity contracts

Downloads

1

Readme

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.