Skip to content

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

@alphatr

Description

@alphatr

Checklist

  • I have tried restarting my IDE and the issue persists.
    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

Activity

added
needs reproNeed a repository that can reproduce the problem, or a link to DEMO.
and removed
needs reproNeed a repository that can reproduce the problem, or a link to DEMO.
on Dec 23, 2024
waynzh

waynzh commented on Dec 31, 2024

@waynzh
Member

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.

aparajita

aparajita commented on Jan 11, 2025

@aparajita

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

<script setup lang="ts">
  const foo = 'bar'
</script>
<template>
  <p>{{ foo }}</p>
</template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @aparajita@alphatr@ota-meshi@waynzh

        Issue actions

          eslint rule `no-useless-assignment` doesn't work well. · Issue #2660 · vuejs/eslint-plugin-vue