vuejs / eslint-plugin-vue

Official ESLint plugin for Vue.js
https://eslint.vuejs.org/
MIT License
4.47k stars 667 forks source link

Feature request: Apply ESLint to inline event handlers #2573

Open henribru opened 1 month ago

henribru commented 1 month ago

Tell us about your environment

The problem you want to solve. ESLint rules don't seem to apply to the code inside inline event handlers (with the exception of what vue/v-on-handler-style checks). As an example, if I do

      @click="
        () => {
          const foo = 3;
          handleClick();
        }
      "

, I would expect no-unused-vars to trigger, but it doesn't. If instead I do

      @click="onClick"
---
function onClick() {
  const foo = 3;
  handleClick();
}

, it obviously does. It would be nice if this was consistent.

Your take on the correct solution to problem. Run ESLint on inline event handlers the same way as if they weren't inline.

Additional context