Skip to content

Commit c427ae0

Browse files
neriyardenMichaelDeBoey
authored andcommitted
feat(await-async-utils): add autofix for references
1 parent 441493c commit c427ae0

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lib/rules/await-async-utils.ts

+3
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ export default createTestingLibraryRule<Options, MessageIds>({
169169
data: {
170170
name: node.name,
171171
},
172+
fix: (fixer) => {
173+
return fixer.insertTextBefore(referenceNode, 'await ');
174+
},
172175
});
173176
return;
174177
}

tests/lib/rules/await-async-utils.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ ruleTester.run(RULE_NAME, rule, {
465465
import { ${asyncUtil} } from '${testingFramework}';
466466
test('several ${asyncUtil} utils not handled are invalid', () => {
467467
const aPromise = ${asyncUtil}(() => getByLabelText('username'));
468-
doSomethingElse(aPromise);
468+
doSomethingElse(await aPromise);
469469
await ${asyncUtil}(() => getByLabelText('email'));
470470
});
471471
`,
@@ -500,7 +500,7 @@ ruleTester.run(RULE_NAME, rule, {
500500
import { ${asyncUtil} } from '${testingFramework}';
501501
test('unhandled expression that evaluates to promise is invalid', () => {
502502
const aPromise = ${asyncUtil}(() => getByLabelText('username'));
503-
doSomethingElse(aPromise);
503+
doSomethingElse(await aPromise);
504504
await ${asyncUtil}(() => getByLabelText('email'));
505505
});
506506
`,

0 commit comments

Comments
 (0)