vue/no-negated-v-if-condition
eslint-plugin-vue
Safe autofix
eslint.config.js
import vue from "eslint-plugin-vue";
export default [
{
plugins: { vue },
rules: {
"vue/no-negated-v-if-condition": "error",
},
},
]; <div v-if="!foo">First</div>
<div v-else>Second</div>
<div v-if="a !== b">First</div>
<div v-else>Second</div>
<div v-if="foo">First</div>
<div v-else-if="!bar">Second</div>
<div v-else>Third</div>
</template><div v-if="foo">First</div>
<div v-else>Second</div>
<div v-if="!foo">First</div>
<div v-else-if="bar">Second</div>
<div v-if="!foo">Content</div>
<div v-if="a !== b">Not equal</div>Examples from the ESLint documentation.
No tracked preset enables this rule, so it has no reach yet.
None of the tracked presets enable this rule. Turn it on with the config below.
vue/no-negated-v-if-condition
eslint-plugin-vue
import vue from "eslint-plugin-vue";
export default [
{
plugins: { vue },
rules: {
"vue/no-negated-v-if-condition": "error",
},
},
];Oxlint does not have this rule.
nursery/noVueNegationElse
nursery · since 2.6.9
{
"linter": {
"rules": {
"nursery": {
"noVueNegationElse": "error"
}
}
}
}Disallow usages of ref objects that can lead to loss of reactivity
Disallow passing multiple objects in an array to class
Disallow asynchronously called restricted methods
Disallow shorthand type conversions in <template>