Skip to content

JSHint compatibility #54

@adambene

Description

@adambene

When the return value of an async operation is not assigned to a variable, then the result translates into a single expression and it raises a JSHint error.

set timeout! ^ 1000
log "Hello World!"

translates to

(function() {
    var Promise = require("bluebird");
    var gen1_promisify = function(fn) {
        return new Promise(function(onFulfilled, onRejected) {
            fn(function(error, result) {
                if (error) {
                    onRejected(error);
                } else {
                    onFulfilled(result);
                }
            });
        });
    };
    var self = this;
    var gen2_asyncResult;
    new Promise(function(gen3_onFulfilled) {
        gen3_onFulfilled(gen1_promisify(function(gen4_callback) {
            return setTimeout(gen4_callback, 1e3);
        }).then(function(gen2_asyncResult) {
            gen2_asyncResult; // <===== the JSHint error is here
            return log("Hello World!");
        }));
    });
}).call(this);

JSHint error on line 20:

20: Expected an assignment or function call and instead saw an expression

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions