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

Latest commit

 

History

History
51 lines (36 loc) · 865 Bytes

no-timing-in-fetch-data.md

File metadata and controls

51 lines (36 loc) · 865 Bytes

nuxt/no-timing-in-fetch-data

disallow setTimeout/setInterval in asyncData/fetch

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

Rule Details

This rule is for preventing using setTimeout/setInterval in asyncData/fetch since it may lead to memory leak

Examples of incorrect code for this rule:

export default {
  asyncData() {
    let foo = 'bar'
    setTimeout(() => {
      foo = 'baz'
    }, 0)
  },
  fetch() {
    let foo = 'bar'
    setInterval(() => {
      foo = 'baz'
    }, 0)
  }
}

Examples of correct code for this rule:

export default {
  async asyncData() {
    let foo = 'baz'
  },
  fetch() {
    let foo = 'baz'
  }
}

🔍 Implementation