Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Copy link
Copy link
Closed
@FloEdelmann

Description

@FloEdelmann
Issue body actions

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.