Skip to content

Commit

Permalink
feature(putout) add ability to resolve eslint plugins (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
coderaiser committed Oct 4, 2019
1 parent c903157 commit efe60e1
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/putout/lib/eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const once = require('once');
const tryCatch = require('try-catch');

const {entries} = Object;
const cwd = process.cwd();

const noConfigFound = (a) => a && a.messageTemplate === 'no-config-found';

Expand All @@ -20,10 +21,15 @@ const getCli = once(() => {
const loadPlugin = (name, require) => {
if (name.includes('@')) {
name = name.replace('/', '/eslint-plugin-');
return require(name);
}

return require(`eslint-plugin-${name}`);
const path = require.resolve(`eslint-plugin-${name}`, {
paths: [
cwd,
]
});

return require(path);
};

const getPluginsStore = once(() => {
Expand Down

0 comments on commit efe60e1

Please sign in to comment.