Skip to content

Commit a291621

Browse files
committed
fix(no-import-module-exports): Don't crash if packages have no entrypoint
1 parent 6ff6cf5 commit a291621

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/rules/no-import-module-exports.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ import pkgUp from 'pkg-up';
44

55
function getEntryPoint(context) {
66
const pkgPath = pkgUp.sync(context.getFilename());
7-
return require.resolve(path.dirname(pkgPath));
7+
try {
8+
return require.resolve(path.dirname(pkgPath));
9+
} catch (error) {
10+
// Assume the package has no entrypoint (e.g. CLI packages)
11+
// in which case require.resolve would throw.
12+
return null;
13+
}
814
}
915

1016
module.exports = {

0 commit comments

Comments
 (0)