Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSHINT: how to disable the warning Missing space after anonymous 'function'

I got warning in jshint

  '[L76:C24] Missing space after 'function''

I follows Nicholas Zakkas Maintainable javascript styles where there is no space after anonymous function. How to remove this warning in jshint?

.jshintrc

{
    "node": true,
    "browser": true,
    "es5": true,
    "esnext": true,
    "bitwise": true,
    "camelcase": true,
    "curly": true,
    "eqeqeq": true,
    "immed": true,
    "indent": 4,
    "latedef": true,
    "newcap": true,
    "noarg": true,
    "quotmark": "single",
    "regexp": true,
    "undef": true,
    "unused": true,
    "strict": true,
    "trailing": true,
    "smarttabs": true
}
like image 895
Fizer Khan Avatar asked Apr 27 '13 14:04

Fizer Khan


1 Answers

Normally you have error notices in the following form in your CLI:

[L426:C63] W030: Expected an assignment or function call and instead saw an expression.

Now you can take that WXXX ID and add it to your options subobject. Simply add

"-WXXX" : true

for whatever notice you want to turn off. Keep in mind that you only can turn off all notices of a type and no specific notices on specific lines or lines in only single files. Still, you can add different tasks for different files and ignore different hints/notices that way.

Here's an example for grunt-contrib-jshint. Note: site.scripts comes from a YAML file that holds the config.

jshint : {
    dev : {
        options : {
            // Ignore: "Bad" line break
            "-W014" : true
        },
        src: [ "<%= site.scripts %>/**/*.js" ]
    }
}
like image 137
kaiser Avatar answered Sep 20 '22 21:09

kaiser