JSLint在下划线的前缀变量名称中报告“意外悬挂”字符(JSLint reports “Unexpected dangling” character in an underscore prefixe

编程入门 行业动态 更新时间:2024-10-27 06:20:08
JSLint在下划线的前缀变量名称中报告“意外悬挂”字符(JSLint reports “Unexpected dangling” character in an underscore prefixed variable name)

我知道有些人认为存在一个领先的下划线,意味着一个变量是“私有的”,这样的隐私是一个小说,并且假设这是为什么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*/

更多推荐

本文发布于:2023-08-01 12:52:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1357906.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:前缀   变量   字符   意外   名称

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!