Skip to content

Commit

Permalink
fix: use file:// url loading plugins
Browse files Browse the repository at this point in the history
The `file://` url is used when the path is not a relative path.  This
supports all platforms.

Signed-off-by: Chris. Webster <chris@webstech.net>
  • Loading branch information
webstech committed Jan 15, 2023
1 parent 301687f commit 3ec47a3
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/plugins/utils.js
Expand Up @@ -52,9 +52,14 @@ export async function loadPlugin({cwd}, name, pluginsPath) {
? dirname(resolveFrom.silent(__dirname, pluginsPath[name]) || resolveFrom(cwd, pluginsPath[name]))
: __dirname;

// See https://github.com/mysticatea/eslint-plugin-node/issues/250
// eslint-disable-next-line node/no-unsupported-features/es-syntax
return isFunction(name) ? name : (await import(resolveFrom.silent(basePath, name) || resolveFrom(cwd, name))).default;
if (!isFunction(name)) {
const file = resolveFrom.silent(basePath, name) || resolveFrom(cwd, name);
// See https://github.com/mysticatea/eslint-plugin-node/issues/250
// eslint-disable-next-line node/no-unsupported-features/es-syntax
name = (await import(`${ file[0] != '.' ? "file://" : "" }${file}`)).default;
}

return name;
}

export function parseConfig(plugin) {
Expand Down

0 comments on commit 3ec47a3

Please sign in to comment.