Skip to content

Commit a594690

Browse files
mysticateamichalsnik
authored andcommitted
Fix: no-async-in-computed-properties crash (fixes #390) (#392)
1 parent 9857496 commit a594690

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

Diff for: lib/utils/index.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -385,11 +385,14 @@ module.exports = {
385385
callee.object.name === 'Vue' &&
386386
callee.property.type === 'Identifier' &&
387387
['component', 'mixin', 'extend'].indexOf(callee.property.name) > -1 &&
388-
node.arguments.length &&
388+
node.arguments.length >= 1 &&
389389
node.arguments.slice(-1)[0].type === 'ObjectExpression'
390390

391-
const isDestructedVueComponent = callee.type === 'Identifier' &&
392-
callee.name === 'component'
391+
const isDestructedVueComponent = node.type === 'CallExpression' &&
392+
callee.type === 'Identifier' &&
393+
callee.name === 'component' &&
394+
node.arguments.length >= 1 &&
395+
node.arguments.slice(-1)[0].type === 'ObjectExpression'
393396

394397
return isFullVueComponent || isDestructedVueComponent
395398
},

Diff for: tests/lib/rules/no-async-in-computed-properties.js

+14
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,20 @@ ruleTester.run('no-async-in-computed-properties', rule, {
6060
}
6161
`,
6262
parserOptions
63+
},
64+
{
65+
filename: 'test.vue',
66+
code: `
67+
async function resolveComponents(components) {
68+
return await Promise.all(components.map(async (component) => {
69+
if(typeof component === 'function') {
70+
return await component()
71+
}
72+
return component;
73+
}));
74+
}
75+
`,
76+
parserOptions: parserOptions8
6377
}
6478
],
6579

0 commit comments

Comments
 (0)