Skip to content

Commit 32c524d

Browse files
committed
Fix bug in eslint 6
1 parent db6779d commit 32c524d

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

lib/rules/no-restricted-call-after-await.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,13 @@ module.exports = {
107107
return allLocalImports
108108
}
109109

110+
function getCwd() {
111+
if (context.getCwd) {
112+
return context.getCwd()
113+
}
114+
return path.resolve('')
115+
}
116+
110117
/**
111118
* @param {string} moduleName
112119
* @param {Program} ast
@@ -116,7 +123,7 @@ module.exports = {
116123
/** @type {string} */
117124
let modulePath
118125
if (moduleName.startsWith('.')) {
119-
modulePath = safeRequireResolve(path.join(context.getCwd(), moduleName))
126+
modulePath = safeRequireResolve(path.join(getCwd(), moduleName))
120127
} else if (path.isAbsolute(moduleName)) {
121128
modulePath = safeRequireResolve(moduleName)
122129
} else {

typings/eslint/index.d.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,8 @@ export namespace Rule {
328328
markVariableAsUsed(name: string): boolean
329329
report(descriptor: ReportDescriptor): void
330330

331-
getCwd(): string
331+
// eslint@6 does not have this method.
332+
getCwd?: () => string
332333
}
333334

334335
type ReportDescriptor =

0 commit comments

Comments
 (0)