vue/no-constant-condition
eslint-plugin-vue
No autofix
eslint.config.js
import vue from "eslint-plugin-vue";
export default [
{
plugins: { vue },
rules: {
"vue/no-constant-condition": "error",
},
},
];if (false) {
doSomethingUnfinished();
}if (Boolean(1)) {
doSomethingAlways();
}if (undefined) {
doSomethingUnfinished();
}if (x === 0) {
doSomething();
}
for (;;) {
doSomethingForever();
}
while (typeof x === "undefined") {
doSomething();
}
do {
doSomething();
} while (x);
var result = x !== 0 ? a : b;
// Exception
while (true) {
if (x) { break; }
x = f();
}Examples from the Biome 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-constant-condition
eslint-plugin-vue
import vue from "eslint-plugin-vue";
export default [
{
plugins: { vue },
rules: {
"vue/no-constant-condition": "error",
},
},
];Oxlint does not have this rule.
correctness/noConstantCondition
correctness · since 1.0.0
{
"linter": {
"rules": {
"correctness": {
"noConstantCondition": "error"
}
}
}
}Disallow constant expressions in conditions
Require component name property to match its file name
Disallow shorthand type conversions in <template>
Disallow usage of button without an explicit type attribute