【问题标题】:How can I suppress a JSLint warning for a single line?如何抑制单行的 JSLint 警告?
【发布时间】:2013-02-18 19:26:34
【问题描述】:

我使用 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 */

我怎样才能抑制这个警告,但只针对这一行?

【问题讨论】:

  • 你能改用 JSHint 吗?有了它,这种事情就容易多了。
  • 我不认为我可以轻松切换,因为我通过 hallettj/jslint.vim Vim 插件使用 JSLint。

标签: javascript jslint


【解决方案1】:

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

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

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

【讨论】:

  • 就是这样!谢谢,不见不散
猜你喜欢
  • 2015-03-17
  • 1970-01-01
  • 1970-01-01
  • 2019-02-25
  • 2011-03-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多