webstrom warnings

I'm still getting some javascript warnings using the webstorm 11.0.1's default javascript checker for my node project and was hoping for some suggestions:

 
var x = moment().toDate(); // using moment, i get unresolved function or method toDate()

 
Session.destroy(criteria) // using Sailsjs, i get a require is missing warning

 
return bcrypt.compareAsync(req.body.password, user.password) // using promisify generated method, i get unresolved function or method. i am using the typescript plugin as recommended here. https://devnet.jetbrains.com/thread/473954?tstart=0
3 comments
Comment actions Permalink

1.

the problem is caused by a tricky way moment properties are defined; see, for example, what format() definition looks like:

(function (global, factory) {
    typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
    typeof define === 'function' && define.amd ? define(factory) :
    global.moment = factory()
}(this, function () {
...
function utils_hooks__hooks () {
        return hookCallback.apply(null, arguments);
    }
...
function Moment(config) {}
...
var momentPrototype__proto = Moment.prototype;
...
momentPrototype__proto.format       = format;
...
var momentPrototype = momentPrototype__proto;
..
utils_hooks__hooks.fn = momentPrototype;
...
var _moment = utils_hooks__hooks;

    return _moment;

}));

Such properties can hardly be resolved during static analysis,  without executing the code... As a workaround I can suggest downloading  typescript stubs for this library: Preferences/Languages &  Frameworks/JavaScript/Libraries, press Download..., select 'Typescript  community stubs' from the drop-down and choose 'moment' from the  libraries list

2. "require() call is missing" is a new inspection introduced in v. 11  - it checks if the module used in code is referenced through require()  statement. This inspection, indeed, is redundant for Sails.js that requires some modules and model classes in runtime and does not require it on file basis. But WebStorm doesn't provide Sails.js support and thus doesn't have any special treatment for it. You can either disable this inspection or suppress it for such statements

3. please can you provide more details - what this generated method is, is it generated dynamically? Full code snippet would be helpful

0
Comment actions Permalink

#1 for the moment issue, i beleive i installed the moment typescript lib as in the screenshot, but am still getting warnings. do you have a suggestion for what i might be doing wrong?

#2, i will do that

#3 i might have wording things incorrectly but i'm referring to this . http://bluebirdjs.com/docs/api/promise.promisifyall.html  i attached an example (promise-webstorm.zip) which makes the readFileAsync , which is what i meant by the dynamically making the method.



Attachment(s):
promise-webstorm.zip
Screen Shot 2015-11-20 at 10.58.56 AM.png
0
Comment actions Permalink

I see:) In this case, fs is imported via

var fs = Promise.promisifyAll(require("fs"));



WebStorm can't resolve such function, because it's generated dynamically while looping through 'fs' module functions and creating new functions with 'Async' suffix

0

Please sign in to leave a comment.