Skip to content

vue/no-unused-properties does not recognize props in functional component (Vue 2) #1312

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
2 tasks done
FloEdelmann opened this issue Oct 2, 2020 · 2 comments · Fixed by #1761
Closed
2 tasks done

Comments

@FloEdelmann
Copy link
Member

FloEdelmann commented Oct 2, 2020

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: 7.10.0
  • eslint-plugin-vue version: 7.0.0
  • Node version: 12.18.4
  • Operating System: Ubuntu 20.04

Please show your full configuration:

{
  "env": {
    "es6": true,
    "node": true
  },
  "parserOptions": {
    "ecmaVersion": 2017
  },
  "plugins": ["vue"],
  "extends": ["plugin:vue/recommended"],
  "rules": {
    "vue/no-unused-properties": ["error", {
      "groups": ["props", "data", "computed", "methods", "setup"]
    }]
  }
}

What did you do?

<template functional>
  <time :datetime="props.date.toISOString()" :title="props.date.toISOString()">{{
    props.date.toISOString().replace(/T.*?$/, ``)
  }}</time>
</template>

<script>
export default {
  props: {
    date: {
      type: Date,
      required: true,
    },
  },
};
</script>

What did you expect to happen?
No error, since the date prop is used inside the template.

What actually happened?

error: 'date' of property found, but never used (vue/no-unused-properties) at ui/components/global/OflTime.vue:10:5:
   8 | export default {
   9 |   props: {
> 10 |     date: {
     |     ^
  11 |       type: Date,
  12 |       required: true,
  13 |     },

Repository to reproduce this issue
https://github.com/OpenLightingProject/open-fixture-library/blob/45508de7c812e9e4d9a55c9517d969c6606d53fd/ui/components/global/OflTime.vue

Related issue: #1669

@arrudaje
Copy link
Contributor

arrudaje commented Oct 7, 2020

@ota-meshi that's weird, I ran this exact piece of code through the test pipeline and it passed (I had to remove the replace(/T.*?$/, '') bit because it was not recognising the syntax), but when I included it in a real project in my IDE it marked it as invalid.

@laddi-netapp
Copy link

I'm getting the same errors when using props inside a render function where it doesn't recognise that context.props.xxx is being used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment