Skip to content

Add new vue/no-negated-condition rule #2795

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

Merged
merged 3 commits into from
Jul 14, 2025
Merged

Conversation

waynzh
Copy link
Member

@waynzh waynzh commented Jul 14, 2025

Resolve #2769
Related PR #2794

@waynzh waynzh requested a review from Copilot July 14, 2025 04:29
Copy link

changeset-bot bot commented Jul 14, 2025

🦋 Changeset detected

Latest commit: 702e432

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
eslint-plugin-vue Minor

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

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Introduce the new vue/no-negated-condition rule that wraps ESLint’s core no-negated-condition to enforce no negated conditions in Vue templates.

  • Add rule implementation with wrapCoreRule
  • Register the rule in the plugin index
  • Provide tests, documentation, and a changelog entry

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/lib/rules/no-negated-condition.js New RuleTester suite with valid and invalid cases
lib/rules/no-negated-condition.js Wraps the core ESLint rule via wrapCoreRule
lib/index.js Registers no-negated-condition in the plugin exports
docs/rules/no-negated-condition.md Docs for the rule with basic details and links
docs/rules/index.md Adds rule to the rules index table
.changeset/true-pumas-open.md Changelog entry for the new minor release
Comments suppressed due to low confidence (2)

tests/lib/rules/no-negated-condition.js:37

  • Add tests for negated conditions in structural directives like v-if and v-show (e.g., <div v-if="!foo">) to ensure the rule flags those cases.
  invalid: [

docs/rules/no-negated-condition.md:16

  • [nitpick] Include a dedicated ## Examples section with clear code blocks showing valid vs. invalid negated conditions in templates for better developer guidance.
This rule is the same rule as core [no-negated-condition] rule but it applies to the expressions in `<template>`.

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.

Thank you! 🙂

@FloEdelmann FloEdelmann merged commit ebbabd2 into master Jul 14, 2025
12 checks passed
@FloEdelmann FloEdelmann deleted the feature/no-negated-condition branch July 14, 2025 14:28
@github-actions github-actions bot mentioned this pull request Jul 14, 2025
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.

Rule suggestion: vue/no-negated-condition for v-if/v-else in the template
2 participants