此代码:
if (this.config.imageTarget) {
this.caption = $('<div />')
.addClass('finaff-lightbox-caption')
.html(content.html())
.appendTo(this.wrapper)
.hide(); // starts out hidden
this.captionSpacer = $('<div> </div>')
.appendTo(this.contentContainer)
.hide();
...导致JSLint崩溃。它说:
if (this.config.imageTarget) {
58 this.caption = $('<div />')
59 .addClass('finaff-lightbox-caption')
==========================^
lint warning: unexpected end of line; it is ambiguous whether these lines are part of the same statement
60 .html(content.html())
===================================^
lint warning: unexpected end of line; it is ambiguous whether these lines are part of the same statement
61 .appendTo(this.wrapper)
===================================^
lint warning: unexpected end of line; it is ambiguous whether these lines are part of the same statement
62 .hide();
是否真的有必要像这样将这类代码合并:
. . .
this.caption = $('<div />').addClass('finaff-lightbox-caption').html(content.html()).appendTo(this.wrapper).hide();
. . .
通过排列点来分开它对我来说是有意义的;让它更容易阅读/ grok。我希望这只是JSLint扮演白手套的婆婆。
答案 0 :(得分:1)
您所要做的就是将white
选项(对于空白)设置为true。
此代码在JSLint.com处发布:
/*jslint white:true */
/*global $, content */
if (this.config.imageTarget) {
this.caption = $('<div />')
.addClass('finaff-lightbox-caption')
.html(content.html())
.appendTo(this.wrapper)
.hide(); // starts out hidden
this.captionSpacer = $('<div> </div>')
.appendTo(this.contentContainer)
.hide();
}
我所做的唯一改变是:
white
设置为true
(容忍非严格的空格规则)global
添加了content
行
content
是什么; global
几乎肯定不处理content
的最佳方法}
。if
括号