Rules to avoid unpleasant composable problems
You'll need to install ESLint along with this package:
# Using pnpm
pnpm add --dev eslint @scayle/eslint-plugin-vue-composable
# Using yarn
yarn add --dev eslint @scayle/eslint-plugin-vue-composable
# Using npm
npm install --save-dev eslint @scayle/eslint-plugin-vue-composable
Add @scayle/eslint-plugin-vue-composable
to the plugins section of your .eslintrc
configuration file.
{
"plugins": [
"@scayle/vue-composable"
]
}
Then configure the rules you want to use under the rules section.
{
"rules": {
"@scayle/vue-composable/no-composable-after-await": "warn",
"@scayle/vue-composable/no-lifecycle-after-await": "error",
"@scayle/vue-composable/no-watch-after-await": "error",
"@scayle/vue-composable/no-computed-after-await": "error"
}
}
Name | Description |
---|---|
no-composable-after-await | disallow asynchronously called composable functions in composables |
no-computed-after-await | disallow asynchronously registered computed in composables |
no-lifecycle-after-await | disallow asynchronously registered lifecycle hooks in composables |
no-watch-after-await | disallow asynchronously registered watch and watchEffect in composables |