-
-
Notifications
You must be signed in to change notification settings - Fork 687
Add vue/no-negated-v-if-condition
rule
#2794
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
base: master
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: fa09bb8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Introduces a new ESLint rule vue/no-negated-v-if-condition
to prohibit negated conditions in v-if
/v-else(-if)
when there’s an else
branch, with auto-suggestion to invert and swap blocks.
- Add rule implementation with detection and fix suggestions
- Add comprehensive tests covering valid/invalid scenarios
- Register rule in plugin and document it
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
tests/lib/rules/no-negated-v-if-condition.js | New test suite covering valid/invalid cases |
lib/rules/no-negated-v-if-condition.js | Rule logic, detection of negated conditions, fix suggestion generators |
lib/index.js | Plugin registration for the new rule |
docs/rules/no-negated-v-if-condition.md | Rule documentation with examples |
docs/rules/index.md | Added rule entry to the rules index |
Comments suppressed due to low confidence (1)
docs/rules/no-negated-v-if-condition.md:57
- [nitpick] In the Related Rules section, this rule currently links to itself. Consider updating it to reference the core ESLint rule
no-negated-condition
or another relevant rule instead of duplicating itself.
- [no-negated-v-if-condition](https://eslint.org/docs/rules/no-negated-v-if-condition)
Co-authored-by: Flo Edelmann <[email protected]>
…ure/np-negated-condition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really cool, thank you! I have just one minor code style nitpick, the rest looks good to me 🙂
Co-authored-by: Flo Edelmann <[email protected]>
related #2769
Found that the check and fix logic for ternaries is quite different. So, I extract
v-if
condition into a separate rule.I’ll submit a follow-up PR later to implement
vue/no-negated-condition
as an extension of theno-negated-condition
.Update: #2795