Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Latest commit

 

History

History
49 lines (34 loc) · 981 Bytes

no-env-in-hooks.md

File metadata and controls

49 lines (34 loc) · 981 Bytes

nuxt/no-env-in-hooks

Disallow process.server and process.client in the following lifecycle hooks: beforeMount, mounted, beforeUpdate, updated, activated, deactivated, beforeDestroy and destroyed.

  • ⚙️ This rule is included in "plugin:nuxt/base".

Rule Details

This rule is for preventing using process.server/process.client in client only Vue lifecycle hooks since they're only executed in client side.

Examples of incorrect code for this rule:

export default {
  mounted() {
    if (process.server) {
      const foo = 'bar'
    }
  },
  beforeMount() {
    if (process.client) {
      const foo = 'bar'
    }
  }
}

Examples of correct code for this rule:

export default {
  mounted() {
    const foo = 'bar'
  },
  beforeMount() {
    const foo = 'bar'
  }
}

🔍 Implementation