JSLint - you are expected to see the instruction, but instead see a block

I just turned on JSLint checking in Aptana Studio 3. In my web application, I have the following code:

Sessions.getVars = function()
{
    return $http.get(baseURL)
                .then(function(response) { return response.data; },
                      function(response) { /* TODO Error handling */ });    
};

This causes the following error Expected to see a statement but instead saw a block.

I looked through this question, but it really only answers the question about switch / case statements. Anyone who can help me understand why this error exists?

+4
source share
3 answers

This is much easier than straightening brackets. You have a certain type of block - an empty block - and JSLint does not like empty blocks. He wants allegations.

, undefined, , ​​:

/*jslint sloppy:true, white:true */
/*global Sessions, $http, baseURL */
Sessions.getVars = function()
{
    return $http.get(baseURL)
                .then(function(response) { return response.data; },
                      function(response) { return undefined; });    
};

, , .

, JSLint , squigglies, !; ^) , , JSLint.

:

  • sloppy - "use strict";
  • white - . , , , Expected exactly one space between ')' and '{'.

, JSLint.com, , , JSLint, , . old.jslint.com.

, , , JSLint " ", response : function() { return "Something"; });. .

TODO, todo.

:

/*jslint sloppy:true, white:true, todo:true */
/*global Sessions, $http, baseURL */
Sessions.getVars = function()
{
    return $http.get(baseURL)
        .then(function(response) { return response.data; },
            function() {
                /* TODO Error handling; add `err` to parameters */ 
                return undefined; 
        });    
};
+1

, , , jslint , , function, ..

function myFunc () { // Put it here
  // body...
}

​​, , .

PS. JSLint , , :

jshint eslint. jshint , eslint ( ) ( ).

+2

JavaScript . JS- -, .

{( ) , .

JavaScript, , (). .

JSLint - . , , JSHint .

0

All Articles