Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork688
Description
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.