Skip to content

vue/no-side-effects-in-computed-properties with composition api's computed #1393

Closed
@sapphi-red

Description

@sapphi-red

What rule do you want to change?
vue/no-side-effects-in-computed-properties

Does this change cause the rule to produce more or fewer warnings?
more warnings

How will the change be implemented? (New option, new default behavior, etc.)?
new default behavior

Please provide some example code that this change will affect:

<script>
import { defineComponent, ref, computed } from 'vue'

export default defineComponent({
  setup() {
    const arr = ref(['aaa', 'b', 'c'])
    const sorted = computed(() => arr.value.sort((a,b) => a.length - b.length)) // here arr is being mutated
    return { sorted }
  }
})
</script>

What does the rule currently do for this code?
no warning

What will the rule do after it's changed?
show warning like computed properties

Additional context

Actually, this new feature does not affect computed properties, so it might have to be a new rule.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions