Skip to content

Files

Latest commit

 

History

History
54 lines (40 loc) · 999 Bytes

no-env-in-hooks.md

File metadata and controls

54 lines (40 loc) · 999 Bytes

Pattern: Use of process.server/process.client/process.browser in client-only hooks

Issue: -

Description

This rule is for preventing using process.server/process.client/process.browser 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'
    }
  },
  beforeDestroy() {
    if (process.browser) {
      const foo = 'bar'
    }
  }
}

Examples of correct code for this rule:

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

Further Reading