From 08154eaf41208b01893b8950e80c38366df14c1d Mon Sep 17 00:00:00 2001 From: Diego Bale <89921440+dbale-altoros@users.noreply.github.com> Date: Fri, 7 Jul 2023 15:25:33 -0300 Subject: [PATCH] Revert "ISSUE #206 - Plugins can be in any path" --- lib/rules/index.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/rules/index.js b/lib/rules/index.js index b5ca69d8..d7e78ab8 100644 --- a/lib/rules/index.js +++ b/lib/rules/index.js @@ -67,13 +67,15 @@ function coreRules(meta) { ] } -function loadPlugin(pluginPath, { reporter, config, inputSrc, fileName }) { +function loadPlugin(pluginName, { reporter, config, inputSrc, fileName }) { let plugins try { - plugins = require(`${pluginPath}`) + plugins = require(`solhint-plugin-${pluginName}`) } catch (e) { console.error( - chalk.red(`[solhint] Error: Could not load ${pluginPath}, make sure it's installed.`) + chalk.red( + `[solhint] Error: Could not load solhint-plugin-${pluginName}, make sure it's installed.` + ) ) process.exit(1) } @@ -81,7 +83,7 @@ function loadPlugin(pluginPath, { reporter, config, inputSrc, fileName }) { if (!Array.isArray(plugins)) { console.warn( chalk.yellow( - `[solhint] Warning: Plugin ${pluginPath} doesn't export an array of rules. Ignoring it.` + `[solhint] Warning: Plugin solhint-plugin-${pluginName} doesn't export an array of rules. Ignoring it.` ) ) return [] @@ -90,7 +92,7 @@ function loadPlugin(pluginPath, { reporter, config, inputSrc, fileName }) { return plugins .map((Plugin) => new Plugin(reporter, config, inputSrc, fileName)) .map((plugin) => { - plugin.ruleId = `${pluginPath}/${plugin.ruleId}` + plugin.ruleId = `${pluginName}/${plugin.ruleId}` return plugin }) }