Skip to content

Commit 7e9d9a4

Browse files
author
Rebecca Stevens
committed
fix(no-restricted-paths): fix for older versions of eslint
1 parent f8e4a91 commit 7e9d9a4

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/rules/no-restricted-paths.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ module.exports = {
7979
})
8080
}
8181

82-
function checkForRestrictedImportPath(importPath, node) {
83-
const absoluteImportPath = resolve(importPath, context)
82+
function checkForRestrictedImportPath(importPathNode, importNode) {
83+
const absoluteImportPath = resolve(importPathNode.value, context)
8484

8585
if (!absoluteImportPath) {
8686
return
@@ -101,7 +101,7 @@ module.exports = {
101101
.every((absoluteExceptionPath) => isValidExceptionPath(absoluteFrom, absoluteExceptionPath))
102102

103103
if (!hasValidExceptionPaths) {
104-
reportInvalidExceptionPath(node)
104+
reportInvalidExceptionPath(importPathNode)
105105
return
106106
}
107107

@@ -113,29 +113,29 @@ module.exports = {
113113
}
114114

115115
const typeIsExpected = (zone.allowedImportKinds || allowedImportKinds)
116-
.some((kind) => node.parent && kind === node.parent.importKind)
116+
.some((kind) => kind === importNode.importKind)
117117

118118
if (typeIsExpected) {
119119
return
120120
}
121121

122122
context.report({
123-
node,
123+
node: importPathNode,
124124
message: `Unexpected path "{{importPath}}" imported in restricted zone.${zone.message ? ` ${zone.message}` : ''}`,
125-
data: { importPath },
125+
data: { importPath: importPathNode.value },
126126
})
127127
})
128128
}
129129

130130
return {
131131
ImportDeclaration(node) {
132-
checkForRestrictedImportPath(node.source.value, node.source)
132+
checkForRestrictedImportPath(node.source, node)
133133
},
134134
CallExpression(node) {
135135
if (isStaticRequire(node)) {
136136
const [ firstArgument ] = node.arguments
137137

138-
checkForRestrictedImportPath(firstArgument.value, firstArgument)
138+
checkForRestrictedImportPath(firstArgument, node)
139139
}
140140
},
141141
}

0 commit comments

Comments
 (0)