最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - 'debugger' command and JSLint - Stack Overflow

programmeradmin6浏览0评论

Google Chrome supports debugger mand as a tool to setup a breakpoint in code. How can I hide warnings for the following code in JSLint:

/*globals $, console, */
/*jslint browser:true, white: true */

function test() {

        "use strict";
        debugger;     // JSLint reports the "Unexpected 'debugger'" error
}

Google Chrome supports debugger mand as a tool to setup a breakpoint in code. How can I hide warnings for the following code in JSLint:

/*globals $, console, */
/*jslint browser:true, white: true */

function test() {

        "use strict";
        debugger;     // JSLint reports the "Unexpected 'debugger'" error
}
Share Improve this question edited Apr 19, 2017 at 1:00 ruffin 17.5k10 gold badges96 silver badges149 bronze badges asked Jan 2, 2014 at 13:39 MartyIXMartyIX 28.6k32 gold badges139 silver badges216 bronze badges
Add a ment  | 

5 Answers 5

Reset to default 11

JSLint has an explicit option to tolerate debugger statements, called debug:

debug: true if debugger statements should be allowed.

You can specify this option via your jslint directive:

/*jslint browser:true, white: true, debug: true */

This error is raised to highlight a lack of convention and possible oversight by the developer.

You can disable it via:

function test() {
    /* ignore jslint start */
    debugger;
    /* ignore jslint end */
}

Appears debug is gone, and this is now tolerated with the devel option, with the side effect that // TODO: etc are also tolerated with the single devel option.

devel: true if browser globals that are useful in development should be predefined, and if debugger statements and TODO ments should be allowed. It adds the same globals as this directive:

/*global
    alert, confirm, console, prompt
*/

Be sure to turn this option off before going into production.

This lints:

/*jslint white, devel */

function test() {
        "use strict";
        debugger;     // JSLint reports the "Unexpected 'debugger'" error
}

in react I used to do it during development like this:

debugger // eslint-disable-line

Disable no-debugger to make it work! (only applicable in Typescript tslint)

"rules": {
    "no-debugger": false
 }
发布评论

评论列表(0)

  1. 暂无评论