Vize

vue/this-in-template

Disallow this. in template expressions.

Default severity Presets Automatic fix Options
warning happy-path, nuxt, ecosystem, opinionated No None

Applies to: Vue SFC templates and blocks, with script context where the rule requires it.

Bad

Template expressions explicitly access this.message, this.className, and this.handleClick, although Vue exposes those bindings directly.

<template>
<div>{{ this.message }}</div>
<div :class="this.className"></div>
<button @click="this.handleClick()"></button>
</template>

Good

Use message, className, and handleClick directly. The literal string 'this.is.a.string' stays unchanged because it is not a member access.

<template>
<div>{{ message }}</div>
<div :class="className"></div>
<button @click="handleClick()"></button>
<div>{{ 'this.is.a.string' }}</div>
</template>

Configuration (Vite+)

import { defineConfig } from "@vizejs/vite-plugin/vite-plus";

export default defineConfig({}).withVue({
  linter: {
    "preset": "incremental",
    "rules": {
      "vue/this-in-template": "warn"
    }
  },
});

Then run vp run lint.