我最近开始使用eslint
模块来帮助清理一些JavaScript文件。我整理其中一个文件时,报告了以下错误:
127:17 error Unexpected alias 'me' for 'this' consistent-this
在checking the documentation之后,我了解到正在报告错误,因为我的代码将this
的值赋给了名为me
而不是that
的变量。
配置项目的.eslintrc.json
使其正确的方式是什么,以便不将以下代码行报告为错误:var me = this;
?
答案 0 :(得分:1)
.eslintrc中的规则应该是这样
{
"rules" : {
"consistent-this": ["error", "me"]
}
}