From bcfb70590548a13d189420e663f81c3e9b94f132 Mon Sep 17 00:00:00 2001 From: Luiz Hemerly Date: Fri, 24 Mar 2023 02:22:34 -0300 Subject: [PATCH] ISSUE #206 - Plugins can be in any path Change loadPlugin function at index.js to receive the plugin path. --- lib/rules/index.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/rules/index.js b/lib/rules/index.js index d7e78ab8..b5ca69d8 100644 --- a/lib/rules/index.js +++ b/lib/rules/index.js @@ -67,15 +67,13 @@ function coreRules(meta) { ] } -function loadPlugin(pluginName, { reporter, config, inputSrc, fileName }) { +function loadPlugin(pluginPath, { reporter, config, inputSrc, fileName }) { let plugins try { - plugins = require(`solhint-plugin-${pluginName}`) + plugins = require(`${pluginPath}`) } catch (e) { console.error( - chalk.red( - `[solhint] Error: Could not load solhint-plugin-${pluginName}, make sure it's installed.` - ) + chalk.red(`[solhint] Error: Could not load ${pluginPath}, make sure it's installed.`) ) process.exit(1) } @@ -83,7 +81,7 @@ function loadPlugin(pluginName, { reporter, config, inputSrc, fileName }) { if (!Array.isArray(plugins)) { console.warn( chalk.yellow( - `[solhint] Warning: Plugin solhint-plugin-${pluginName} doesn't export an array of rules. Ignoring it.` + `[solhint] Warning: Plugin ${pluginPath} doesn't export an array of rules. Ignoring it.` ) ) return [] @@ -92,7 +90,7 @@ function loadPlugin(pluginName, { reporter, config, inputSrc, fileName }) { return plugins .map((Plugin) => new Plugin(reporter, config, inputSrc, fileName)) .map((plugin) => { - plugin.ruleId = `${pluginName}/${plugin.ruleId}` + plugin.ruleId = `${pluginPath}/${plugin.ruleId}` return plugin }) }