Skip to content

linter: no-useless-spread fixer clobbers code before span in Vue script block #5913

Closed
@axetroy

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

Metadata

Assignees

Labels

A-linterArea - LinterC-bugCategory - Bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions