eslint-plugin-vue icon indicating copy to clipboard operation
eslint-plugin-vue copied to clipboard

eslint rule `no-useless-assignment` doesn't work well.

Open alphatr opened this issue 11 months ago • 2 comments

Checklist

  • [x] I have tried restarting my IDE and the issue persists.
  • [x] I have read the FAQ and my problem is not listed.

Tell us about your environment

  • ESLint version: 9.17.0
  • eslint-plugin-vue version: 9.32.0
  • Vue version: 3.5.13
  • Node version: v22.11.0
  • Operating System: macos 15.1.1

Please show your full configuration:

import pluginVue from 'eslint-plugin-vue'

export default [
  ...pluginVue.configs['flat/base'],
  {
    rules: {
      'no-useless-assignment': 'error',
    }
  }
]

What did you do?

<template>
  <p :title="title">test</p>
</template>
<script setup>
import {ref} from "vue"

const title = ref("test")
const color = ref("#FFF")
</script>
<style>
p {
  color: v-bind(color);
}
</style>

What did you expect to happen?

doesn't report error;

What actually happened?

report error 'This assigned value is not used in subsequent statements.'

Repository to reproduce this issue

https://ota-meshi.github.io/eslint-plugin-vue-demo

alphatr avatar Dec 23 '24 12:12 alphatr

I can confirm this issue. It's likely something in vue-eslint-parser or we might need to add vue/no-useless-assignment to handle it. I haven't looked too closely yet, but will check when I have time.

waynzh avatar Dec 31 '24 11:12 waynzh

Will also flag the assigned to foo with something like this:

<script setup lang="ts">
  const foo = 'bar'
</script>
<template>
  <p>{{ foo }}</p>
</template>

aparajita avatar Jan 11 '25 01:01 aparajita