disallow
context.isServer/context.isClient
inasyncData/fetch/nuxtServerInit
- ⚙️ This rule is included in
"plugin:nuxt/base"
.
This rule is for preventing using context.isServer/context.isClient
in asyncData/fetch/nuxtServerInit
Examples of incorrect code for this rule:
export default {
asyncData(context) {
if (context.isServer) {
const foo = 'bar'
}
},
fetch({ isClient }) {
if (isClient) {
const foo = 'bar'
}
}
}
Examples of correct code for this rule:
export default {
async asyncData() {
if (process.server) {
const foo = 'bar'
}
},
fetch() {
if (process.client) {
const foo = 'bar'
}
}
}