简体   繁体   中英

TsLint: function invocation disallowed

I have some TypeScript code like this in my Visual Studio project

if (_.isNull(user)) {
  //Do stuff
}

And on save, TSLint gives me

Message TsLint: function invocation disallowed: _.isNull    BaseCtrl.ts    127

I do have the TypeScript definitions for Underscore.js in my project.

What does this message mean & how do I either fix my code to make TSLint happy or turn off this message in my tslint.json project settings?

I believe this is an issue with using isNull which appears to be on the function ban list.

https://github.com/palantir/tslint/blob/master/src/rules/banRule.ts

The default ban list that comes with Web Essentials includes three ban rules:

"ban": [true,
       ["_", "extend"],
       ["_", "isNull"],
       ["_", "isDefined"]
 ],

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM