Skip to content

Commit cd268e5

Browse files
committed
- Linting: Fix as per current prettier
- Testing: Fix test (was not parsing) - Testing: Fix test (missing an error message)
1 parent 60998b7 commit cd268e5

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

__tests__/prefer-await-to-then.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ ruleTester.run('prefer-await-to-then', rule, {
1616
'async function hi() { await thing().then() }',
1717
'async function hi() { await thing().catch() }',
1818
'a = async () => (await something())',
19-
'a = async () => (try { await something() } catch { somethingElse() })',
19+
`a = async () => {
20+
try { await something() } catch (error) { somethingElse() }
21+
}`,
2022
'something().then(async () => await somethingElse())'
2123
],
2224

@@ -31,7 +33,7 @@ ruleTester.run('prefer-await-to-then', rule, {
3133
},
3234
{
3335
code: 'function foo() { hey.then(function() { }).then(x).catch() }',
34-
errors: [{ message }, { message }]
36+
errors: [{ message }, { message }, { message }]
3537
},
3638
{
3739
code:

rules/prefer-await-to-then.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@ module.exports = {
4040
}
4141

4242
// if you're a then/catch/finally expression then you're probably a promise
43-
if (node.property && (node.property.name === 'then' || node.property.name === 'catch' || node.property.name === 'finally')) {
43+
if (
44+
node.property &&
45+
(node.property.name === 'then' ||
46+
node.property.name === 'catch' ||
47+
node.property.name === 'finally')
48+
) {
4449
context.report({
4550
node: node.property,
4651
message: 'Prefer await to then()/catch()/finally().'

0 commit comments

Comments
 (0)