如何抑制单行的JSLint警告?

时间:2013-03-04 16:22:01

标签: javascript jslint

我使用nicEdit编辑器,它有一个名为nicEditor的函数对象。

JSLint发出警告:

  

构造函数名称'nicEditor'应以大写字母开头。

它忽略了我在麻烦的线“

之前放置的/*jslint newcap:false */选项
/*jslint newcap:false */
var nic_editor = new nicEditor({
    buttonList : ['bold', 'italic', 'underline', 'strikethrough', 'emoticonToolbar'],
    iconsPath : '/assets/nicEditorIcons.gif'
}),
/*jslint newcap:true */

如何禁止此警告,但仅针对此行?

1 个答案:

答案 0 :(得分:5)

我不相信它可能比你现在更精细。 TBH,我认为你目前的解决方案还不错。

如果你真的想避免newCaps设置,你可以使用局部变量来重命名构造函数:

var NicEditor = nicEditor;
var nic_editor = new NicEditor({
    buttonList : ['bold', 'italic', 'underline', 'strikethrough', 'emoticonToolbar'],
    iconsPath : '/assets/nicEditorIcons.gif'
}),
相关问题