vuejs / eslint-plugin-vue

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

feat(no-duplicate-attr-inheritance): ignore multi root #2598

Open waynzh opened 2 weeks ago

waynzh commented 2 weeks ago

resolve #2596.

FloEdelmann commented 2 weeks ago
  • since this will result in fewer errors, should we still consider adding an option to control this?

I think it would make sense to add a new checkMultiRootNodes option (false by default).

  • multi root could also be a group of v-if / v-else / v-else nodes. Should we consider treating it as a "single" root?

How does Vue itself behave here?

waynzh commented 1 week ago

add a new checkMultiRootNodes option (false by default).

When checkMultiRootNodes is set to true, this rule will ignore the multi root nodes error. Perhaps we could consider renaming it to something like ignoreMultiRootNodes?

How does Vue itself behave here?

Vue treats a group of v-if / v-else-if/v-else as a single node. I've added an isConditionalGroup function to do that.

FloEdelmann commented 1 week ago

When checkMultiRootNodes is set to true, this rule will ignore the multi root nodes error. Perhaps we could consider renaming it to something like ignoreMultiRootNodes?

Sorry, my suggestion was not clear enough. I'd say the rule should stop reporting errors for components with multiple root nodes by default. But the old behavior should still be available (for users who want to explicitly define the behavior for multi-root components) via an option. Is checkMultiRootNodes a good name for that? Do you have a better suggestion?

waynzh commented 1 week ago

the rule should stop reporting errors for components with multiple root nodes by default

Then the name and setting the default to false make sense to me. I've updated the test cases and docs.