Skip to content

Commit 224d165

Browse files
neriyardenMichaelDeBoey
authored andcommitted
feat(await-async-utils): add autofix for references
1 parent 9717acd commit 224d165

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
@@ -466,7 +466,7 @@ ruleTester.run(RULE_NAME, rule, {
466466
import { ${asyncUtil} } from '${testingFramework}';
467467
test('several ${asyncUtil} utils not handled are invalid', () => {
468468
const aPromise = ${asyncUtil}(() => getByLabelText('username'));
469-
doSomethingElse(aPromise);
469+
doSomethingElse(await aPromise);
470470
await ${asyncUtil}(() => getByLabelText('email'));
471471
});
472472
`,
@@ -501,7 +501,7 @@ ruleTester.run(RULE_NAME, rule, {
501501
import { ${asyncUtil} } from '${testingFramework}';
502502
test('unhandled expression that evaluates to promise is invalid', () => {
503503
const aPromise = ${asyncUtil}(() => getByLabelText('username'));
504-
doSomethingElse(aPromise);
504+
doSomethingElse(await aPromise);
505505
await ${asyncUtil}(() => getByLabelText('email'));
506506
});
507507
`,

0 commit comments

Comments
 (0)