@slippy-lint/slippy
Version:
A simple but powerful linter for Solidity
117 lines • 4.95 kB
JavaScript
export class AssertionError extends Error {
constructor(message) {
super(`Assertion error: ${message}`);
}
}
export var SlippyErrorCode;
(function (SlippyErrorCode) {
SlippyErrorCode["Generic"] = "SLIPPY_GENERIC_ERROR";
SlippyErrorCode["FileNotFound"] = "SLIPPY_FILE_NOT_FOUND";
SlippyErrorCode["ConfigNotFound"] = "SLIPPY_CONFIG_NOT_FOUND";
SlippyErrorCode["SlippyRuleNotRegistered"] = "SLIPPY_RULE_NOT_REGISTERED";
SlippyErrorCode["SlippyConfigAlreadyExists"] = "SLIPPY_CONFIG_ALREADY_EXISTS";
SlippyErrorCode["SlippyUnmatchedPattern"] = "SLIPPY_UNMATCHED_PATTERN";
SlippyErrorCode["SlippyDirectoriesNotSupported"] = "SLIPPY_DIRECTORIES_NOT_SUPPORTED";
SlippyErrorCode["SlippyCantInferSolidityVersion"] = "SLIPPY_CANT_INFER_SOLIDITY_VERSION";
SlippyErrorCode["SlippyErrorLoadingConfig"] = "SLIPPY_ERROR_LOADING_CONFIG";
SlippyErrorCode["SlippyInvalidConfig"] = "SLIPPY_INVALID_CONFIG";
SlippyErrorCode["SlippyRuleConfigError"] = "SLIPPY_RULE_CONFIG_ERROR";
SlippyErrorCode["SlippyNonexistentConfigPath"] = "SLIPPY_NONEXISTENT_CONFIG_PATH";
SlippyErrorCode["SlippyTooManyFixes"] = "SLIPPY_TOO_MANY_FIXES";
SlippyErrorCode["SlippyParsingErrorAfterFix"] = "SLIPPY_PARSING_ERROR_AFTER_FIX";
})(SlippyErrorCode || (SlippyErrorCode = {}));
export class SlippyError extends Error {
constructor(message, code = SlippyErrorCode.Generic, hint) {
super(message);
this.message = message;
this.code = code;
this.hint = hint;
this.isSlippyError = true;
}
static isSlippyError(error) {
return (error instanceof Error && error.isSlippyError === true);
}
}
export class SlippyFileNotFoundError extends SlippyError {
constructor(fileId) {
super(`File not found: ${fileId}`);
this.code = SlippyErrorCode.FileNotFound;
}
}
export class SlippyConfigNotFoundError extends SlippyError {
constructor() {
super("No slippy.config.js found in the current directory or any parent directory");
this.code = SlippyErrorCode.ConfigNotFound;
this.hint = "Run 'slippy --init' to create a configuration file.";
}
}
export class SlippyRuleNotRegisteredError extends SlippyError {
constructor(ruleName) {
super(`Rule '${ruleName}' does not exist`);
this.code = SlippyErrorCode.SlippyRuleNotRegistered;
}
}
export class SlippyConfigAlreadyExistsError extends SlippyError {
constructor(configPath) {
super(`Configuration file already exists at '${configPath}'`);
this.code = SlippyErrorCode.SlippyConfigAlreadyExists;
}
}
export class SlippyUnmatchedPatternError extends SlippyError {
constructor(pattern) {
super(`No files matched the pattern: '${pattern}'`);
this.code = SlippyErrorCode.SlippyUnmatchedPattern;
}
}
export class SlippyDirectoriesNotSupportedError extends SlippyError {
constructor(directory) {
super(`Directories are not supported: '${directory}'`);
this.code = SlippyErrorCode.SlippyDirectoriesNotSupported;
}
}
export class SlippyCantInferSolidityVersionError extends SlippyError {
constructor(sourceId) {
super(`Cannot infer Solidity version for source file: ${sourceId}`);
this.code = SlippyErrorCode.SlippyCantInferSolidityVersion;
this.hint =
"Check that the version pragmas are correct and that you are using the latest version of Slippy.";
}
}
export class SlippyConfigLoadingError extends SlippyError {
constructor(slippyConfigPath, message) {
super(`Error loading config at '${slippyConfigPath}': ${message}`);
this.code = SlippyErrorCode.SlippyErrorLoadingConfig;
}
}
export class SlippyInvalidConfigError extends SlippyError {
constructor(slippyConfigPath, message, hint) {
super(`Invalid config at '${slippyConfigPath}': ${message}`);
this.code = SlippyErrorCode.SlippyInvalidConfig;
this.hint = hint;
}
}
export class SlippyRuleConfigError extends SlippyError {
constructor(ruleName, problem) {
super(`Error in configuration for rule '${ruleName}': ${problem}`);
this.code = SlippyErrorCode.SlippyRuleConfigError;
}
}
export class SlippyNonexistentConfigPathError extends SlippyError {
constructor(configPath) {
super(`The specified config path does not exist: '${configPath}'`);
this.code = SlippyErrorCode.SlippyNonexistentConfigPath;
}
}
export class SlippyTooManyFixesError extends SlippyError {
constructor(fileId) {
super(`The file '${fileId}' produced too many fixes.`);
this.code = SlippyErrorCode.SlippyTooManyFixes;
}
}
export class SlippyParsingErrorAfterFixError extends SlippyError {
constructor(fileId) {
super(`Parsing error after autofix in file '${fileId}'.`);
this.code = SlippyErrorCode.SlippyParsingErrorAfterFix;
}
}
//# sourceMappingURL=errors.js.map