简体   繁体   English

为eslint一致指定其他别名吗?

[英]Designate additional alias names for eslint consistent-this rule?

I recently started using the eslint module to help clean-up some JavaScript files. 我最近开始使用eslint模块来帮助清理一些JavaScript文件。 The following error is being reported when I lint one of my files: 当我整理我的一个文件时,报告了以下错误:

127:17 error Unexpected alias 'me' for 'this' consistent-this

After checking the documentation , I understand the error is being reported because my code is assigning the value of this to a variable named me instead of that . 经过检查的文档 ,我的理解是所报告的错误,因为我的代码是分配的价值this一个变量命名的me ,而不是that

What is the proper way to configure my project's .eslintrc.json to make it so the following line of code is not reported as an error: var me = this; 配置我的项目的.eslintrc.json使其正确的正确方法是什么,这样.eslintrc.json以下代码行报告为错误: var me = this; ?

The rule should be like this in your .eslintrc 该规则应在您的.eslintrc中是这样的

{
   "rules" : {
       "consistent-this": ["error", "me"]
   }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM