简体   繁体   English

JS Lint:“ _ fnGetTrNodes”中意外悬挂了“ _”

[英]JS Lint: Unexpected dangling '_' in '_fnGetTrNodes'

My code looks like this: 我的代码如下所示:

$.extend($.fn.dataTableExt.afnSortData, {
    'dom-text': function (oSettings, iColumn) {
        var aData = [];
        $('td:eq(' + iColumn + ') input', oSettings.oApi._fnGetTrNodes(oSettings)).each(function () {
            aData.push(this.value);
        });
        return aData;
    },
    'dom-data-rk': function (oSettings, iColumn) {
        var aData = [];
        $('td:eq(' + iColumn + ')', oSettings.oApi._fnGetTrNodes(oSettings)).each(function () {
            aData.push($(this).attr('data-rk'));
        });
        return aData;
    }
});

I used JSLint and it came up with an error: 我使用了JSLint,它出现了一个错误:

Warning 21  JS Lint: Unexpected dangling '_' in '_fnGetTrNodes'.

Can someone explain what this means? 有人可以解释这是什么意思吗? I don't understand the error message at all :-( 我根本不理解错误消息:-(

JSLint simply doesn't like identifiers to begin with an underscore character. JSLint根本不喜欢标识符以下划线字符开头。 Change the identifier and the warning will go away, or add the following directive to the top of the file: 更改标识符,警告将消失,或在文件顶部添加以下指令:

/*jslint nomen: true */

The reason it doesn't like them is that people often use it to indicate a "private" variable, but doesn't actually change the behaviour of the variable. 它不喜欢他们的原因是人们经常使用它来表示“私有”变量,但实际上并没有改变变量的行为。

Do not use _ (underbar) as the first character of a name. 请勿将_(下划线)用作名称的首字符。 It is sometimes used to indicate privacy, but it does not actually provide privacy. 有时用于表示隐私,但实际上并不提供隐私。 If privacy is important, use the forms that provide private members. 如果隐私很重要,请使用提供私人成员的表格。 Avoid conventions that demonstrate a lack of competence. 避免表现出缺乏能力的约定。

more about code conventions used by JSLint here 更多关于使用JSLint的编码规范在这里

您可以简单地将“允许在标识符中悬挂_”设置为true来忽略此错误。

Well, JSlint doesn't like a variable name that begins with an underscore ( _ ). 嗯,JSlint不喜欢以下划线( _ )开头的变量名称。


It is better to use JShint.com instead of JSlint. 最好使用JShint.com而不是JSlint。 It's a fork of JSlint and provide you more options of configuration and doesn't show stupid errors like this. 它是JSlint的分支,可为您提供更多配置选项,并且不会显示此类愚蠢的错误。 https://stackoverflow.com/a/10763615/1149495 https://stackoverflow.com/a/10763615/1149495

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

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