Skip to content

no-unused-properties: Misses v-bind inside "style" section (with repro) #1789

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
iliubinskii opened this issue Feb 4, 2022 · 4 comments · Fixed by #1790
Closed

no-unused-properties: Misses v-bind inside "style" section (with repro) #1789

iliubinskii opened this issue Feb 4, 2022 · 4 comments · Fixed by #1790
Assignees
Labels

Comments

@iliubinskii
Copy link

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: ^6.7.2
  • eslint-plugin-vue version: ^7.0.0
  • Node version: 14.18
  • Operating System: Windows 10

Please show your full configuration:

See:
https://github.com/ilyub/repro-vue-no-unused-properties/blob/master/.eslintrc.js

rules: {
    "vue/no-unused-components": "warn",
    "vue/no-unused-properties": "warn",
  },

What did you do?

See:
https://github.com/ilyub/repro-vue-no-unused-properties/blob/master/src/components/HelloWorld.vue

<template>
...
</template>

<script lang="ts">
export default defineComponent({
  name: "HelloWorld",
  props: {
    msg: String,
    background: String,
    otherProp: String,
  },
});
</script>

<style scoped lang="scss">
h3 {
  background: v-bind(background);
}
</style>

What did you expect to happen?

One error: from otherProp.

What actually happened?

Two errors: from otherProp and background.

Note that background is used in "style" section.

IMPORTANT NOTE:
Bug occurs in the presense of "vue/no-unused-components".
If you disable it then you get one error as expected.

Repository to reproduce this issue

https://github.com/ilyub/repro-vue-no-unused-properties

@FloEdelmann
Copy link
Member

This exact issue has been fixed in the latest release: https://github.com/vuejs/eslint-plugin-vue/releases/tag/v8.4.0

Note that the eslint-plugin-vue version you're using (v7.0.0) was released one year ago and many newer versions exist.

@iliubinskii
Copy link
Author

iliubinskii commented Feb 4, 2022

I have upgraded eslint-plugin-vue to 8.4.0 in reproduction repository:
https://github.com/ilyub/repro-vue-no-unused-properties/blob/master/package.json
image

It does not fix issue.

I have checked version inside node_modules folder:
image
It is surely 8.4.0.

My project where I originally had the issue was upgraded to version 8.4.0 on 27 January and I am reporting issue more than week after. So I am surely using latest version.

The only reason why I mentioned v7.0.0 is because I created reproduction repository with "vue create" command and it installed v7.0.0. But now I upgraded reproduction repository, as mentioned above.

Please, re-open.

And please, pay attention to my comment about combination of "vue/no-unused-components" and "vue/no-unused-properties" rules:
image

@FloEdelmann FloEdelmann reopened this Feb 4, 2022
@FloEdelmann
Copy link
Member

@ota-meshi Can xou have a look at this?

@ota-meshi
Copy link
Member

I tried debugging it.
It seems that the calling order of 'Program:exit' and "VElement[parent.type!='VElement']:exit" AST node listeners differs depending on the rule registration order. This causes the rule to finish parsing before v-bind() processed, which can lead to false positives.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants