JSlint线路断路格式



我真的不明白JSlint希望我如何格式化此脚本:

(function ($) {
    "use strict";
    window.isMobileDevice = function () {
        return (window.orientation !== undefined) || (navigator.userAgent.indexOf("IEMobile") !== -1);
    };
}());

我得到此错误:

Line is longer than 80 characters.
        return (window.orientation !== undefined) || (navigator.userAgent.indexOf("IEMobile") !== -1);

如果我添加了一个断路:

(function () {
    "use strict";
    window.isMobileDevice = function () {
        return (window.orientation !== undefined) ||
            (navigator.userAgent.indexOf("IEMobile") !== -1);
    };
}());

我得到此错误:

Expected '(' at column 8, not column 12.
            (navigator.userAgent.indexOf("IEMobile") !== -1);

应该如何格式化线路的格式?

完全就像它告诉您:Expected '(' at column 8, not column 12.。;^d

将那条线向后移动四个空间,而您是金色的。

在jslint.com上为我提供绒毛:

/*jslint browser*/
(function () {
    "use strict";
    window.isMobileDevice = function () {
        return (window.orientation !== undefined) ||
        (navigator.userAgent.indexOf("IEMobile") !== -1);
    };
}());

请注意,我还必须删除参数$,因为它没有使用。

但是您可以覆盖...

我认为这是我指出JSlint非常有用的,但是幸运的是,这是我们可以像您想要的那样将其更改为工作的地方。如果设置" white Space Mess"指令,则您的代码(减去$(是可以的。

/*jslint browser, white*/
(function () {
    "use strict";
    window.isMobileDevice = function () {
        return (window.orientation !== undefined) ||
            (navigator.userAgent.indexOf("IEMobile") !== -1);
    };
}());

最新更新