noVueThisInTemplate (JavaScript)
Language JavaScript (and super languages)
Summary
Section titled “Summary”- Rule available since:
v2.6.5 - Diagnostic Category:
lint/nursery/noVueThisInTemplate - This rule has an unsafe fix.
- The default severity of this rule is information.
- This rule belongs to the following domains:
- Sources:
- Inspired from
vue/this-in-template
- Inspired from
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "noVueThisInTemplate": "error" } } }}Description
Section titled “Description”Disallow this in Vue templates.
Vue templates can read the properties of the component directly. Writing this.count
in a template does the same thing as writing count, so this only adds noise.
The rule doesn’t report this.name when writing name alone would mean something else,
for example when a v-for or v-slot variable, or a function parameter, has the same name.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”<template> <a :href="this.url">{{ text }}</a></template>
<template> <p>{{ this.text }}</p></template>
<template> <button @click="this.count++">Add</button></template>
<template> <a :href="url">{{ text }}</a> <button @click="count++">Add</button> <!-- `item` alone would be the `v-for` variable. --> <p v-for="item in items">{{ this.item }}</p></template>Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.