Skip to content

Commit

Permalink
Fix bug in eslint 6
Browse files Browse the repository at this point in the history
  • Loading branch information
ota-meshi committed Dec 17, 2020
1 parent db6779d commit 32c524d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion lib/rules/no-restricted-call-after-await.js
Expand Up @@ -107,6 +107,13 @@ module.exports = {
return allLocalImports
}

function getCwd() {
if (context.getCwd) {
return context.getCwd()
}
return path.resolve('')
}

/**
* @param {string} moduleName
* @param {Program} ast
Expand All @@ -116,7 +123,7 @@ module.exports = {
/** @type {string} */
let modulePath
if (moduleName.startsWith('.')) {
modulePath = safeRequireResolve(path.join(context.getCwd(), moduleName))
modulePath = safeRequireResolve(path.join(getCwd(), moduleName))
} else if (path.isAbsolute(moduleName)) {
modulePath = safeRequireResolve(moduleName)
} else {
Expand Down
3 changes: 2 additions & 1 deletion typings/eslint/index.d.ts
Expand Up @@ -328,7 +328,8 @@ export namespace Rule {
markVariableAsUsed(name: string): boolean
report(descriptor: ReportDescriptor): void

getCwd(): string
// eslint@6 does not have this method.
getCwd?: () => string
}

type ReportDescriptor =
Expand Down

0 comments on commit 32c524d

Please sign in to comment.