Skip to content
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

vue/prefer-use-template-ref crashes for setup arrow function #2635

Open
2 tasks done
FloEdelmann opened this issue Dec 3, 2024 · 0 comments · May be fixed by #2636
Open
2 tasks done

vue/prefer-use-template-ref crashes for setup arrow function #2635

FloEdelmann opened this issue Dec 3, 2024 · 0 comments · May be fixed by #2636

Comments

@FloEdelmann
Copy link
Member

FloEdelmann commented Dec 3, 2024

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.16.0
  • eslint-plugin-vue version: 9.32.0
  • Vue version: 3.5.13
  • Node version: 22.11.0
  • Operating System: Kubuntu 22.04

Please show your full configuration:

{
  // …
  'vue/prefer-use-template-ref': 'error',
  // …
}

What did you do?

defineComponent({
    setup: () => ({}),
})

What did you expect to happen?
vue/prefer-use-template-ref should not crash.

What actually happened?

TypeError: Cannot read properties of undefined (reading 'filter')
Occurred while linting foo.ts:220
Rule: "vue/prefer-use-template-ref"
    at getScriptRefsFromSetupFunction (…/node_modules/eslint-plugin-vue/lib/rules/prefer-use-template-ref.js:33:37)
    at Object.onSetupFunctionEnter (…/node_modules/eslint-plugin-vue/lib/rules/prefer-use-template-ref.js:82:33)
    at callVisitor (…/node_modules/eslint-plugin-vue/lib/utils/index.js:1246:21)
    at vueVisitor.Property[value.type=/^(Arrow)?FunctionExpression$/] > :function (…/node_modules/eslint-plugin-vue/lib/utils/index.js:1314:13)
    at ruleErrorHandler (…/node_modules/eslint/lib/linter/linter.js:1076:28)
    at …/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (…/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (…/node_modules/eslint/lib/linter/node-event-generator.js:297:26)
    at NodeEventGenerator.applySelectors (…/node_modules/eslint/lib/linter/node-event-generator.js:326:22)

Repository to reproduce this issue
https://ota-meshi.github.io/eslint-plugin-vue-demo/#eJwtyzEKhDAQRuGrhKkSMAhbBrXxGmkW/QVBJ0My2Sbk7lrsKz94jba0gwJNZcun6BJ5x3Ey1nRLYrDaFtm8FWiVYKwz82Js626I3F3kafyfNFCuFwqFRr+KUTIOZF8LvOKW66vwL1H49P4AdL8oqw==

Additional information
This was not a problem in v9.31.0, so it was probably introduced in #2608 or #2612. CC @ntnyq @Thomasan1999

@FloEdelmann FloEdelmann changed the title vue/prefer-use-template-ref crashes when setup is an arrow function vue/prefer-use-template-ref crashes for setup arrow function Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant