linter: no-useless-spread
fixer clobbers code before span in Vue script block #5913
Closed
Description
<template>
<div>Hello world</div>
</template>
<script lang="js">
const isCondition = true
const bar = {
...(isCondition ? { a: 1 } : { b: 2 })
}
export default {
data() {
bar
}
}
</script>
! �]8;;https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-useless-spread.html�\eslint-plugin-unicorn(no-useless-spread)�]8;;�\: Using a spread operator here creates a new object unnecessarily.
,-[src\renderer\App.vue:5:5]
4 | const bar = {
5 | ...(isCondition ? { a: 1 } : { b: 2 })
: ^^^
6 | }
`----
help: `isCondition ? { a: 1 } : { b: 2 }` returns a new object. Spreading it into an object expression to create a new object is redundant.
And here is the fix: