为什么 vue/this-in-template ESLint 规则不能自动修复?
Why isn't the vue/this-in-template ESLint rule automatically fixable?
在Vue.JS中,模板不需要使用this
来访问组件变量。 ESLint 的 Vue 扩展包含规则 vue/this-in-template 以在 this
被不必要地使用时发出警告,例如在下面的示例中。
<template>
<img
v-if="this.type == 'image'"
:src="this.imageURL"
class="cardImage"
/>
</template>
Line 2: error Unexpected usage of 'this' vue/this-in-template
Line 3: error Unexpected usage of 'this' vue/this-in-template
但是,此规则是少数不能自动修复的规则之一。这是为什么?
implementation of vue/this-in-template
currently does not implement fix()
,这是自动修复错误所必需的。
我认为它尚未实现,可能是因为可能有一些棘手的示例(可能是动态 属性 名称)需要进行重要的修复。从模板中删除 this
也没有发现任何安全问题。
在Vue.JS中,模板不需要使用this
来访问组件变量。 ESLint 的 Vue 扩展包含规则 vue/this-in-template 以在 this
被不必要地使用时发出警告,例如在下面的示例中。
<template>
<img
v-if="this.type == 'image'"
:src="this.imageURL"
class="cardImage"
/>
</template>
Line 2: error Unexpected usage of 'this' vue/this-in-template
Line 3: error Unexpected usage of 'this' vue/this-in-template
但是,此规则是少数不能自动修复的规则之一。这是为什么?
implementation of vue/this-in-template
currently does not implement fix()
,这是自动修复错误所必需的。
我认为它尚未实现,可能是因为可能有一些棘手的示例(可能是动态 属性 名称)需要进行重要的修复。从模板中删除 this
也没有发现任何安全问题。