eslint-plugin-vue-no-static-computed
eslint-plugin-vue-no-static-computed
ESLint rule to disallow Vue computed() wrapping purely static values with no reactive dependencies.
Installation
npm install --save-dev eslint-plugin-vue-no-static-computed
Usage
In your ESLint flat config (eslint.config.js):
import vueNoStaticComputed from 'eslint-plugin-vue-no-static-computed'
export default [
{
plugins: {
'vue-no-static-computed': vueNoStaticComputed,
},
rules: {
'vue-no-static-computed/no-static-computed': 'error',
},
},
]
Rule Details
no-static-computed flags computed() calls where the getter returns a value with no reactive dependencies. These should be plain variables instead.
Examples
Bad:
import { computed } from 'vue'
const items = computed(() => ['a', 'b', 'c'])
const config = computed(() => ({ key: 'value' }))
const label = computed(() => 'hello')
Good:
import { computed, ref } from 'vue'
const items = ['a', 'b', 'c']
const config = { key: 'value' }
const label = 'hello'
const count = ref(0)
const doubled = computed(() => count.value * 2)
License
MIT
Related Packages
eslint-plugin-test-id
This checks is data-test-id prop is present, on some tags which are useful for e...
10,384
17
Version History
| Version | Released | License |
|---|---|---|
| 0.1.0 | MIT |