JSLint: control comments (selective ignore)

后端 未结 9 1789
一生所求
一生所求 2020-12-01 06:16

Does JSLint have anything like JavaScript Lint\'s control comments (e.g. /*jsl:fallthru*/) to make it ignore certain passages?

9条回答
  •  無奈伤痛
    2020-12-01 06:50

    Yes. From the documentation [note that this is from an older version of the docs, but it still applies]:

    The implementation of JSLint accepts an option object that allows you to determine the subset of JavaScript that is acceptable to you. It is also possible to set those options within the source of a script.

    An option specification can look like this:

    /*jslint nomen: true, debug: true,
      evil: false, vars: true */
    

    An option specification starts with /*jslint. Notice that there is no space before the j. The specification contains a sequence of name value pairs, where the names are JSLint options, and the values are true or false. An option specification takes precedence over the option object.

    The documentation doesn't specifically mention it, but you can enable and disable different checks throughout the code with multiple jslint comments (thanks Dominic Mitchell).

    There is a complete list of options in the documentation.

提交回复
热议问题