我知道有些人认为存在一个领先的下划线,意味着一个变量是“私有的”,这样的隐私是一个小说,并且假设这是为什么JSLint报告这样的名称与错误消息。
我在我正在建立的网站上使用Google Analytics(分析)。 我参考GA的变量,如“_gaq”。
我试图让我的JS代码是100%的JSLint干净(我不是宗教信仰我的编码风格,所以会和克罗克福德先生的律师一起去)。 也就是说,我无法做任何关于Google的变量名称...所以,我想我不能100%的“干净”。
我发布在这里,以防我误解了消息,并且可以做一些事情来遵守JSLint的做法。
I know that some people consider the presence of a leading underscore to imply that a variable is "private," that such privacy is a fiction, and assume this is why JSLint reports such names with an error message.
I use Google Analytics on a Web site I am building. I make reference to GA's variables, such as "_gaq."
I am trying to get my JS code to be 100% JSLint clean (I'm not religious about my coding style, and so will go with Mr. Crockford's counsel). That said, I can't do anything about Google's variables names... so, I guess I can't get 100% "clean."
I post here in case I've misunderstood the message, and can do something to comply with JSLint practices.
最满意答案
啊,我已经处理了...我用包含下划线的前缀变量的语句包装JSLint命令来禁用,然后重新启用这个类的错误:
/*jslint nomen: true*/ ... statement(s) with _var ... /*jslint nomen: false*/Ah, I've got this handled... I wrap the statements that use the underscore prefixed variables with JSLint commands to disable, then re-enable this class of error:
/*jslint nomen: true*/ ... statement(s) with _var ... /*jslint nomen: false*/更多推荐
发布评论