Skip to content

Latest commit

 

History

History
98 lines (76 loc) · 2.46 KB

no-restricted-call-after-await.md

File metadata and controls

98 lines (76 loc) · 2.46 KB
pageClass sidebarDepth title description
rule-details
0
vue/no-restricted-call-after-await
disallow asynchronously called restricted methods

vue/no-restricted-call-after-await

disallow asynchronously called restricted methods

  • This rule has not been released yet.

📖 Rule Details

This rule reports your restricted calls after the await expression. In setup() function, you need to call your restricted functions synchronously.

🔧 Options

This rule takes a list of objects, where each object specifies a restricted module name and an exported name:

{
  "vue/no-restricted-call-after-await": ["error",
    { "module": "vue-i18n", "path": "useI18n" },
    { ... } // You can specify more...
  ]
}
<script>
import { useI18n } from 'vue-i18n'
export default {
  async setup() {
    /* ✓ GOOD */
    useI18n({})

    await doSomething()

    /* ✗ BAD */
    useI18n({})
  }
}
</script>

The following properties can be specified for the object.

  • module ... Specify the module name.
  • path ... Specify the imported name or the path that points to the method.
  • message ... Specify an optional custom message.

For examples:

{
  "vue/no-restricted-call-after-await": ["error",
    { "module": "a", "path": "foo" },
    { "module": "b", "path": ["bar", "baz"] },
    { "module": "c" }, // Checks the default import.
    { "module": "d", "path": "default" }, // Checks the default import.
  ]
}
<script>
import { foo as fooOfA } from 'a'
import { bar as barOfB } from 'b'
import defaultOfC from 'c'
import defaultOfD from 'd'
export default {
  async setup() {
    await doSomething()

    /* ✗ BAD */
    fooOfA()
    barOfB.baz()
    defaultOfC()
    defaultOfD()
  }
}
</script>

🔍 Implementation