UNPKG

hardhat-output-validator

Version:

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

56 lines 2.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getErrorHandler = void 0; const types_1 = require("./types"); const getErrorHandler = (fileSource, fileName) => { const foundErrors = []; const getErrorText = (errorType, extraData) => { const typeToMessage = () => { switch (errorType) { case types_1.ErrorType.MissingTitle: return 'Contract is missing title'; case types_1.ErrorType.MissingDetails: return 'Contract is missing details'; case types_1.ErrorType.CompilationWarning: return `Compilation warnings: \n ${extraData} `; // User DOCS case types_1.ErrorType.MissingUserDoc: return `${extraData} is missing @notice`; // DEV DOCS case types_1.ErrorType.MissingDevDoc: return `${extraData} is missing @dev comment`; case types_1.ErrorType.MissingParams: return `${extraData} is missing @param comment`; case types_1.ErrorType.MissingReturnParams: return `${extraData} is missing @return comment`; case types_1.ErrorType.MissingAllParams: return `${extraData} is missing (all) @param comments`; case types_1.ErrorType.MissingAllReturnParams: return `${extraData} is missing (all) @return comments`; // NON STRICT case types_1.ErrorType.MissingUserOrDevDoc: return `${extraData} is missing documentation`; default: return undefined; } }; return `${errorType !== types_1.ErrorType.CompilationWarning ? 'Comments Error' : ''}: ${typeToMessage()}\n @ ${fileName} \n --> ${fileSource}\n`; }; const addError = (errorType, severityLevel, extraData) => { const text = getErrorText(errorType, extraData); foundErrors.push({ text, severityLevel, type: errorType, at: '', filePath: fileSource, fileName, }); }; return { addError, getAll: () => foundErrors, }; }; exports.getErrorHandler = getErrorHandler; //# sourceMappingURL=errors.js.map