Skip to content

Commit

Permalink
fix(no-import-module-exports): Don't crash if packages have no entryp…
Browse files Browse the repository at this point in the history
…oint
  • Loading branch information
eps1lon committed May 26, 2021
1 parent 6ff6cf5 commit a291621
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/rules/no-import-module-exports.js
Expand Up @@ -4,7 +4,13 @@ import pkgUp from 'pkg-up';

function getEntryPoint(context) {
const pkgPath = pkgUp.sync(context.getFilename());
return require.resolve(path.dirname(pkgPath));
try {
return require.resolve(path.dirname(pkgPath));
} catch (error) {
// Assume the package has no entrypoint (e.g. CLI packages)
// in which case require.resolve would throw.
return null;
}
}

module.exports = {
Expand Down

0 comments on commit a291621

Please sign in to comment.