# no-constant-condition

Rule `vue/no-constant-condition`. Disallow constant expressions in conditions in `<template>`

- Source: vue
- Technologies: Vue
- Kind: correctness
- Needs type information: no
- Autofix: no
- Reach: 0 weekly downloads of presets that enable it
- Trend: 0% last quarter
- Rank: #1824 by reach

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `vue/no-constant-condition` | no | no | package `eslint-plugin-vue` | [docs](https://eslint.vuejs.org/rules/no-constant-condition.html) |
| Biome | `correctness/noConstantCondition` | yes | no | group correctness, since 1.0.0 | [docs](https://biomejs.dev/linter/rules/no-constant-condition/) |

## Code examples

### Incorrect: the rule reports this

```js
if (false) {
    doSomethingUnfinished();
}
```

```js
if (Boolean(1)) {
    doSomethingAlways();
}
```

```js
if (undefined) {
    doSomethingUnfinished();
}
```

### Correct: the rule accepts this

```js
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.

## Enable it

### ESLint: `eslint.config.js`

```js
import vue from "eslint-plugin-vue";

export default [
  {
    plugins: { vue },
    rules: {
      "vue/no-constant-condition": "error",
    },
  },
];
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "correctness": {
        "noConstantCondition": "error"
      }
    }
  }
}
```

## Related rules

- [eslint/no-constant-condition](https://lintradar.dev/rules/eslint/no-constant-condition.md): Disallow constant expressions in conditions
- [vue/no-console](https://lintradar.dev/rules/vue/no-console.md): Disallow the use of `console` in `<template>`
- [vue/no-content-outside-block](https://lintradar.dev/rules/vue/no-content-outside-block.md): Disallow content outside of the top-level blocks
- [vue/match-component-file-name](https://lintradar.dev/rules/vue/match-component-file-name.md): Require component name property to match its file name
- [vue/no-define-model-default](https://lintradar.dev/rules/vue/no-define-model-default.md): Disallow default values in `defineModel`
- [vue/html-button-has-type](https://lintradar.dev/rules/vue/html-button-has-type.md): Disallow usage of button without an explicit type attribute

---

Web page: https://lintradar.dev/rules/vue/no-constant-condition. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
