Description
Tell us about your environment
Node v9.3.0
eslint-plugin-vue v
- ESLint Version: 4.18.0
- eslint-plugin-vue Version: 4.3.0
- Node Version: 9.3.0
Please show your full configuration:
module.exports = {
root: true,
env: {
browser: true,
node: true
},
parserOptions: {
parser: 'babel-eslint'
},
extends: [
'plugin:vue/essential'
],
plugins: [
'vue'
],
}
What did you do? Please include the actual source code causing the issue.
computed: {
categorized() {
const categories = {}
this.types.forEach(c => {
categories[c.category] = categories[c.category] || []
categories[c.category].push(c)
})
return categories
},
},
What did you expect to happen?
This function takes an array of types, each of which has a category property, and returns an array of categories, each of which has an array of types within that category.
This function is appropriate as a computed function as it does not modify this.types
.
What actually happened? Please include the actual, raw output from ESLint.
47:7 error Unexpected side effect in "categorized" computed property vue/no-side-effects-in-computed-properties
✖ 1 problem (1 error, 0 warnings)
The issue is with line 7 from the snippet: categories[c.category].push(c)
. The regex for no-side-effects-in-computed-properties
catches ANY use of push
, even if it's on unrelated arrays. It even catches push
calls within comments, for instance:
unacceptable() {
return this.types.map(t => {
// [].push('xxx')
return t
})
I'm not certain what an appropriate fix is for this. Perhaps it should try to verify that the array being modified is not within the scope of the computed function?