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

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

Merged
merged 7 commits into from
Nov 27, 2024

Conversation

waynzh
Copy link
Member

@waynzh waynzh commented Nov 5, 2024

resolve #2596.

  • since this will result in fewer errors, should we still consider adding an option to control this?
  • multi root could also be a group of v-if / v-else / v-else nodes. Should we consider treating it as a "single" root?

@FloEdelmann
Copy link
Member

  • 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
Copy link
Member Author

waynzh commented Nov 10, 2024

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
Copy link
Member

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
Copy link
Member Author

waynzh commented Nov 12, 2024

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.

lib/rules/no-duplicate-attr-inheritance.js Outdated Show resolved Hide resolved
docs/rules/no-duplicate-attr-inheritance.md Show resolved Hide resolved
docs/rules/no-duplicate-attr-inheritance.md Outdated Show resolved Hide resolved
docs/rules/no-duplicate-attr-inheritance.md Outdated Show resolved Hide resolved
@@ -26,11 +26,12 @@ export default {
/* ✓ GOOD */
inheritAttrs: false
}
</script>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

docs/rules/no-duplicate-attr-inheritance.md Outdated Show resolved Hide resolved
Copy link
Member

@FloEdelmann FloEdelmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me now. Thanks for your work!

Copy link
Member

@ota-meshi ota-meshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you!

@ota-meshi ota-meshi enabled auto-merge (squash) November 27, 2024 05:53
@ota-meshi ota-meshi merged commit 86a8138 into vuejs:master Nov 27, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

no-duplicate-attr-inheritance: should ignore components with multiple root nodes?
3 participants