Skip to content

False Positive for 'Big v-if' Rule #466

@bchanez

Description

@bchanez

Describe the bug
The vue-mess-detector plugin is triggering the "Big v-if" rule for my component, but I don't believe the v-if condition is large or complex enough to warrant this warning. The rule is being triggered on a relatively simple condition.

To Reproduce

  1. What is the exact code you are analyzing?
<script setup lang="ts">
defineProps({
  fieldError: {
    type: String as () => string,
    default: () => undefined,
  },
  generalErrors: {
    type: Array as () => string[],
    default: () => [],
  },
})
</script>

<template>
  <ion-text
    v-if="fieldError"
    class="ml-4 text-red-500"
  >
    {{ fieldError }}
  </ion-text>

  <div
    v-if="generalErrors.length"
    class="text-red-500 mt-4"
  >
    <ul>
      <li
        v-for="(error) in generalErrors"
        :key="error"
      >
        {{ error }}
      </li>
    </ul>
  </div>
</template>
  1. What is the output you are getting?
-  rrd ~ big v-if
   src/components/FormErrors.vue
   👉 Big v-if can be moved out to its own component. See: https://vue-mess-detector.webmania.cc/rules/rrd/big-vif.html
   line #9 has a v-if with 13 lines 🚨

Expected behavior
I expect the rule to not be triggered since the v-if condition is not that complex or large. The generalErrors condition is a simple check for an array length, and it does not seem to meet the threshold for a "big v-if" as per the rule.

Screenshots
N/A

Used version number of vue-mess-detector:
0.65.0

Used version number of node & yarn:
[email protected]

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingjules

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions