问题
To prohibit code like this.$log
.
The following config doesn't work:
{
'no-restricted-properties': [
2,
{
object: 'this',
property: '$log',
},
],
}
回答1:
You can achieve this by using no-restricted-syntax rule.
So in your .eslintrc
file add this rule.
"no-restricted-syntax": [
"error",
{
"selector": "MemberExpression[object.type='ThisExpression'][property.name='$log']",
"message": "this.$log is prohibited"
}
]
来源:https://stackoverflow.com/questions/65432897/eslint-how-to-restrict-property-of-this