Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Rule suggestion:vue/no-negated-condition forv-if/v-else in the template #2769

@FloEdelmann

Description

@FloEdelmann

Please describe what the rule should do:
Similar to the core ESLint ruleno-negated-condition (and its autofixable variantunicorn/no-negated-condition), this rule would report negated conditions in the template (only if bothif andelse cases are handled). Avoiding unnecessary negated conditions makes the code a bit easier to read.

What category should the rule belong to?
[ ] Enforces code style (layout)
[ ] Warns about a potential error (problem)
[x] Suggests an alternate way of doing something (suggestion)
[ ] Other (please specify:)

Provide 2-3 code examples that this rule should warn about:

<template>  <div><!-- BAD-->    <divv-if="!foo" />    <spanv-else /><!-- GOOD-->    <spanv-if="foo" />    <divv-else />  </div></template>

Additional context
Should it also report ternaries with negated conditions used in the template?

<template>  <div><!-- BAD-->    <div:class="!foo ? 'bar' : 'baz'" /><!-- GOOD-->    <div:class="foo ? 'baz' : 'bar'" />  </div></template>

Or should that be a different rule? Then the names could bevue/no-negated-condition for theno-negated-condition extension rule that applies to ternaries, andvue/no-negated-v-if-condition for the rule proposed above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp