Skip to content

(Fixes #436) Fix 'getComputedProperties' #465

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ module.exports = {
} else if (cp.value.type === 'ObjectExpression') {
value = cp.value.properties
.filter(p =>
p.type === 'Property' &&
p.key.type === 'Identifier' &&
p.key.name === 'get' &&
p.value.type === 'FunctionExpression'
Expand Down
6 changes: 5 additions & 1 deletion tests/lib/rules/no-async-in-computed-properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,14 @@ ruleTester.run('no-async-in-computed-properties', rule, {
return bar
}
},
foo2: {
bar: {
set () {
new Promise((resolve, reject) => {})
}
},
baz: {
...mapGetters({ get: 'getBaz' }),
...mapActions({ set: 'setBaz' })
}
}
}
Expand Down
22 changes: 22 additions & 0 deletions tests/lib/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,28 @@ describe('getComputedProperties', () => {

assert.ok(computedProperties[0].value)
})

it('should not collide with object spread operator inside CP', () => {
node = parse(`const test = {
name: 'test',
computed: {
foo: {
...mapGetters({ get: 'getFoo' }),
...mapActions({ set: 'setFoo' })
}
}
}`)

const computedProperties = utils.getComputedProperties(node)

assert.equal(
computedProperties.length,
1,
'it detects all computed properties'
)

assert.notOk(computedProperties[0].value)
})
})

describe('getStaticPropertyName', () => {
Expand Down