Skip to content

Commit 83b039d

Browse files
committed
fix: crash in ExportNamedDeclaration:exit
1 parent a15493f commit 83b039d

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

fixture/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,10 @@ import 'node:process'
1414
import '@jcoreio/toolchain'
1515

1616
import '@jcoreio/eslint-plugin-implicit-dependencies'
17+
18+
const foo = 1
19+
export { foo }
20+
21+
export default foo
22+
23+
export class Bar {}

src/rules/no-implicit-dependencies.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ export default {
7676
'CallExpression:exit': (node) => {
7777
if (
7878
node.callee.type === 'Identifier' &&
79-
node.callee.name === 'require'
79+
node.callee.name === 'require' &&
80+
node.arguments.length >= 1 &&
81+
node.arguments[0].type === 'Literal'
8082
) {
8183
const name = node.arguments[0].value
8284
checkModuleName(name, node)
@@ -91,11 +93,11 @@ export default {
9193
checkModuleName(name, node)
9294
},
9395
'ExportNamedDeclaration:exit': (node) => {
94-
const name = node.source.value
96+
const name = node.source?.value
9597
checkModuleName(name, node)
9698
},
9799
'ExportAllDeclaration:exit': (node) => {
98-
const name = node.source.value
100+
const name = node.source?.value
99101
checkModuleName(name, node)
100102
},
101103
}

0 commit comments

Comments
 (0)