vue/no-constant-condition
Disallow constant conditions in template expressions.
| Default severity | Presets | Automatic fix | Options |
|---|---|---|---|
warning |
None | No | None |
Applies to: Vue SFC templates and blocks, with script context where the rule requires it.
Bad
The ternary condition is always true.
<template>
<p>{{ true ? primary : fallback }}</p>
</template>
Good
The branch depends on the reactive ready value.
<template>
<p>{{ ready ? primary : fallback }}</p>
</template>
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"vue/no-constant-condition": "warn"
}
},
});
Then run vp run lint.