-
-
Notifications
You must be signed in to change notification settings - Fork 833
Closed
Labels
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:
2024-09-20.15.53.53.mov
Reactions are currently unavailable