Skip to content

Commit

Permalink
Simplify the fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
papandreou committed Feb 13, 2019
1 parent a5fa46a commit 0c113b5
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/rules/no-async-describe.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ module.exports = function (context) {

function fixAsyncFunction(fixer, fn) {
if (!containsDirectAwait(fn.body)) {
return fixer.replaceTextRange(
[ fn.start, fn.end ],
sourceCode.text.slice(fn.range[0], fn.range[1]).replace(/^async /, '')
);
// Remove the "async" token and all the whitespace before "function":
const [ asyncToken, functionToken ] = sourceCode.getFirstTokens(fn, 2);
return fixer.removeRange([ asyncToken.range[0], functionToken.range[0] ]);
}
return undefined;
}
Expand Down

0 comments on commit 0c113b5

Please sign in to comment.