Skip to content

Commit

Permalink
Revert "ISSUE #206 - Plugins can be in any path"
Browse files Browse the repository at this point in the history
  • Loading branch information
dbale-altoros authored Jul 7, 2023
1 parent c561e53 commit 08154ea
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/rules/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,23 @@ 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)
}

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 []
Expand All @@ -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
})
}
Expand Down

0 comments on commit 08154ea

Please sign in to comment.