起源$log
:
Vue.prototype.$log = console.log
禁止场所:
<template>
<!-- Place 1 -->
<div @click="$log">
<!-- Place 2 -->
{{ $log }}
<!-- Place 3 -->
{{ $log('foo') }}
</div>
</template>
<script>
import Vue from 'vue'
// Place 4
Vue.prototype.$log('foo')
export default {
created() {
// Place 5
this.$log('foo')
},
}
</script>
一些可能有帮助的附加信息:
- ESLint - 如何限制属性this https://stackoverflow.com/questions/65432897/eslint-how-to-restrict-property-of-this
- 无限制语法 https://eslint.org/docs/rules/no-restricted-syntax
- vue/无限制语法 https://eslint.vuejs.org/rules/no-restricted-syntax.html
深入挖掘后no-restricted-syntax
, vue/no-restricted-syntax
规则,以及AST
s,我终于开始工作了,这是工作规则:
{
rules: {
'no-restricted-syntax': [
'error',
{
selector: '[name=$log]',
message: "Using '$log' is not allowed.",
},
],
'vue/no-restricted-syntax': [
'error',
{
selector: '[name=$log]',
message: "Using '$log' is not allowed.",
},
],
},
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)