Skip to content

Commit

Permalink
Add check for watchEffect.
Browse files Browse the repository at this point in the history
  • Loading branch information
ota-meshi committed Mar 7, 2020
1 parent ac342f7 commit 902d352
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/rules/no-watch-after-await.js
Expand Up @@ -45,6 +45,9 @@ module.exports = {
[ReferenceTracker.ESM]: true,
watch: {
[ReferenceTracker.CALL]: true
},
watchEffect: {
[ReferenceTracker.CALL]: true
}
}
}
Expand Down
41 changes: 41 additions & 0 deletions tests/lib/rules/no-watch-after-await.js
Expand Up @@ -41,6 +41,21 @@ tester.run('no-watch-after-await', rule, {
</script>
`
},
{
filename: 'test.vue',
code: `
<script>
import {watch, watchEffect} from 'vue'
export default {
async setup() {
watchEffect(() => { /* ... */ })
watch(() => { /* ... */ })
await doSomething()
}
}
</script>
`
},
{
filename: 'test.vue',
code: `
Expand Down Expand Up @@ -82,6 +97,32 @@ tester.run('no-watch-after-await', rule, {
}
]
},
{
filename: 'test.vue',
code: `
<script>
import {watch, watchEffect} from 'vue'
export default {
async setup() {
await doSomething()
watchEffect(() => { /* ... */ })
watch(() => { /* ... */ })
}
}
</script>
`,
errors: [
{
messageId: 'forbidden',
line: 8
},
{
messageId: 'forbidden',
line: 9
}
]
},
{
filename: 'test.vue',
code: `
Expand Down

0 comments on commit 902d352

Please sign in to comment.